From eaf2f407ca2034a6bafc02e6a6755a63cd1f471c Mon Sep 17 00:00:00 2001 From: William Joye Date: Thu, 15 Mar 2018 14:58:22 -0400 Subject: add ds9 view parser --- ds9/library/layout.tcl | 12 +++++-- ds9/library/source.tcl | 2 ++ ds9/parsers/viewlex.fcl | 40 +++++++++++++++++++++ ds9/parsers/viewparser.tac | 89 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 ds9/parsers/viewlex.fcl create mode 100644 ds9/parsers/viewparser.tac diff --git a/ds9/library/layout.tcl b/ds9/library/layout.tcl index 4912673..7e5c30f 100644 --- a/ds9/library/layout.tcl +++ b/ds9/library/layout.tcl @@ -848,12 +848,20 @@ proc ProcessSendWidthCmd {proc id param} { proc ProcessViewCmd {varname iname} { upvar $varname var + upvar $iname ii + + view::YY_FLUSH_BUFFER + view::yy_scan_string [lrange $var $ii end] + view::yyparse + incr ii [expr $view::yycnt-1] +} + +proc oProcessViewCmd {varname iname} { + upvar $varname var upvar $iname i global view global rgb - global canvas - global icanvas set item [string tolower [lindex $var $i]] diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index a4bad05..c0b0a97 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -220,6 +220,8 @@ source $ds9(root)/library/tileparser.tcl source $ds9(root)/library/tilelex.tcl source $ds9(root)/library/twomassparser.tcl source $ds9(root)/library/twomasslex.tcl +source $ds9(root)/library/viewparser.tcl +source $ds9(root)/library/viewlex.tcl source $ds9(root)/library/vlaparser.tcl source $ds9(root)/library/vlalex.tcl source $ds9(root)/library/vlssparser.tcl diff --git a/ds9/parsers/viewlex.fcl b/ds9/parsers/viewlex.fcl new file mode 100644 index 0000000..1fe719c --- /dev/null +++ b/ds9/parsers/viewlex.fcl @@ -0,0 +1,40 @@ +#tab viewparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +blue {return $BLUE_} +buttons {return $BUTTONS_} +colorbar {return $COLORBAR_} +colorbarnumerics {return $COLORBARNUMERICS_} +filename {return $FILENAME_} +frame {return $FRAME_} +graph {return $GRAPH_} +green {return $GREEN_} +horz {return $HORIZONTAL_} +horizontal {return $HORIZONTAL_} +horzgraph {return $HORZGRAPH_} +info {return $INFO_} +keyvalue {return $KEYVALUE_} +keyword {return $KEYWORD_} +layout {return $LAYOUT_} +lowhigh {return $LOWHIGH_} +magnifier {return $MAGNIFIER_} +minmax {return $MINMAX_} +object {return $OBJECT_} +panner {return $PANNER_} +red {return $RED_} +units {return $UNITS_} +vert {return $VERTICAL_} +vertical {return $VERTICAL_} +vertgraph {return $VERTGRAPH_} + +#include yesno.fin +#include coords.fin +#include string.fin + +%% diff --git a/ds9/parsers/viewparser.tac b/ds9/parsers/viewparser.tac new file mode 100644 index 0000000..7684be8 --- /dev/null +++ b/ds9/parsers/viewparser.tac @@ -0,0 +1,89 @@ +%{ +%} + +#include yesno.tin +#include coords.tin +#include string.tin + +%start command + +%token BLUE_ +%token BUTTONS_ +%token COLORBAR_ +%token COLORBARNUMERICS_ +%token FILENAME_ +%token FRAME_ +%token GRAPH_ +%token GREEN_ +%token HORIZONTAL_ +%token HORZGRAPH_ +%token INFO_ +%token KEYVALUE_ +%token KEYWORD_ +%token LAYOUT_ +%token LOWHIGH_ +%token MAGNIFIER_ +%token MINMAX_ +%token OBJECT_ +%token PANNER_ +%token RED_ +%token UNITS_ +%token VERTICAL_ +%token VERTGRAPH_ + +%% + +#include yesno.trl +#include coords.trl + +command : view + | view {yyclearin; YYACCEPT} STRING_ + ; + + +view : layout + | LAYOUT_ layout + | INFO_ yesno {global view; set view(info) $2; UpdateView} + | PANNER_ yesno {global view; set view(panner) $2; UpdateView} + | MAGNIFIER_ yesno {global view; set view(magnifier) $2; UpdateView} + | BUTTONS_ yesno {global view; set view(buttons) $2; UpdateView} + | COLORBAR_ yesno {global view; set view(colorbar) $2; UpdateView} + # backward compatible + | COLORBARNUMERICS_ yesno {global colorbar; set colorbar(numerics) $2; UpdateView} + | GRAPH_ graph + # backward compatible + | HORZGRAPH_ yesno {global view; set view(graph,horz) $2; UpdateView} + # backward compatible + | VERTGRAPH_ yesno {global view; set view(graph,vert) $2; UpdateView} + | FILENAME_ yesno {global view; set view(info,filename) $2; UpdateView} + | OBJECT_ yesno {global view; set view(info,object) $2; UpdateView} + | KEYWORD_ yesno {global view; set view(info,keyword) $2; UpdateView} + | KEYVALUE_ STRING_ {global view; set view(info,keyvalue) $2; UpdateView} + | MINMAX_ yesno {global view; set view(info,minmax) $2; UpdateView} + | LOWHIGH_ yesno {global view; set view(info,lowhigh) $2; UpdateView} + | UNITS_ yesno {global view; set view(info,units) $2; UpdateView} + | coordsys yesno {global view; set view(info,$1) $2; UpdateView} + | wcssys yesno {global view; set view(info,$1) $2; UpdateView} + | FRAME_ yesno {global view; set view(info,frame) $2; UpdateView} + | RED_ yesno {global rgb; set rgb(red) $2; RGBView} + | GREEN_ yesno {global rgb; set rgb(green) $2; RGBView} + | BLUE_ yesno {global rgb; set rgb(blue) $2; RGBView} + ; + +layout : HORIZONTAL_ {global view; set view(layout) horizontal; ViewHorzCmd} + | VERTICAL_ {global view; set view(layout) vertical; ViewVertCmd} + ; + +graph : HORIZONTAL_ yesno {global view; set view(graph,horz) $2; UpdateView} + | VERTICAL_ yesno {global view; set view(graph,vert) $2; UpdateView} + ; + +%% + +proc view::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} -- cgit v0.12