summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-05-10 18:35:53 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-05-10 18:35:53 (GMT)
commit92ad0b6f98fafe51cf6fbb4ff4a082cc87d8ee3c (patch)
treed70b3c644cf9703e275f855237ca0284d85372f2
parentaf4920d1c5c55b2be51b8f76f6f1ef168003f8d2 (diff)
downloadblt-92ad0b6f98fafe51cf6fbb4ff4a082cc87d8ee3c.zip
blt-92ad0b6f98fafe51cf6fbb4ff4a082cc87d8ee3c.tar.gz
blt-92ad0b6f98fafe51cf6fbb4ff4a082cc87d8ee3c.tar.bz2
add ds9 srgbcube parser
-rw-r--r--ds9/library/array.tcl3
-rw-r--r--ds9/library/rgbarray.tcl30
-rw-r--r--ds9/library/rgbimage.tcl33
-rw-r--r--ds9/library/source.tcl6
-rw-r--r--ds9/library/srgbcube.tcl9
-rw-r--r--ds9/parsers/rgbarraylex.fcl3
-rw-r--r--ds9/parsers/rgbarrayparser.tac12
-rw-r--r--ds9/parsers/rgbimagelex.fcl2
-rw-r--r--ds9/parsers/rgbimageparser.tac10
-rw-r--r--ds9/parsers/srgbcubelex.fcl14
-rw-r--r--ds9/parsers/srgbcubeparser.tac31
11 files changed, 134 insertions, 19 deletions
diff --git a/ds9/library/array.tcl b/ds9/library/array.tcl
index 3f95167..902316b 100644
--- a/ds9/library/array.tcl
+++ b/ds9/library/array.tcl
@@ -82,6 +82,9 @@ proc ProcessArrayCmd {varname iname sock fn} {
set array(load,sock) $sock
set array(load,fn) $fn
set array(load,layer) {}
+ global rgbarray
+ set rgbarray(load,sock) $sock
+ set rgbarray(load,fn) $fn
array::YY_FLUSH_BUFFER
array::yy_scan_string [lrange $var $i end]
diff --git a/ds9/library/rgbarray.tcl b/ds9/library/rgbarray.tcl
index 1bcccc1..3417eec 100644
--- a/ds9/library/rgbarray.tcl
+++ b/ds9/library/rgbarray.tcl
@@ -127,8 +127,17 @@ proc ProcessRGBArrayCmd {varname iname sock fn} {
upvar $varname var
upvar $iname i
- global loadParam
- global current
+ global debug
+ if {$debug(tcl,parser)} {
+ global rgbarray
+ set rgbarray(load,sock) $sock
+ set rgbarray(load,fn) $fn
+
+ rgbarray::YY_FLUSH_BUFFER
+ rgbarray::yy_scan_string [lrange $var $i end]
+ rgbarray::yyparse
+ incr i [expr $rgbarray::yycnt-1]
+ } else {
switch -- [string tolower [lindex $var $i]] {
new {
@@ -162,20 +171,21 @@ proc ProcessRGBArrayCmd {varname iname sock fn} {
}
FinishLoad
}
+}
proc RGBArrayCmdLoad {param} {
- global array
+ global rgbarray
- if {$array(load,sock) != {}} {
+ if {$rgbarray(load,sock) != {}} {
# xpa
- if {![ImportRGBArraySocket $array(load,sock) $param]} {
+ if {![ImportRGBArraySocket $rgbarray(load,sock) $param]} {
InitError xpa
ImportRGBArrayFile $param
}
} else {
# comm
- if {$array(load,fn) != {}} {
- ImportRGBArrayAlloc $array(load,fn) $param
+ if {$rgbarray(load,fn) != {}} {
+ ImportRGBArrayAlloc $rgbarray(load,fn) $param
} else {
ImportRGBArrayFile $param
}
@@ -183,6 +193,12 @@ proc RGBArrayCmdLoad {param} {
FinishLoad
}
+proc RGBArrayCmdSet {which value} {
+ global rgbarray
+
+ set rgbarray($which) $value
+}
+
proc ProcessSendRGBArrayCmd {proc id param sock fn} {
global current
diff --git a/ds9/library/rgbimage.tcl b/ds9/library/rgbimage.tcl
index 4f40c32..8f96d68 100644
--- a/ds9/library/rgbimage.tcl
+++ b/ds9/library/rgbimage.tcl
@@ -129,6 +129,18 @@ proc ProcessRGBImageCmd {varname iname sock fn} {
upvar $varname var
upvar $iname i
+ global debug
+ if {$debug(tcl,parser)} {
+ global rgbimage
+ set rgbimage(load,sock) $sock
+ set rgbimage(load,fn) $fn
+
+ rgbimage::YY_FLUSH_BUFFER
+ rgbimage::yy_scan_string [lrange $var $i end]
+ rgbimage::yyparse
+ incr i [expr $rgbimage::yycnt-1]
+ } else {
+
switch -- [string tolower [lindex $var $i]] {
new {
incr i
@@ -161,6 +173,27 @@ proc ProcessRGBImageCmd {varname iname sock fn} {
}
FinishLoad
}
+}
+
+proc RGBImageCmdLoad {param} {
+ global rgbimage
+
+ if {$rgbimage(load,sock) != {}} {
+ # xpa
+ if {![LoadRGBImageSocket $rgbimage(load,sock) $param]} {
+ InitError xpa
+ LoadRGBImageFile $param
+ }
+ } else {
+ # comm
+ if {$rgbimage(load,fn) != {}} {
+ LoadRGBImageAlloc $rgbimage(load,fn) $param
+ } else {
+ LoadRGBImageFile $param
+ }
+ }
+ FinishLoad
+}
proc ProcessSendRGBImageCmd {proc id param sock fn} {
global current
diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl
index 090df28..dc6073e 100644
--- a/ds9/library/source.tcl
+++ b/ds9/library/source.tcl
@@ -288,8 +288,12 @@ 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/rgbarrayparser.tcl
+source $ds9(root)/library/rgbarraylex.tcl
source $ds9(root)/library/rgbcubeparser.tcl
source $ds9(root)/library/rgbcubelex.tcl
+source $ds9(root)/library/rgbimageparser.tcl
+source $ds9(root)/library/rgbimagelex.tcl
source $ds9(root)/library/sampparser.tcl
source $ds9(root)/library/samplex.tcl
source $ds9(root)/library/saveparser.tcl
@@ -308,6 +312,8 @@ 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/srgbcubeparser.tcl
+source $ds9(root)/library/srgbcubelex.tcl
source $ds9(root)/library/threadsparser.tcl
source $ds9(root)/library/threadslex.tcl
source $ds9(root)/library/threedparser.tcl
diff --git a/ds9/library/srgbcube.tcl b/ds9/library/srgbcube.tcl
index 28902fb..ac8f448 100644
--- a/ds9/library/srgbcube.tcl
+++ b/ds9/library/srgbcube.tcl
@@ -33,6 +33,14 @@ proc ProcessSRGBCubeCmd {varname iname sock fn} {
upvar $varname var
upvar $iname i
+ global debug
+ if {$debug(tcl,parser)} {
+ srgbcube::YY_FLUSH_BUFFER
+ srgbcube::yy_scan_string [lrange $var $i end]
+ srgbcube::yyparse
+ incr i [expr $srgbcube::yycnt-1]
+ } else {
+
switch -- [string tolower [lindex $var $i]] {
new {
incr i
@@ -65,3 +73,4 @@ proc ProcessSRGBCubeCmd {varname iname sock fn} {
}
FinishLoad
}
+}
diff --git a/ds9/parsers/rgbarraylex.fcl b/ds9/parsers/rgbarraylex.fcl
index bf43fb5..7f2d962 100644
--- a/ds9/parsers/rgbarraylex.fcl
+++ b/ds9/parsers/rgbarraylex.fcl
@@ -1,4 +1,4 @@
-#tab rgbcubeparser.tab.tcl
+#tab rgbarrayparser.tab.tcl
%{
%}
@@ -7,6 +7,7 @@
%%
+mask {return $MASK_}
new {return $NEW_}
#include string.fin
diff --git a/ds9/parsers/rgbarrayparser.tac b/ds9/parsers/rgbarrayparser.tac
index 61142c5..b69a283 100644
--- a/ds9/parsers/rgbarrayparser.tac
+++ b/ds9/parsers/rgbarrayparser.tac
@@ -5,25 +5,27 @@
%start command
+%token MASK_
%token NEW_
%%
-command : rgbcube
- | rgbcube {yyclearin; YYACCEPT} STRING_
+command : rgbarray
+ | rgbarray {yyclearin; YYACCEPT} STRING_
;
-rgbcube : opts {RGBCubeCmdLoad {}}
- | opts STRING_ {RGBCubeCmdLoad $2}
+rgbarray : opts {RGBArrayCmdLoad {}}
+ | opts STRING_ {RGBArrayCmdLoad $2}
;
opts :
| NEW_ {CreateRGBFrame}
+ | MASK_ {RGBArrayCmdSet load,layer mask}
;
%%
-proc rgbcube::yyerror {msg} {
+proc rgbarray::yyerror {msg} {
variable yycnt
variable yy_current_buffer
variable index_
diff --git a/ds9/parsers/rgbimagelex.fcl b/ds9/parsers/rgbimagelex.fcl
index bf43fb5..cf8f852 100644
--- a/ds9/parsers/rgbimagelex.fcl
+++ b/ds9/parsers/rgbimagelex.fcl
@@ -1,4 +1,4 @@
-#tab rgbcubeparser.tab.tcl
+#tab rgbimageparser.tab.tcl
%{
%}
diff --git a/ds9/parsers/rgbimageparser.tac b/ds9/parsers/rgbimageparser.tac
index 61142c5..4997c0b 100644
--- a/ds9/parsers/rgbimageparser.tac
+++ b/ds9/parsers/rgbimageparser.tac
@@ -9,12 +9,12 @@
%%
-command : rgbcube
- | rgbcube {yyclearin; YYACCEPT} STRING_
+command : rgbimage
+ | rgbimage {yyclearin; YYACCEPT} STRING_
;
-rgbcube : opts {RGBCubeCmdLoad {}}
- | opts STRING_ {RGBCubeCmdLoad $2}
+rgbimage : opts {RGBImageCmdLoad {}}
+ | opts STRING_ {RGBImageCmdLoad $2}
;
opts :
@@ -23,7 +23,7 @@ opts :
%%
-proc rgbcube::yyerror {msg} {
+proc rgbimage::yyerror {msg} {
variable yycnt
variable yy_current_buffer
variable index_
diff --git a/ds9/parsers/srgbcubelex.fcl b/ds9/parsers/srgbcubelex.fcl
new file mode 100644
index 0000000..bf43fb5
--- /dev/null
+++ b/ds9/parsers/srgbcubelex.fcl
@@ -0,0 +1,14 @@
+#tab rgbcubeparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+new {return $NEW_}
+
+#include string.fin
+
+%%
diff --git a/ds9/parsers/srgbcubeparser.tac b/ds9/parsers/srgbcubeparser.tac
new file mode 100644
index 0000000..34b386a
--- /dev/null
+++ b/ds9/parsers/srgbcubeparser.tac
@@ -0,0 +1,31 @@
+%{
+%}
+
+#include string.tin
+
+%start command
+
+%token NEW_
+
+%%
+
+command : rgbcube
+ | rgbcube {yyclearin; YYACCEPT} STRING_
+ ;
+
+rgbcube : opts STRING_ STRING_ {LoadSRGBCubeFile $2 $3}
+ ;
+
+opts :
+ | NEW_ {CreateRGBFrame}
+ ;
+
+%%
+
+proc rgbcube::yyerror {msg} {
+ variable yycnt
+ variable yy_current_buffer
+ variable index_
+
+ ParserError $msg $yycnt $yy_current_buffer $index_
+}