s/\#.*//;
next unless m/\S/;
s/\s+$//;
- m/^([A-Z0-9]+)(?:\s+([^\t ;]+))?(?:\s+\;\s*(.*))?$/
+ m/^([A-Z0-9]+)(\??)(?:\s+([^\t ;]+))?(?:\s+\;\s*(.*))?$/
or oops("syntax error");
$morse_name= $1;
+ $morse_optional= $2;
@morse= split //, $morse_name;
- @addrs= defined($2) ? split /\,/, $2 : ();
- $comment= $3;
+ @addrs= defined($3) ? split /\,/, $3 : ();
+ $comment= $4;
@addrs < 8 or oops("only up to 7 addrs are supported");
unshift @data, sprintf "0x%x%x", scalar(@addrs), $morse_bytes;
push @data, map {
- s/^\:/ $filename.':' /e;
+ s/^\:\b/ $filename.':' /e;
$filename= $1 if m/^([^:]+)\:/;
$_ = $symval{$_} if exists $symval{$_};
- m/\:/ ? ' xxx_unknown_xxx' : "$_ - (0xf00 * !(($_ & 0xf00)^0xf00))"
+ if ($which eq 'inc') {
+ $val= $_;
+ } elsif (m/\:/) {
+ printf STDERR "morse-generator: message \`%s': %s".
+ "unknown symbol \`%s'\n",
+ $morse_name, ($morse_optional ? 'warning: ' :''), $_;
+ exit 4 unless $morse_optional;
+ $val= ' xxx_unknown_xxx';
+ } else {
+ $val= "$_ - (0xf00 * !(($_ & 0xf00)^0xf00))";
+ }
+ $val;
} @addrs;
push @data, ('0') x (3 - (scalar(@data) + 3) % 4);
# Messages for slave detection/i2c
DW ; slave write (nyi)
-DQ FSR2L,:outmsg_end ; previous slave read incomplete
-DR FSR2L,:outmsg_end ; slave read overrun
+DQ FSR2L,::outmsg_end ; previous slave read incomplete
+DR FSR2L,::outmsg_end ; slave read overrun
# Messages for specific peripherals
RS FSR0L ; POLARITY message too short
PB points:pointmsg ; Firing point when already busy
PI points:pointmsg,T3CON ; Unexpected Timer 3 interrupt
PU points:pointmsg ; Firing nonexistent point
-PF points:t ; Flash mentions point not on board
+PF ::t ; Flash mentions point not on board