3 # This script appends additional token codes to the end of the
4 # parse.h file that lemon generates. These extra token codes are
5 # not used by the parser. But they are used by the tokenizer and/or
9 set in
[open [lindex $argv 0] rb
]
13 if {[regexp {^
#define TK_} $line]} {
15 set x
[lindex $line 2]
16 if {$x>$max} {set max
$x}
21 # The following are the extra token codes to be added. SPACE and
22 # ILLEGAL *must* be the last two token codes and they must be in that order.
45 if {[lrange $extras end-1 end
]!="SPACE ILLEGAL"} {
46 error "SPACE and ILLEGAL must be the last two token codes and they\
47 must be in that order"
51 puts [format "#define TK_%-29s %4d" $x $max]
54 # Some additional #defines related to token codes.
56 puts "\n/* The token codes above must all fit in 8 bits */"
57 puts [format "#define %-20s %-6s" TKFLG_MASK
0xff]
58 puts "\n/* Flags that can be added to a token code when it is not"
59 puts "** being stored in a u8: */"
60 foreach {fg val comment
} {
61 TKFLG_DONTFOLD
0x100 {/* Omit constant folding optimizations
*/}
63 puts [format "#define %-20s %-6s %s" $fg $val $comment]