From 92fc6a10347cc38b62c621728ed33aa267dcc75b Mon Sep 17 00:00:00 2001 From: William Joye Date: Fri, 11 May 2018 13:09:54 -0400 Subject: add ds9 mosaicwcs/mosiciraf parsers --- ds9/library/mosaiciraf.tcl | 35 +++++++++++++++++++++++++++++++--- ds9/library/mosaicwcs.tcl | 35 +++++++++++++++++++++++++++++++--- ds9/library/source.tcl | 4 ++++ ds9/parsers/mosaiciraflex.fcl | 15 +++++++++++++++ ds9/parsers/mosaicirafparser.tac | 34 +++++++++++++++++++++++++++++++++ ds9/parsers/mosaicwcslex.fcl | 16 ++++++++++++++++ ds9/parsers/mosaicwcsparser.tac | 41 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 174 insertions(+), 6 deletions(-) create mode 100644 ds9/parsers/mosaiciraflex.fcl create mode 100644 ds9/parsers/mosaicirafparser.tac create mode 100644 ds9/parsers/mosaicwcslex.fcl create mode 100644 ds9/parsers/mosaicwcsparser.tac diff --git a/ds9/library/mosaiciraf.tcl b/ds9/library/mosaiciraf.tcl index be91595..c2a3656 100644 --- a/ds9/library/mosaiciraf.tcl +++ b/ds9/library/mosaiciraf.tcl @@ -47,11 +47,19 @@ proc ProcessMosaicIRAFCmd {varname iname sock fn} { upvar $varname var upvar $iname i - global loadParam - global current + global debug + if {$debug(tcl,parser)} { + global parse + set parse(sock) $sock + set parse(fn) $fn - set layer {} + mosaiciraf::YY_FLUSH_BUFFER + mosaiciraf::yy_scan_string [lrange $var $i end] + mosaiciraf::yyparse + incr i [expr $mosaiciraf::yycnt-1] + } else { + set layer {} switch -- [string tolower [lindex $var $i]] { new { incr i @@ -84,3 +92,24 @@ proc ProcessMosaicIRAFCmd {varname iname sock fn} { } FinishLoad } +} + +proc MosaicIRAFCmdLoad {param layer} { + global parse + + if {$parse(sock) != {}} { + # xpa + if {![LoadMosaicIRAFSocket $parse(sock) $param $layer]} { + InitError xpa + LoadMosaicIRAFFile $param $layer + } + } else { + # comm + if {$parse(fn) != {}} { + LoadMosaicIRAFAlloc $parse(fn) $param $layer + } else { + LoadMosaicIRAFFile $param $layer + } + } + FinishLoad +} diff --git a/ds9/library/mosaicwcs.tcl b/ds9/library/mosaicwcs.tcl index 3e4b604..65e16b0 100644 --- a/ds9/library/mosaicwcs.tcl +++ b/ds9/library/mosaicwcs.tcl @@ -83,11 +83,19 @@ proc ProcessMosaicWCSCmd {varname iname sock fn} { upvar $varname var upvar $iname i - global loadParam - global current + global debug + if {$debug(tcl,parser)} { + global parse + set parse(sock) $sock + set parse(fn) $fn + + mosaicwcs::YY_FLUSH_BUFFER + mosaicwcs::yy_scan_string [lrange $var $i end] + mosaicwcs::yyparse + incr i [expr $mosaicwcs::yycnt-1] + } else { set layer {} - switch -- [string tolower [lindex $var $i]] { new { incr i @@ -127,6 +135,27 @@ proc ProcessMosaicWCSCmd {varname iname sock fn} { } FinishLoad } +} + +proc MosaicWCSCmdLoad {param layer sys} { + global parse + + if {$parse(sock) != {}} { + # xpa + if {![LoadMosaicWCSSocket $parse(sock) $param $layer $sys]} { + InitError xpa + LoadMosaicWCSFile $param $layer $sys + } + } else { + # comm + if {$parse(fn) != {}} { + LoadMosaicWCSAlloc $parse(fn) $param $layer $sys + } else { + LoadMosaicWCSFile $param $layer $sys + } + } + FinishLoad +} proc ProcessSendMosaicWCSCmd {proc id param sock fn} { global current diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index a24b714..e750ddb 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -256,6 +256,10 @@ source $ds9(root)/library/minmaxparser.tcl source $ds9(root)/library/minmaxlex.tcl source $ds9(root)/library/modeparser.tcl source $ds9(root)/library/modelex.tcl +source $ds9(root)/library/mosaicwcsparser.tcl +source $ds9(root)/library/mosaicwcslex.tcl +source $ds9(root)/library/mosaicirafparser.tcl +source $ds9(root)/library/mosaiciraflex.tcl source $ds9(root)/library/mosaicimageirafparser.tcl source $ds9(root)/library/mosaicimageiraflex.tcl source $ds9(root)/library/mosaicimagewcsparser.tcl diff --git a/ds9/parsers/mosaiciraflex.fcl b/ds9/parsers/mosaiciraflex.fcl new file mode 100644 index 0000000..aaf5a95 --- /dev/null +++ b/ds9/parsers/mosaiciraflex.fcl @@ -0,0 +1,15 @@ +#tab mosaicirafparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +mask {return $MASK_} +new {return $NEW_} + +#include string.fin + +%% diff --git a/ds9/parsers/mosaicirafparser.tac b/ds9/parsers/mosaicirafparser.tac new file mode 100644 index 0000000..1ecf784 --- /dev/null +++ b/ds9/parsers/mosaicirafparser.tac @@ -0,0 +1,34 @@ +%{ +%} + +#include string.tin + +%start command + +%token MASK_ +%token NEW_ + +%% + +command : mosaiciraf + | mosaiciraf {yyclearin; YYACCEPT} STRING_ + ; + +mosaiciraf : opts {MosaicIRAFCmdLoad {} $1} + | opts STRING_ {MosaicIRAFCmdLoad $2 $1} + ; + +opts : + | NEW_ {CreateFrame; set _ {}} + | MASK_ {set _ mask} + ; + +%% + +proc mosaiciraf::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} diff --git a/ds9/parsers/mosaicwcslex.fcl b/ds9/parsers/mosaicwcslex.fcl new file mode 100644 index 0000000..807a62e --- /dev/null +++ b/ds9/parsers/mosaicwcslex.fcl @@ -0,0 +1,16 @@ +#tab mosaicwcsparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +mask {return $MASK_} +new {return $NEW_} + +#include coords.fin +#include string.fin + +%% diff --git a/ds9/parsers/mosaicwcsparser.tac b/ds9/parsers/mosaicwcsparser.tac new file mode 100644 index 0000000..f29bff9 --- /dev/null +++ b/ds9/parsers/mosaicwcsparser.tac @@ -0,0 +1,41 @@ +%{ +%} + +#include coords.tin +#include string.tin + +%start command + +%token MASK_ +%token NEW_ + +%% + +#include coords.trl + +command : mosaicwcs + | mosaicwcs {yyclearin; YYACCEPT} STRING_ + ; + +mosaicwcs : sys opts {MosaicWCSCmdLoad {} $2 $1} + | sys opts STRING_ {MosaicWCSCmdLoad $3 $2 $1} + ; + +sys : {set _ wcs} + | wcssys {set _ $1} + ; + +opts : + | NEW_ {CreateFrame; set _ {}} + | MASK_ {set _ mask} + ; + +%% + +proc mosaicwcs::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} -- cgit v0.12