From 5f2e59a9516c29a4c92eadbdbdf73398f73f5214 Mon Sep 17 00:00:00 2001 From: William Joye Date: Mon, 14 May 2018 13:38:22 -0400 Subject: add ds9 preserve parser --- ds9/library/load.tcl | 9 +++++++++ ds9/library/source.tcl | 6 ++++-- ds9/parsers/preservelex.fcl | 17 +++++++++++++++++ ds9/parsers/preserveparser.tac | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 ds9/parsers/preservelex.fcl create mode 100644 ds9/parsers/preserveparser.tac diff --git a/ds9/library/load.tcl b/ds9/library/load.tcl index 1a7cd37..221a1f6 100644 --- a/ds9/library/load.tcl +++ b/ds9/library/load.tcl @@ -434,6 +434,14 @@ proc ProcessPreserveCmd {varname iname} { upvar $varname var upvar $iname i + global debug + if {$debug(tcl,parser)} { + preserve::YY_FLUSH_BUFFER + preserve::yy_scan_string [lrange $var $i end] + preserve::yyparse + incr i [expr $preserve::yycnt-1] + } else { + global ds9 global scale global panzoom @@ -453,6 +461,7 @@ proc ProcessPreserveCmd {varname iname} { } } } +} proc ProcessSendPreserveCmd {proc id param} { global scale diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index 13f0c09..e24dbad 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -292,10 +292,12 @@ source $ds9(root)/library/pixeltableparser.tcl source $ds9(root)/library/pixeltablelex.tcl source $ds9(root)/library/plotparser.tcl source $ds9(root)/library/plotlex.tcl -source $ds9(root)/library/prefsparser.tcl -source $ds9(root)/library/prefslex.tcl source $ds9(root)/library/precisionparser.tcl source $ds9(root)/library/precisionlex.tcl +source $ds9(root)/library/prefsparser.tcl +source $ds9(root)/library/prefslex.tcl +source $ds9(root)/library/preserveparser.tcl +source $ds9(root)/library/preservelex.tcl source $ds9(root)/library/psparser.tcl source $ds9(root)/library/pslex.tcl source $ds9(root)/library/regionparser.tcl diff --git a/ds9/parsers/preservelex.fcl b/ds9/parsers/preservelex.fcl new file mode 100644 index 0000000..ef0834b --- /dev/null +++ b/ds9/parsers/preservelex.fcl @@ -0,0 +1,17 @@ +#tab preserveparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +pan {return $PAN_} +regions {return $REGIONS_} + +#include yesno.fin +#include numeric.fin +#include string.fin + +%% diff --git a/ds9/parsers/preserveparser.tac b/ds9/parsers/preserveparser.tac new file mode 100644 index 0000000..0c33299 --- /dev/null +++ b/ds9/parsers/preserveparser.tac @@ -0,0 +1,34 @@ +%{ +%} + +#include yesno.tin +#include numeric.tin +#include string.tin + +%start command + +%token PAN_ +%token REGIONS_ + +%% + +#include yesno.trl +#include numeric.trl + +command : preserve + | preserve {yyclearin; YYACCEPT} STRING_ + ; + +preserve : PAN_ yesno {PanZoomCmdSet preserve $2 PreservePan} + | REGIONS_ yesno {MarkerCmdSet preserve $2 MarkerPreserve} + ; + +%% + +proc preserve::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} -- cgit v0.12