From 583f23d32829ac3d0c605747f3c08b686ed49c66 Mon Sep 17 00:00:00 2001 From: William Joye Date: Thu, 10 May 2018 12:38:20 -0400 Subject: add ds9 rgbcube parser --- ds9/library/rgbcube.tcl | 33 +++++++++++++++++++++++++++++++++ ds9/library/source.tcl | 2 ++ ds9/parsers/rgbcubelex.fcl | 14 ++++++++++++++ ds9/parsers/rgbcubeparser.tac | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 ds9/parsers/rgbcubelex.fcl create mode 100644 ds9/parsers/rgbcubeparser.tac diff --git a/ds9/library/rgbcube.tcl b/ds9/library/rgbcube.tcl index dfd2e2f..76424ce 100644 --- a/ds9/library/rgbcube.tcl +++ b/ds9/library/rgbcube.tcl @@ -111,6 +111,18 @@ proc ProcessRGBCubeCmd {varname iname sock fn} { upvar $varname var upvar $iname i + global debug + if {$debug(tcl,parser)} { + global rgbcube + set rgbcube(load,sock) $sock + set rgbcube(load,fn) $fn + + rgbcube::YY_FLUSH_BUFFER + rgbcube::yy_scan_string [lrange $var $i end] + rgbcube::yyparse + incr i [expr $rgbcube::yycnt-1] + } else { + switch -- [string tolower [lindex $var $i]] { new { incr i @@ -143,6 +155,27 @@ proc ProcessRGBCubeCmd {varname iname sock fn} { } FinishLoad } +} + +proc RGBCubeCmdLoad {param} { + global rgbcube + + if {$rgbcube(load,sock) != {}} { + # xpa + if {![LoadRGBCubeSocket $rgbcube(load,sock) $param]} { + InitError xpa + LoadRGBCubeFile $param + } + } else { + # comm + if {$rgbcube(load,fn) != {}} { + LoadRGBCubeAlloc $rgbcube(load,fn) $param + } else { + LoadRGBCubeFile $param + } + } + FinishLoad +} proc ProcessSendRGBCubeCmd {proc id param sock fn} { global current diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index 237f0f2..090df28 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -288,6 +288,8 @@ source $ds9(root)/library/regionparser.tcl source $ds9(root)/library/regionlex.tcl source $ds9(root)/library/rgbparser.tcl source $ds9(root)/library/rgblex.tcl +source $ds9(root)/library/rgbcubeparser.tcl +source $ds9(root)/library/rgbcubelex.tcl source $ds9(root)/library/sampparser.tcl source $ds9(root)/library/samplex.tcl source $ds9(root)/library/saveparser.tcl diff --git a/ds9/parsers/rgbcubelex.fcl b/ds9/parsers/rgbcubelex.fcl new file mode 100644 index 0000000..bf43fb5 --- /dev/null +++ b/ds9/parsers/rgbcubelex.fcl @@ -0,0 +1,14 @@ +#tab rgbcubeparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +new {return $NEW_} + +#include string.fin + +%% diff --git a/ds9/parsers/rgbcubeparser.tac b/ds9/parsers/rgbcubeparser.tac new file mode 100644 index 0000000..61142c5 --- /dev/null +++ b/ds9/parsers/rgbcubeparser.tac @@ -0,0 +1,32 @@ +%{ +%} + +#include string.tin + +%start command + +%token NEW_ + +%% + +command : rgbcube + | rgbcube {yyclearin; YYACCEPT} STRING_ + ; + +rgbcube : opts {RGBCubeCmdLoad {}} + | opts STRING_ {RGBCubeCmdLoad $2} + ; + +opts : + | NEW_ {CreateRGBFrame} + ; + +%% + +proc rgbcube::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} -- cgit v0.12