From 44b298577ac9f07ec6560fe0a1f6bbd37f8bd250 Mon Sep 17 00:00:00 2001 From: William Joye Date: Thu, 10 May 2018 17:23:51 -0400 Subject: add ds9 mosaicimagewfpc2 parser --- ds9/library/mosaicimagewfpc2.tcl | 32 ++++++++++++++++++++++++++++++-- ds9/library/source.tcl | 2 ++ ds9/parsers/mosaicimagewfpc2lex.fcl | 14 ++++++++++++++ ds9/parsers/mosaicimagewfpc2parser.tac | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 ds9/parsers/mosaicimagewfpc2lex.fcl create mode 100644 ds9/parsers/mosaicimagewfpc2parser.tac diff --git a/ds9/library/mosaicimagewfpc2.tcl b/ds9/library/mosaicimagewfpc2.tcl index 1fe23fc..ac59f98 100644 --- a/ds9/library/mosaicimagewfpc2.tcl +++ b/ds9/library/mosaicimagewfpc2.tcl @@ -53,8 +53,17 @@ proc ProcessMosaicImageWFPC2Cmd {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 + + mosaicimagewfpc2::YY_FLUSH_BUFFER + mosaicimagewfpc2::yy_scan_string [lrange $var $i end] + mosaicimagewfpc2::yyparse + incr i [expr $mosaicimagewfpc2::yycnt-1] + } else { switch -- [string tolower [lindex $var $i]] { new { @@ -88,5 +97,24 @@ proc ProcessMosaicImageWFPC2Cmd {varname iname sock fn} { } FinishLoad } +} +proc MosaicImageWFPC2CmdLoad {param} { + global parse + if {$parse(sock) != {}} { + # xpa + if {![LoadMosaicImageWFPC2Socket $parse(sock) $param]} { + InitError xpa + LoadMosaicImageWFPC2File $param + } + } else { + # comm + if {$parse(fn) != {}} { + LoadMosaicImageWFPC2Alloc $parse(fn) $param + } else { + LoadMosaicImageWFPC2File $param + } + } + FinishLoad +} diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index 15cd215..a24b714 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -260,6 +260,8 @@ source $ds9(root)/library/mosaicimageirafparser.tcl source $ds9(root)/library/mosaicimageiraflex.tcl source $ds9(root)/library/mosaicimagewcsparser.tcl source $ds9(root)/library/mosaicimagewcslex.tcl +source $ds9(root)/library/mosaicimagewfpc2parser.tcl +source $ds9(root)/library/mosaicimagewfpc2lex.tcl source $ds9(root)/library/multiframeparser.tcl source $ds9(root)/library/multiframelex.tcl source $ds9(root)/library/nanparser.tcl diff --git a/ds9/parsers/mosaicimagewfpc2lex.fcl b/ds9/parsers/mosaicimagewfpc2lex.fcl new file mode 100644 index 0000000..8464c5e --- /dev/null +++ b/ds9/parsers/mosaicimagewfpc2lex.fcl @@ -0,0 +1,14 @@ +#tab mosaicimagewfpc2parser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +new {return $NEW_} + +#include string.fin + +%% diff --git a/ds9/parsers/mosaicimagewfpc2parser.tac b/ds9/parsers/mosaicimagewfpc2parser.tac new file mode 100644 index 0000000..1f3aaa8 --- /dev/null +++ b/ds9/parsers/mosaicimagewfpc2parser.tac @@ -0,0 +1,32 @@ +%{ +%} + +#include string.tin + +%start command + +%token NEW_ + +%% + +command : mosaicimagewfpc2 + | mosaicimagewfpc2 {yyclearin; YYACCEPT} STRING_ + ; + +mosaicimagewfpc2 : opts {MosaicImageWFPC2CmdLoad {}} + | opts STRING_ {MosaicImageWFPC2CmdLoad $2} + ; + +opts : + | NEW_ {CreateFrame} + ; + +%% + +proc mosaicimagewfpc2::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} -- cgit v0.12