From 15bd8441b3977ccd664fdbc4a8d07e8931be480a Mon Sep 17 00:00:00 2001 From: William Joye Date: Fri, 1 Jun 2018 14:15:41 -0400 Subject: update ds9 send parsers --- ds9/library/crop.tcl | 74 ++++------------------------------------- ds9/library/source.tcl | 2 ++ ds9/parsers/binsendparser.tac | 2 ++ ds9/parsers/blocksendparser.tac | 2 ++ ds9/parsers/cropsendlex.fcl | 17 ++++++++++ ds9/parsers/cropsendparser.tac | 53 +++++++++++++++++++++++++++++ ds9/parsers/gridsendparser.tac | 2 ++ 7 files changed, 84 insertions(+), 68 deletions(-) create mode 100644 ds9/parsers/cropsendlex.fcl create mode 100644 ds9/parsers/cropsendparser.tac diff --git a/ds9/library/crop.tcl b/ds9/library/crop.tcl index b505b18..3082a4a 100644 --- a/ds9/library/crop.tcl +++ b/ds9/library/crop.tcl @@ -400,73 +400,11 @@ proc ProcessCropCmd {varname iname} { } proc ProcessSendCropCmd {proc id param {sock {}} {fn {}}} { - global crop - global current - switch -- [string tolower [lindex $param 0]] { - lock {$proc $id "$crop(lock)\n"} - 3d { - set sys [lindex $param 1] - FixSpecSystem sys physical - - if {$current(frame) != {}} { - $proc $id "[$current(frame) get crop 3d $sys]\n" - } - } - default { - set sys [lindex $param 0] - set sky [lindex $param 1] - set format [lindex $param 2] - set dformat [lindex $param 3] - FixSpec sys sky format physical fk5 degrees - - if {$current(frame) != {}} { - $proc $id "[$current(frame) get crop center $sys $sky $format $sys $dformat]\n" - } - } - } -} - -proc FixSpecSystem {sysname defsys} { - upvar $sysname sys - - set rr 0 - - switch -- $sys { - image - - physical - - detector - - amplifier - - wcs - - wcsa - - wcsb - - wcsc - - wcsd - - wcse - - wcsf - - wcsg - - wcsh - - wcsi - - wcsj - - wcsk - - wcsl - - wcsm - - wcsn - - wcso - - wcsp - - wcsq - - wcsr - - wcss - - wcst - - wcsu - - wcsv - - wcsw - - wcsx - - wcsy - - wcsz {incr rr} - default { - set sys $defsys - } - } + global parse + set parse(proc) $proc + set parse(id) $id - return $rr + cropsend::YY_FLUSH_BUFFER + cropsend::yy_scan_string $param + cropsend::yyparse } diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index 581b9a7..60862b5 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -218,6 +218,8 @@ source $ds9(root)/library/contourparser.tcl source $ds9(root)/library/contourlex.tcl source $ds9(root)/library/cropparser.tcl source $ds9(root)/library/croplex.tcl +source $ds9(root)/library/cropsendparser.tcl +source $ds9(root)/library/cropsendlex.tcl source $ds9(root)/library/crosshairparser.tcl source $ds9(root)/library/crosshairlex.tcl source $ds9(root)/library/cubeparser.tcl diff --git a/ds9/parsers/binsendparser.tac b/ds9/parsers/binsendparser.tac index 859551d..7c6266f 100644 --- a/ds9/parsers/binsendparser.tac +++ b/ds9/parsers/binsendparser.tac @@ -12,6 +12,8 @@ %token FUNCTION_ %token LOCK_ +%start binsend + %% binsend : LOCK_ {ProcessSendCmdYesNo bin lock} diff --git a/ds9/parsers/blocksendparser.tac b/ds9/parsers/blocksendparser.tac index 551f7ca..786928d 100644 --- a/ds9/parsers/blocksendparser.tac +++ b/ds9/parsers/blocksendparser.tac @@ -3,6 +3,8 @@ #include string.tin +%start blocksend + %token LOCK_ %% diff --git a/ds9/parsers/cropsendlex.fcl b/ds9/parsers/cropsendlex.fcl new file mode 100644 index 0000000..10ec937 --- /dev/null +++ b/ds9/parsers/cropsendlex.fcl @@ -0,0 +1,17 @@ +#tab cropsendparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +3d {return $3D_} + +#include matchlock.fin +#include coords.fin +#include string.fin + +%% + diff --git a/ds9/parsers/cropsendparser.tac b/ds9/parsers/cropsendparser.tac new file mode 100644 index 0000000..b6100cb --- /dev/null +++ b/ds9/parsers/cropsendparser.tac @@ -0,0 +1,53 @@ +%{ +%} + +#include matchlock.tin +#include coords.tin +#include string.tin + +%start cropsend + +%token 3D_ + +%% + +#include matchlock.trl +#include coords.trl + +cropsend : {ProcessSendCmdCurrent "get crop center physical fk5 degrees physical degrees"} + | coordsys {ProcessSendCmdCurrent "get crop center $1 fk5 degrees $1 degrees"} + + | wcssys {ProcessSendCmdCurrent "get crop center $1 fk5 degrees $1 degrees"} + | skyframe {ProcessSendCmdCurrent "get crop center wcs $1 degrees wcs degrees"} + + | wcssys skyformat + {ProcessSendCmdCurrent "get crop center $1 fk5 $2 $1 degrees"} + | skyframe skyformat + {ProcessSendCmdCurrent "get crop center wcs $1 $2 wcs degrees"} + + | wcssys skyformat rformat + {ProcessSendCmdCurrent "get crop center $1 fk5 $2 $1 $3"} + | skyframe skyformat rformat + {ProcessSendCmdCurrent "get crop center wcs $1 $2 wcs $3"} + + | wcssys skyframe skyformat rformat + {ProcessSendCmdCurrent "get crop center $1 $2 $3 $1 $4"} + + | 3D_ 3d + | LOCK_ {ProcessSendCmdGet crop lock} + ; + +3d : {ProcessSendCmdCurrent "get crop 3d image"} + | coordsys {ProcessSendCmdCurrent "get crop 3d $1"} + | wcssys {ProcessSendCmdCurrent "get crop 3d $1"} + ; + +%% + +proc cropsend::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} diff --git a/ds9/parsers/gridsendparser.tac b/ds9/parsers/gridsendparser.tac index 769c824..c0509e9 100644 --- a/ds9/parsers/gridsendparser.tac +++ b/ds9/parsers/gridsendparser.tac @@ -4,6 +4,8 @@ #include font.tin #include string.tin +%start gridsend + %token AXES_ %token BORDER_ %token COLOR_ -- cgit v0.12