From 888c5a7dc8199ffdf42f5e58b26fa4863195f0e9 Mon Sep 17 00:00:00 2001 From: William Joye Date: Wed, 9 May 2018 14:44:05 -0400 Subject: add ds9 envi parser --- ds9/library/envi.tcl | 41 +++++++++++++---------------------------- ds9/library/source.tcl | 2 ++ ds9/parsers/envilex.fcl | 16 ++++++++++++++++ ds9/parsers/enviparser.tac | 36 ++++++++++++++++++++++++++++++++++++ ds9/parsers/photolex.fcl | 1 + ds9/parsers/photoparser.tac | 2 ++ 6 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 ds9/parsers/envilex.fcl create mode 100644 ds9/parsers/enviparser.tac 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} ; -- cgit v0.12