OLD | NEW |
1 #!/usr/bin/tclsh | 1 #!/usr/bin/tclsh |
2 # | 2 # |
3 # This script appends additional token codes to the end of the | 3 # This script appends additional token codes to the end of the |
4 # parse.h file that lemon generates. These extra token codes are | 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 | 5 # not used by the parser. But they are used by the tokenizer and/or |
6 # the code generator. | 6 # the code generator. |
7 # | 7 # |
8 # | 8 # |
9 set in [open [lindex $argv 0] rb] | 9 set in [open [lindex $argv 0] rb] |
10 set max 0 | 10 set max 0 |
(...skipping 19 matching lines...) Expand all Loading... |
30 ISNOT | 30 ISNOT |
31 END_OF_FILE | 31 END_OF_FILE |
32 UNCLOSED_STRING | 32 UNCLOSED_STRING |
33 FUNCTION | 33 FUNCTION |
34 COLUMN | 34 COLUMN |
35 AGG_FUNCTION | 35 AGG_FUNCTION |
36 AGG_COLUMN | 36 AGG_COLUMN |
37 UMINUS | 37 UMINUS |
38 UPLUS | 38 UPLUS |
39 REGISTER | 39 REGISTER |
| 40 VECTOR |
| 41 SELECT_COLUMN |
40 ASTERISK | 42 ASTERISK |
| 43 SPAN |
41 SPACE | 44 SPACE |
42 ILLEGAL | 45 ILLEGAL |
43 } | 46 } |
44 if {[lrange $extras end-1 end]!="SPACE ILLEGAL"} { | 47 if {[lrange $extras end-1 end]!="SPACE ILLEGAL"} { |
45 error "SPACE and ILLEGAL must be the last two token codes and they\ | 48 error "SPACE and ILLEGAL must be the last two token codes and they\ |
46 must be in that order" | 49 must be in that order" |
47 } | 50 } |
48 foreach x $extras { | 51 foreach x $extras { |
49 incr max | 52 incr max |
50 puts [format "#define TK_%-29s %4d" $x $max] | 53 puts [format "#define TK_%-29s %4d" $x $max] |
51 } | 54 } |
52 | 55 |
53 # Some additional #defines related to token codes. | 56 # Some additional #defines related to token codes. |
54 # | 57 # |
55 puts "\n/* The token codes above must all fit in 8 bits */" | 58 puts "\n/* The token codes above must all fit in 8 bits */" |
56 puts [format "#define %-20s %-6s" TKFLG_MASK 0xff] | 59 puts [format "#define %-20s %-6s" TKFLG_MASK 0xff] |
57 puts "\n/* Flags that can be added to a token code when it is not" | 60 puts "\n/* Flags that can be added to a token code when it is not" |
58 puts "** being stored in a u8: */" | 61 puts "** being stored in a u8: */" |
59 foreach {fg val comment} { | 62 foreach {fg val comment} { |
60 TKFLG_DONTFOLD 0x100 {/* Omit constant folding optimizations */} | 63 TKFLG_DONTFOLD 0x100 {/* Omit constant folding optimizations */} |
61 } { | 64 } { |
62 puts [format "#define %-20s %-6s %s" $fg $val $comment] | 65 puts [format "#define %-20s %-6s %s" $fg $val $comment] |
63 } | 66 } |
OLD | NEW |