#!/usr/bin/perl -w

# converts an inc-file to a C-array

$count = 0;

print "\n//DONT EDIT THIS FILE, IT IS AUTO-GENERATED!\n\n";
print "#include <inttypes.h>\n";
print "#include <avr/pgmspace.h>\n\n";

while (<>) {
    if (/^\s*[;\#]/) {
	next;  # skip comments
    }

    if (/([\d\w]+):/) {
	print "uint8_t PROGMEM $1\[\] = {\n    ";
    }
    
    if (/DB\s+(\d+)T/i) {
	if ($count != 0) {
	    print ",\n    ";
	}
	printf("%d", $1);
	$count++;
    }
}

print "};\n";
