summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-05-08 20:49:47 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-05-08 20:49:47 (GMT)
commit3df839da664ea2addc7ccc6d7868dc55b0ee279b (patch)
tree74ca46807bbf44eb0214c3c71c5f10d7e49e6666
parent00025e4e4f0b0469fc6c3bd5ffb4ef3e457fd30f (diff)
downloadblt-3df839da664ea2addc7ccc6d7868dc55b0ee279b.zip
blt-3df839da664ea2addc7ccc6d7868dc55b0ee279b.tar.gz
blt-3df839da664ea2addc7ccc6d7868dc55b0ee279b.tar.bz2
add ds9 source parser
-rw-r--r--ds9/library/source.tcl2
-rw-r--r--ds9/library/util.tcl17
-rw-r--r--ds9/parsers/sourcelex.fcl12
-rw-r--r--ds9/parsers/sourceparser.tac25
4 files changed, 53 insertions, 3 deletions
diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl
index f70f0e1..d503984 100644
--- a/ds9/library/source.tcl
+++ b/ds9/library/source.tcl
@@ -292,6 +292,8 @@ source $ds9(root)/library/sleepparser.tcl
source $ds9(root)/library/sleeplex.tcl
source $ds9(root)/library/smoothparser.tcl
source $ds9(root)/library/smoothlex.tcl
+source $ds9(root)/library/sourceparser.tcl
+source $ds9(root)/library/sourcelex.tcl
source $ds9(root)/library/threedparser.tcl
source $ds9(root)/library/threedlex.tcl
source $ds9(root)/library/tileparser.tcl
diff --git a/ds9/library/util.tcl b/ds9/library/util.tcl
index dfb7991..5a67d90 100644
--- a/ds9/library/util.tcl
+++ b/ds9/library/util.tcl
@@ -1650,13 +1650,24 @@ proc ProcessSleepCmd {varname iname} {
proc ProcessSourceCmd {varname iname} {
upvar $varname var
upvar $iname i
- SourceCmd [lindex $var $i]
-}
-proc SourceCmd {fn} {
# we need to be realized
# you never know what someone will try to do
ProcessRealizeDS9
+
+ global debug
+ if {$debug(tcl,parser)} {
+ source::YY_FLUSH_BUFFER
+ source::yy_scan_string [lrange $var $i end]
+ source::yyparse
+ incr i [expr $source::yycnt-1]
+ } else {
+
+ uplevel #0 "source [lindex $var $i]"
+}
+}
+
+proc SourceCmd {fn} {
uplevel #0 "source $fn"
}
diff --git a/ds9/parsers/sourcelex.fcl b/ds9/parsers/sourcelex.fcl
new file mode 100644
index 0000000..8c17472
--- /dev/null
+++ b/ds9/parsers/sourcelex.fcl
@@ -0,0 +1,12 @@
+#tab sourceparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+#include string.fin
+
+%%
diff --git a/ds9/parsers/sourceparser.tac b/ds9/parsers/sourceparser.tac
new file mode 100644
index 0000000..4ae5b8a
--- /dev/null
+++ b/ds9/parsers/sourceparser.tac
@@ -0,0 +1,25 @@
+%{
+%}
+
+#include string.tin
+
+%start command
+
+%%
+
+command : source
+ | source {yyclearin; YYACCEPT} STRING_
+ ;
+
+source : STRING_ {SourceCmd $1}
+ ;
+
+%%
+
+proc source::yyerror {msg} {
+ variable yycnt
+ variable yy_current_buffer
+ variable index_
+
+ ParserError $msg $yycnt $yy_current_buffer $index_
+}