summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-04-18 20:42:14 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-04-18 20:42:14 (GMT)
commit13692448a7ff8facb5c78d9fbb2534f4fa474ac0 (patch)
tree37dd375889704525e3619a1bcb932893896a04f3
parentdfe055b55cdcd990b3bfb3d821ebf9e785a90b98 (diff)
downloadblt-13692448a7ff8facb5c78d9fbb2534f4fa474ac0.zip
blt-13692448a7ff8facb5c78d9fbb2534f4fa474ac0.tar.gz
blt-13692448a7ff8facb5c78d9fbb2534f4fa474ac0.tar.bz2
add ds9 prefs parser
-rw-r--r--ds9/library/source.tcl2
-rw-r--r--ds9/library/util.tcl20
-rw-r--r--ds9/parsers/bgparser.tac2
-rw-r--r--ds9/parsers/nanparser.tac2
-rw-r--r--ds9/parsers/prefslex.fcl21
-rw-r--r--ds9/parsers/prefsparser.tac42
6 files changed, 86 insertions, 3 deletions
diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl
index 507d29c..073618f 100644
--- a/ds9/library/source.tcl
+++ b/ds9/library/source.tcl
@@ -248,6 +248,8 @@ source $ds9(root)/library/panparser.tcl
source $ds9(root)/library/panlex.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/psparser.tcl
source $ds9(root)/library/pslex.tcl
source $ds9(root)/library/regionparser.tcl
diff --git a/ds9/library/util.tcl b/ds9/library/util.tcl
index 683047e..d0c3c0b 100644
--- a/ds9/library/util.tcl
+++ b/ds9/library/util.tcl
@@ -1175,7 +1175,16 @@ proc DS9Backup {ch which} {
# Process Cmds
-proc Pds9CmdSet {which value {cmd {}}} {
+proc ds9CmdSet {which value {cmd {}}} {
+ global ds9
+
+ set ds9($which) $value
+ if {$cmd != {}} {
+ eval $cmd
+ }
+}
+
+proc pds9CmdSet {which value {cmd {}}} {
global pds9
set pds9($which) $value
@@ -1188,6 +1197,14 @@ proc ProcessPrefsCmd {varname iname} {
upvar $varname var
upvar $iname i
+ global debug
+ if {$debug(tcl,parser)} {
+ prefs::YY_FLUSH_BUFFER
+ prefs::yy_scan_string [lrange $var $i end]
+ prefs::yyparse
+ incr i [expr $prefs::yycnt-1]
+ } else {
+
global pds9
global ds9
@@ -1233,6 +1250,7 @@ proc ProcessPrefsCmd {varname iname} {
}
}
}
+}
proc ProcessSendPrefsCmd {proc id param} {
global pds9
diff --git a/ds9/parsers/bgparser.tac b/ds9/parsers/bgparser.tac
index c85eddd..859a114 100644
--- a/ds9/parsers/bgparser.tac
+++ b/ds9/parsers/bgparser.tac
@@ -11,7 +11,7 @@ command : bg
| bg {yyclearin; YYACCEPT} STRING_
;
-bg : STRING_ {Pds9CmdSet bg $1 PrefsBgColor}
+bg : STRING_ {pds9CmdSet bg $1 PrefsBgColor}
;
%%
diff --git a/ds9/parsers/nanparser.tac b/ds9/parsers/nanparser.tac
index 4b93853..f033034 100644
--- a/ds9/parsers/nanparser.tac
+++ b/ds9/parsers/nanparser.tac
@@ -11,7 +11,7 @@ command : nan
| nan {yyclearin; YYACCEPT} STRING_
;
-nan : STRING_ {Pds9CmdSet nan $1 PrefsNanColor}
+nan : STRING_ {ds9CmdSet nan $1 PrefsNanColor}
;
%%
diff --git a/ds9/parsers/prefslex.fcl b/ds9/parsers/prefslex.fcl
new file mode 100644
index 0000000..1d8cdbb
--- /dev/null
+++ b/ds9/parsers/prefslex.fcl
@@ -0,0 +1,21 @@
+#tab prefsparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+bgcolor {return $BGCOLOR_}
+clear {return $CLEAR_}
+irafalign {return $IRAFALIGN_}
+nancolor {return $NANCOLOR_}
+precision {return $PRECISION_}
+threads {return $THREADS_}
+
+#include yesno.fin
+#include numeric.fin
+#include string.fin
+
+%%
diff --git a/ds9/parsers/prefsparser.tac b/ds9/parsers/prefsparser.tac
new file mode 100644
index 0000000..16becbb
--- /dev/null
+++ b/ds9/parsers/prefsparser.tac
@@ -0,0 +1,42 @@
+%{
+%}
+
+#include yesno.tin
+#include numeric.tin
+#include string.tin
+
+%start command
+
+%token BGCOLOR_
+%token CLEAR_
+%token IRAFALIGN_
+%token NANCOLOR_
+%token PRECISION_
+%token THREADS_
+
+%%
+
+#include yesno.trl
+#include numeric.trl
+
+command : prefs
+ | prefs {yyclearin; YYACCEPT} STRING_
+ ;
+
+prefs : CLEAR_ {ClearPrefs}
+ | PRECISION_ INT_ INT_ INT_ INT_ INT_ INT_ {pds9CmdSet prec,linear $2; pds9CmdSet prec,deg $3; pds9CmdSet prec,hms $4;pds9CmdSet prec,dms $5; pds9CmdSet prec,arcmin $6; pds9CmdSet prec,arcsec $7 PrefsPrecision}
+ | BGCOLOR_ STRING_ {pds9CmdSet bg $2 PrefsBgColor}
+ | NANCOLOR_ STRING_ {pds9CmdSet nan $2 PrefsNanColor}
+ | THREADS_ INT_ {ds9CmdSet threads $2 ChangeThreads}
+ | IRAFALIGN_ yesno {pds9CmdSet iraf $2 PrefsIRAFAlign}
+ ;
+
+%%
+
+proc prefs::yyerror {msg} {
+ variable yycnt
+ variable yy_current_buffer
+ variable index_
+
+ ParserError $msg $yycnt $yy_current_buffer $index_
+}