summaryrefslogtreecommitdiffstats
path: root/fickle
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-03-03 21:25:31 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-03-03 21:25:31 (GMT)
commit1883aba178b0a40e813a634ad31dbc81181f0857 (patch)
treed6fedbbddef1a284241700c494fc86bfefdcfcbf /fickle
parenta0458d71bf7875ac52952810693213c2ef7585dd (diff)
downloadblt-1883aba178b0a40e813a634ad31dbc81181f0857.zip
blt-1883aba178b0a40e813a634ad31dbc81181f0857.tar.gz
blt-1883aba178b0a40e813a634ad31dbc81181f0857.tar.bz2
add #tab and #include
Diffstat (limited to 'fickle')
-rw-r--r--fickle/fickle.tcl40
1 files changed, 34 insertions, 6 deletions
diff --git a/fickle/fickle.tcl b/fickle/fickle.tcl
index 9636581..a0454b0 100644
--- a/fickle/fickle.tcl
+++ b/fickle/fickle.tcl
@@ -625,8 +625,9 @@ proc ${::p}::yylex \{\} \{
variable index_
variable done_
variable state_table_
-
- while \{1\} \{"
+"
+ puts $::dest $::tab
+ puts $::dest " while \{1\} \{"
if $::startstates {
puts $::dest " set yy_current_state \[yy_top_state\]"
}
@@ -844,6 +845,7 @@ proc fickle_args {argv} {
set ::BUFFER_SIZE 1024
set ::p "yy"
set ::verbose 0
+ set ::tab {}
while {$argvp < [llength $argv]} {
set arg [lindex $argv $argvp]
switch -- $arg {
@@ -878,13 +880,13 @@ proc fickle_args {argv} {
set ::src stdin
set out_filename "lex.yy.tcl"
} else {
- set in_filename [lindex $argv $argvp]
+ set ::in_filename [lindex $argv $argvp]
if {$out_filename == ""} {
- set out_filename [file rootname $in_filename]
+ set out_filename [file rootname $::in_filename]
append out_filename ".tcl"
}
- if [catch {open $in_filename r} ::src] {
- puts stderr "Could not open specification file '$in_filename'."
+ if [catch {open $::in_filename r} ::src] {
+ puts stderr "Could not open specification file '$::in_filename'."
exit $::IO_ERROR
}
}
@@ -934,6 +936,32 @@ proc fickle_main {} {
if {$line == "%%"} {
set file_state "subroutines"
break
+ } elseif {[lindex $line 0] == "#tab"} {
+ set dir [file dirname $::in_filename]
+ set fn [lindex $line 1]
+ if {$fn != {}} {
+ if [catch {open [file join $dir $fn] r} ch] {
+ puts stderr "Could not open tab file '$fn'."
+ exit $::IO_ERROR
+ }
+ catch {set ::tab [read $ch]}
+ catch {close $fn}
+ }
+ } elseif {[lindex $line 0] == "#include"} {
+ set dir [file dirname $::in_filename]
+ set fn [lindex $line 1]
+ if {$fn != {}} {
+ if [catch {open [file join $dir $fn] r} ch] {
+ puts stderr "Could not open include file '$fn'."
+ exit $::IO_ERROR
+ }
+ while {[gets $ch line] >= 0} {
+ incr ::line_count
+ append rules_buf "\n" \
+ [strip_only_comments $line]
+ }
+ catch {close $fn}
+ }
} else {
append rules_buf "\n" [strip_only_comments $line]
}