summaryrefslogtreecommitdiffstats
path: root/taccle
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-03-03 22:52:59 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-03-03 22:52:59 (GMT)
commit5afae68c2d49c6a4ac9506bdbb019fce13d261ce (patch)
treec15cdc4afdab241a82285a19cc1e12fe1bfe208d /taccle
parentd0d911010be430036b02a3cca7b884a4281c2208 (diff)
downloadblt-5afae68c2d49c6a4ac9506bdbb019fce13d261ce.zip
blt-5afae68c2d49c6a4ac9506bdbb019fce13d261ce.tar.gz
blt-5afae68c2d49c6a4ac9506bdbb019fce13d261ce.tar.bz2
add defs include file
Diffstat (limited to 'taccle')
-rw-r--r--taccle/taccle.tcl39
1 files changed, 34 insertions, 5 deletions
diff --git a/taccle/taccle.tcl b/taccle/taccle.tcl
index 0d6948b..4259a09 100644
--- a/taccle/taccle.tcl
+++ b/taccle/taccle.tcl
@@ -1513,13 +1513,14 @@ proc taccle_args {argv} {
print_taccle_help stderr
exit $::IO_ERROR
}
- set in_filename [lindex $argv $argvp]
+ set ::in_filename [lindex $argv $argvp]
+ set ::in_dir [file dirname $::in_filename]
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 grammar file '$in_filename'."
+ if [catch {open $::in_filename r} ::src] {
+ puts stderr "Could not open grammar file '$::in_filename'."
exit $::IO_ERROR
}
if [catch {open $out_filename w} ::dest] {
@@ -1580,7 +1581,22 @@ proc taccle_main {} {
}
} else {
if {$file_state == "definitions"} {
- handle_defs $line
+ if {[lindex $line 0] == "#include"} {
+ set fn [lindex $line 1]
+ if {$fn != {}} {
+ if [catch {open [file join $::in_dir $fn] r} ch] {
+ puts stderr "Could not open definition file '$fn'."
+ exit $::IO_ERROR
+ }
+ while {[gets $ch line] >= 0} {
+ incr ::line_count
+ handle_defs $line
+ }
+ catch {close $fn}
+ }
+ } else {
+ handle_defs $line
+ }
} elseif {$file_state == "rules"} {
# keep reading the rest of the file until EOF or
# another '%%' appears
@@ -1588,6 +1604,19 @@ proc taccle_main {} {
while {[gets $::src line] >= 0 && $file_state == "rules"} {
if {$line == "%%"} {
set file_state "subroutines"
+ } elseif {[lindex $line 0] == "#include"} {
+ set fn [lindex $line 1]
+ if {$fn != {}} {
+ if [catch {open [file join $::in_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_comments $line]
+ }
+ catch {close $fn}
+ }
} else {
append rules_buf "\n" [strip_comments $line]
}