summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-05-09 18:44:05 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-05-09 18:44:05 (GMT)
commit888c5a7dc8199ffdf42f5e58b26fa4863195f0e9 (patch)
treecb1e8e7a5c12fb40737d2308d68dfb33b4690e76
parent564e1f08a369740a5b081c0c29d88459c9ae1002 (diff)
downloadblt-888c5a7dc8199ffdf42f5e58b26fa4863195f0e9.zip
blt-888c5a7dc8199ffdf42f5e58b26fa4863195f0e9.tar.gz
blt-888c5a7dc8199ffdf42f5e58b26fa4863195f0e9.tar.bz2
add ds9 envi parser
-rw-r--r--ds9/library/envi.tcl41
-rw-r--r--ds9/library/source.tcl2
-rw-r--r--ds9/parsers/envilex.fcl16
-rw-r--r--ds9/parsers/enviparser.tac36
-rw-r--r--ds9/parsers/photolex.fcl1
-rw-r--r--ds9/parsers/photoparser.tac2
6 files changed, 70 insertions, 28 deletions
diff --git a/ds9/library/envi.tcl b/ds9/library/envi.tcl
index c03d496..43459b6 100644
--- a/ds9/library/envi.tcl
+++ b/ds9/library/envi.tcl
@@ -35,10 +35,13 @@ proc ProcessENVICmd {varname iname sock fn} {
upvar $varname var
upvar $iname i
- global loadParam
- global current
-
- set layer {}
+ global debug
+ if {$debug(tcl,parser)} {
+ envi::YY_FLUSH_BUFFER
+ envi::yy_scan_string [lrange $var $i end]
+ envi::yyparse
+ incr i [expr $envi::yycnt-1]
+ } else {
switch -- [string tolower [lindex $var $i]] {
new {
@@ -55,33 +58,15 @@ proc ProcessENVICmd {varname iname sock fn} {
}
}
- if {$sock != {}} {
- # xpa
- if {0} {
- # not supported
- } else {
- set fn [lindex $var $i]
- set fn2 [lindex $var [expr $i+1]]
- if {$fn2 == {}} {
- set fn2 [FindENVIDataFile $fn]
- }
- ImportENVIFile $fn $fn2
- }
- } else {
- # comm
- if {0} {
- # not supported
- } else {
- set fn [lindex $var $i]
- set fn2 [lindex $var [expr $i+1]]
- if {$fn2 == {}} {
- set fn2 [FindENVIDataFile $fn]
- }
- ImportENVIFile $fn $fn2
- }
+ set fn [lindex $var $i]
+ set fn2 [lindex $var [expr $i+1]]
+ if {$fn2 == {}} {
+ set fn2 [FindENVIDataFile $fn]
}
+ ImportENVIFile $fn $fn2
FinishLoad
}
+}
proc FindENVIDataFile {fn} {
set rn [file rootname $fn]
diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl
index 1f1204f..e6ed274 100644
--- a/ds9/library/source.tcl
+++ b/ds9/library/source.tcl
@@ -226,6 +226,8 @@ source $ds9(root)/library/dsssaoparser.tcl
source $ds9(root)/library/dsssaolex.tcl
source $ds9(root)/library/dssstsciparser.tcl
source $ds9(root)/library/dssstscilex.tcl
+source $ds9(root)/library/enviparser.tcl
+source $ds9(root)/library/envilex.tcl
source $ds9(root)/library/exportparser.tcl
source $ds9(root)/library/exportlex.tcl
source $ds9(root)/library/frameparser.tcl
diff --git a/ds9/parsers/envilex.fcl b/ds9/parsers/envilex.fcl
new file mode 100644
index 0000000..012cdaf
--- /dev/null
+++ b/ds9/parsers/envilex.fcl
@@ -0,0 +1,16 @@
+#tab enviparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+mask {return $MASK_}
+new {return $NEW_}
+slice {return $SLICE_}
+
+#include string.fin
+
+%%
diff --git a/ds9/parsers/enviparser.tac b/ds9/parsers/enviparser.tac
new file mode 100644
index 0000000..9cffdb7
--- /dev/null
+++ b/ds9/parsers/enviparser.tac
@@ -0,0 +1,36 @@
+%{
+%}
+
+#include string.tin
+
+%start command
+
+%token MASK_
+%token NEW_
+%token SLICE_
+
+%%
+
+command : envi
+ | envi {yyclearin; YYACCEPT} STRING_
+ ;
+
+envi : opts STRING_ {ImportENVIFile $2 [FindENVIDataFile $2]; FinishLoad}
+ | opts STRING_ STRING_ {ImportENVIFile $2 $3; FinishLoad}
+ ;
+
+opts :
+ | MASK_
+ | NEW_ {CreateFrame}
+ | SLICE_
+ ;
+
+%%
+
+proc envi::yyerror {msg} {
+ variable yycnt
+ variable yy_current_buffer
+ variable index_
+
+ ParserError $msg $yycnt $yy_current_buffer $index_
+}
diff --git a/ds9/parsers/photolex.fcl b/ds9/parsers/photolex.fcl
index c39bd1b..49fe286 100644
--- a/ds9/parsers/photolex.fcl
+++ b/ds9/parsers/photolex.fcl
@@ -7,6 +7,7 @@
%%
+mask {return $MASK_}
new {return $NEW_}
slice {return $SLICE_}
diff --git a/ds9/parsers/photoparser.tac b/ds9/parsers/photoparser.tac
index 2cf3dc7..7187e9f 100644
--- a/ds9/parsers/photoparser.tac
+++ b/ds9/parsers/photoparser.tac
@@ -5,6 +5,7 @@
%start command
+%token MASK_
%token NEW_
%token SLICE_
@@ -19,6 +20,7 @@ photo : opts {PhotoCmdLoad {}}
;
opts :
+ | MASK_
| NEW_ {CreateFrame}
| SLICE_ {PhotoCmdSet load,mode slice}
;