blob: c5c3525ad4c86e0f9c3a64236f1eb198a6750df7 [file] [log] [blame]
drh60a15a42015-10-07 12:21:14 +00001#!/usr/bin/tclsh
2#
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
6# the code generator.
7#
8#
9set in [open [lindex $argv 0] rb]
10set max 0
11while {![eof $in]} {
12 set line [gets $in]
13 if {[regexp {^#define TK_} $line]} {
14 puts $line
15 set x [lindex $line 2]
16 if {$x>$max} {set max $x}
17 }
18}
19close $in
20
21# The following are the extra token codes to be added
22#
23set extras {
24 TO_TEXT
25 TO_BLOB
26 TO_NUMERIC
27 TO_INT
28 TO_REAL
29 ISNOT
30 END_OF_FILE
31 ILLEGAL
32 SPACE
33 UNCLOSED_STRING
34 FUNCTION
35 COLUMN
36 AGG_FUNCTION
37 AGG_COLUMN
38 UMINUS
39 UPLUS
40 REGISTER
41}
42foreach x $extras {
43 incr max
44 puts [format "#define TK_%-29s %4d" $x $max]
45}
drh1167d322015-10-28 20:01:45 +000046
47# Some additional #defines related to token codes.
48#
49puts "\n/* The token codes above must all fit in 8 bits */"
50puts [format "#define %-20s %-6s" TKFLG_MASK 0xff]
51puts "\n/* Flags that can be added to a token code when it is not"
52puts "** being stored in a u8: */"
53foreach {fg val comment} {
54 TKFLG_DONTFOLD 0x100 {/* Omit constant folding optimizations */}
55} {
56 puts [format "#define %-20s %-6s %s" $fg $val $comment]
57}