summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-05-10 16:38:20 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-05-10 16:38:20 (GMT)
commit583f23d32829ac3d0c605747f3c08b686ed49c66 (patch)
treedf9e202d10c25c7a67f97433a90f49bf946e5e85
parent862a4a9a3489bc2f064416e8d567c4e7d5c8fd62 (diff)
downloadblt-583f23d32829ac3d0c605747f3c08b686ed49c66.zip
blt-583f23d32829ac3d0c605747f3c08b686ed49c66.tar.gz
blt-583f23d32829ac3d0c605747f3c08b686ed49c66.tar.bz2
add ds9 rgbcube parser
-rw-r--r--ds9/library/rgbcube.tcl33
-rw-r--r--ds9/library/source.tcl2
-rw-r--r--ds9/parsers/rgbcubelex.fcl14
-rw-r--r--ds9/parsers/rgbcubeparser.tac32
4 files changed, 81 insertions, 0 deletions
diff --git a/ds9/library/rgbcube.tcl b/ds9/library/rgbcube.tcl
index dfd2e2f..76424ce 100644
--- a/ds9/library/rgbcube.tcl
+++ b/ds9/library/rgbcube.tcl
@@ -111,6 +111,18 @@ proc ProcessRGBCubeCmd {varname iname sock fn} {
upvar $varname var
upvar $iname i
+ global debug
+ if {$debug(tcl,parser)} {
+ global rgbcube
+ set rgbcube(load,sock) $sock
+ set rgbcube(load,fn) $fn
+
+ rgbcube::YY_FLUSH_BUFFER
+ rgbcube::yy_scan_string [lrange $var $i end]
+ rgbcube::yyparse
+ incr i [expr $rgbcube::yycnt-1]
+ } else {
+
switch -- [string tolower [lindex $var $i]] {
new {
incr i
@@ -143,6 +155,27 @@ proc ProcessRGBCubeCmd {varname iname sock fn} {
}
FinishLoad
}
+}
+
+proc RGBCubeCmdLoad {param} {
+ global rgbcube
+
+ if {$rgbcube(load,sock) != {}} {
+ # xpa
+ if {![LoadRGBCubeSocket $rgbcube(load,sock) $param]} {
+ InitError xpa
+ LoadRGBCubeFile $param
+ }
+ } else {
+ # comm
+ if {$rgbcube(load,fn) != {}} {
+ LoadRGBCubeAlloc $rgbcube(load,fn) $param
+ } else {
+ LoadRGBCubeFile $param
+ }
+ }
+ FinishLoad
+}
proc ProcessSendRGBCubeCmd {proc id param sock fn} {
global current
diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl
index 237f0f2..090df28 100644
--- a/ds9/library/source.tcl
+++ b/ds9/library/source.tcl
@@ -288,6 +288,8 @@ source $ds9(root)/library/regionparser.tcl
source $ds9(root)/library/regionlex.tcl
source $ds9(root)/library/rgbparser.tcl
source $ds9(root)/library/rgblex.tcl
+source $ds9(root)/library/rgbcubeparser.tcl
+source $ds9(root)/library/rgbcubelex.tcl
source $ds9(root)/library/sampparser.tcl
source $ds9(root)/library/samplex.tcl
source $ds9(root)/library/saveparser.tcl
diff --git a/ds9/parsers/rgbcubelex.fcl b/ds9/parsers/rgbcubelex.fcl
new file mode 100644
index 0000000..bf43fb5
--- /dev/null
+++ b/ds9/parsers/rgbcubelex.fcl
@@ -0,0 +1,14 @@
+#tab rgbcubeparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+new {return $NEW_}
+
+#include string.fin
+
+%%
diff --git a/ds9/parsers/rgbcubeparser.tac b/ds9/parsers/rgbcubeparser.tac
new file mode 100644
index 0000000..61142c5
--- /dev/null
+++ b/ds9/parsers/rgbcubeparser.tac
@@ -0,0 +1,32 @@
+%{
+%}
+
+#include string.tin
+
+%start command
+
+%token NEW_
+
+%%
+
+command : rgbcube
+ | rgbcube {yyclearin; YYACCEPT} STRING_
+ ;
+
+rgbcube : opts {RGBCubeCmdLoad {}}
+ | opts STRING_ {RGBCubeCmdLoad $2}
+ ;
+
+opts :
+ | NEW_ {CreateRGBFrame}
+ ;
+
+%%
+
+proc rgbcube::yyerror {msg} {
+ variable yycnt
+ variable yy_current_buffer
+ variable index_
+
+ ParserError $msg $yycnt $yy_current_buffer $index_
+}