From 75d81565076d3bab3e92a10c8e04fd949faaea90 Mon Sep 17 00:00:00 2001 From: William Joye Date: Thu, 7 Jun 2018 15:10:36 -0400 Subject: add ds9 cube send parser --- ds9/library/cube.tcl | 33 ++++++++++++--------------------- ds9/library/source.tcl | 2 ++ ds9/parsers/cubesendlex.fcl | 18 ++++++++++++++++++ ds9/parsers/cubesendparser.tac | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 21 deletions(-) create mode 100644 ds9/parsers/cubesendlex.fcl create mode 100644 ds9/parsers/cubesendparser.tac diff --git a/ds9/library/cube.tcl b/ds9/library/cube.tcl index de4beca..d94955c 100644 --- a/ds9/library/cube.tcl +++ b/ds9/library/cube.tcl @@ -727,27 +727,18 @@ proc CubeCmdCoord {ss sys axis} { } proc ProcessSendCubeCmd {proc id param {sock {}} {fn {}}} { - global cube - global current + global parse + set parse(proc) $proc + set parse(id) $id + + cubesend::YY_FLUSH_BUFFER + cubesend::yy_scan_string $param + cubesend::yyparse +} + +proc CubeSendCmdInterval {} { + global parse global blink - switch -- [string tolower [lindex $param 0]] { - lock {$proc $id "$cube(lock)\n"} - axes - - order { - switch -- [string tolower [lindex $param 1]] { - lock {$proc $id [ToYesNo $cube(lock,axes)]} - default {$proc $id "$cube(axes)\n"} - } - } - interval {$proc $id "[expr $blink(interval)/1000.]\n"} - axis {$proc $id "$cube(axis)\n"} - default { - if {$current(frame) != {}} { - $proc $id "[$current(frame) get fits slice $cube(axis)]\n" - } else { - $proc $id "1\n" - } - } - } + $parse(proc) $parse(id) "[expr $blink(interval)/1000.]\n" } diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index e82eaa8..9b0137e 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -234,6 +234,8 @@ source $ds9(root)/library/crosshairsendparser.tcl source $ds9(root)/library/crosshairsendlex.tcl source $ds9(root)/library/cubeparser.tcl source $ds9(root)/library/cubelex.tcl +source $ds9(root)/library/cubesendparser.tcl +source $ds9(root)/library/cubesendlex.tcl source $ds9(root)/library/cursorparser.tcl source $ds9(root)/library/cursorlex.tcl source $ds9(root)/library/dssesoparser.tcl diff --git a/ds9/parsers/cubesendlex.fcl b/ds9/parsers/cubesendlex.fcl new file mode 100644 index 0000000..5a51bdd --- /dev/null +++ b/ds9/parsers/cubesendlex.fcl @@ -0,0 +1,18 @@ +#tab cubesendparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +axis {return $AXIS_} +axes {return $AXES_} +interval {return $INTERVAL_} +lock {return $LOCK_} +order {return $ORDER_} + +#include string.fin + +%% diff --git a/ds9/parsers/cubesendparser.tac b/ds9/parsers/cubesendparser.tac new file mode 100644 index 0000000..70cfb3e --- /dev/null +++ b/ds9/parsers/cubesendparser.tac @@ -0,0 +1,36 @@ +%{ +%} + +#include string.tin + +%start cubesend + +%token AXIS_ +%token AXES_ +%token INTERVAL_ +%token LOCK_ +%token ORDER_ + +%% + +cubesend : {global cube; ProcessSendCmdCurrent frame "get fits slice $cube(axis)"} + | LOCK_ {ProcessSendCmdGet cube lock} + | INTERVAL_ {CubeSendCmdInterval} + | AXIS_ {ProcessSendCmdGet cube axis} + | AXES_ order + | ORDER_ order + ; + +order : {ProcessSendCmdGet cube axes} + | LOCK_ {ProcessSendCmdYesNo cube lock,axes} + ; + +%% + +proc cubesend::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} -- cgit v0.12