2015-10-07 15:21:14 +03:00
|
|
|
#!/usr/bin/tclsh
|
|
|
|
#
|
|
|
|
# This script appends additional token codes to the end of the
|
|
|
|
# parse.h file that lemon generates. These extra token codes are
|
|
|
|
# not used by the parser. But they are used by the tokenizer and/or
|
|
|
|
# the code generator.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
set in [open [lindex $argv 0] rb]
|
|
|
|
set max 0
|
|
|
|
while {![eof $in]} {
|
|
|
|
set line [gets $in]
|
|
|
|
if {[regexp {^#define TK_} $line]} {
|
|
|
|
puts $line
|
|
|
|
set x [lindex $line 2]
|
|
|
|
if {$x>$max} {set max $x}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close $in
|
|
|
|
|
2015-11-09 05:08:09 +03:00
|
|
|
# The following are the extra token codes to be added. SPACE and
|
|
|
|
# ILLEGAL *must* be the last two token codes and they must be in that order.
|
2015-10-07 15:21:14 +03:00
|
|
|
#
|
|
|
|
set extras {
|
2018-02-26 21:49:05 +03:00
|
|
|
TRUEFALSE
|
2015-10-07 15:21:14 +03:00
|
|
|
ISNOT
|
|
|
|
FUNCTION
|
|
|
|
COLUMN
|
|
|
|
AGG_FUNCTION
|
|
|
|
AGG_COLUMN
|
|
|
|
UMINUS
|
|
|
|
UPLUS
|
2018-02-26 21:49:05 +03:00
|
|
|
TRUTH
|
2015-10-07 15:21:14 +03:00
|
|
|
REGISTER
|
2016-08-18 18:36:03 +03:00
|
|
|
VECTOR
|
2016-07-09 23:23:55 +03:00
|
|
|
SELECT_COLUMN
|
2017-04-14 22:03:10 +03:00
|
|
|
IF_NULL_ROW
|
2015-11-19 19:33:31 +03:00
|
|
|
ASTERISK
|
2016-02-28 00:16:04 +03:00
|
|
|
SPAN
|
2017-08-02 14:36:16 +03:00
|
|
|
END_OF_FILE
|
|
|
|
UNCLOSED_STRING
|
2015-11-09 05:08:09 +03:00
|
|
|
SPACE
|
|
|
|
ILLEGAL
|
|
|
|
}
|
|
|
|
if {[lrange $extras end-1 end]!="SPACE ILLEGAL"} {
|
|
|
|
error "SPACE and ILLEGAL must be the last two token codes and they\
|
|
|
|
must be in that order"
|
2015-10-07 15:21:14 +03:00
|
|
|
}
|
|
|
|
foreach x $extras {
|
|
|
|
incr max
|
|
|
|
puts [format "#define TK_%-29s %4d" $x $max]
|
|
|
|
}
|
2015-10-28 23:01:45 +03:00
|
|
|
|
|
|
|
# Some additional #defines related to token codes.
|
|
|
|
#
|
|
|
|
puts "\n/* The token codes above must all fit in 8 bits */"
|
|
|
|
puts [format "#define %-20s %-6s" TKFLG_MASK 0xff]
|
|
|
|
puts "\n/* Flags that can be added to a token code when it is not"
|
|
|
|
puts "** being stored in a u8: */"
|
|
|
|
foreach {fg val comment} {
|
|
|
|
TKFLG_DONTFOLD 0x100 {/* Omit constant folding optimizations */}
|
|
|
|
} {
|
|
|
|
puts [format "#define %-20s %-6s %s" $fg $val $comment]
|
|
|
|
}
|