From d233cb16ebbd17b7b0279a369554531709e1e9e5 Mon Sep 17 00:00:00 2001 From: William Joye Date: Mon, 11 Jun 2018 12:45:42 -0400 Subject: add ds9 prefs send parser --- ds9/library/source.tcl | 2 ++ ds9/library/util.tcl | 24 ++++++++++++++---------- ds9/library/wcs.tcl | 12 ------------ ds9/parsers/prefssendlex.fcl | 18 ++++++++++++++++++ ds9/parsers/prefssendparser.tac | 29 +++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 22 deletions(-) create mode 100644 ds9/parsers/prefssendlex.fcl create mode 100644 ds9/parsers/prefssendparser.tac diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index e5d3a8a..b5abccc 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -334,6 +334,8 @@ 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/prefssendparser.tcl +source $ds9(root)/library/prefssendlex.tcl source $ds9(root)/library/preserveparser.tcl source $ds9(root)/library/preservelex.tcl source $ds9(root)/library/psparser.tcl diff --git a/ds9/library/util.tcl b/ds9/library/util.tcl index ebbd522..1724235 100644 --- a/ds9/library/util.tcl +++ b/ds9/library/util.tcl @@ -318,6 +318,14 @@ proc ProcessSendCmdGet3 {varname key key2 key3} { $parse(proc) $parse(id) "$var($key) $var($key2) $var($key3)\n" } +proc ProcessSendCmdGet6 {varname key key2 key3 key4 key5 key6} { + upvar #0 $varname var + global $varname + + global parse + $parse(proc) $parse(id) "$var($key) $var($key2) $var($key3) $var($key4) $var($key5) $var($key6)\n" +} + proc ProcessSendCmdYesNo {varname key} { upvar #0 $varname var global $varname @@ -1343,17 +1351,13 @@ proc ProcessPrefsCmd {varname iname} { } proc ProcessSendPrefsCmd {proc id param {sock {}} {fn {}}} { - global pds9 - global ds9 + global parse + set parse(proc) $proc + set parse(id) $id - # backward compatibility - switch -- [string tolower [lindex $param 0]] { - precision {$proc $id "$pds9(prec,linear) $pds9(prec,deg) $pds9(prec,hms) $pds9(prec,dms) $pds9(prec,arcmin) $pds9(prec,arcsec)\n"} - bgcolor {$proc $id "$pds9(bg)\n"} - nancolor {$proc $id "$pds9(nan)\n"} - threads {$proc $id "$ds9(threads)\n"} - irafalign {$proc $id [ToYesNo $pds9(iraf)]} - } + prefssend::YY_FLUSH_BUFFER + prefssend::yy_scan_string $param + prefssend::yyparse } proc ProcessPrecisionCmd {varname iname} { diff --git a/ds9/library/wcs.tcl b/ds9/library/wcs.tcl index 1162369..d0e1f5c 100644 --- a/ds9/library/wcs.tcl +++ b/ds9/library/wcs.tcl @@ -1194,18 +1194,6 @@ proc ProcessSendWCSCmd {proc id param {sock {}} {fn {}}} { wcssend::YY_FLUSH_BUFFER wcssend::yy_scan_string $param wcssend::yyparse - return - - global current - global wcs - switch -- [string tolower $param] { - align {$proc $id [ToYesNo $current(align)]} - system {$proc $id "$wcs(system)\n"} - sky {$proc $id "$wcs(sky)\n"} - format - - skyformat {$proc $id "$wcs(skyformat)\n"} - default {$proc $id "$wcs(system)\n"} - } } # backward compatibilty diff --git a/ds9/parsers/prefssendlex.fcl b/ds9/parsers/prefssendlex.fcl new file mode 100644 index 0000000..aa1554a --- /dev/null +++ b/ds9/parsers/prefssendlex.fcl @@ -0,0 +1,18 @@ +#tab prefssendparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +bgcolor {return $BGCOLOR_} +irafalign {return $IRAFALIGN_} +nancolor {return $NANCOLOR_} +precision {return $PRECISION_} +threads {return $THREADS_} + +#include ws.fin + +%% diff --git a/ds9/parsers/prefssendparser.tac b/ds9/parsers/prefssendparser.tac new file mode 100644 index 0000000..5c5c761 --- /dev/null +++ b/ds9/parsers/prefssendparser.tac @@ -0,0 +1,29 @@ +%{ +%} + +%start prefssend + +%token BGCOLOR_ +%token IRAFALIGN_ +%token NANCOLOR_ +%token PRECISION_ +%token THREADS_ + +%% + +prefssend : PRECISION_ {ProcessSendCmdGet6 pds9 prec,linear prec,deg prec,hms prec,dms prec,arcmin prec,arcsec} + | BGCOLOR_ {ProcessSendCmdGet pds9 bg} + | NANCOLOR_ {ProcessSendCmdGet pds9 nan} + | THREADS_ {ProcessSendCmdGet ds9 threads} + | IRAFALIGN_ {ProcessSendCmdYesNo pds9 iraf} + ; + +%% + +proc prefssend::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} -- cgit v0.12