summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-04-05 19:03:51 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-04-05 19:03:51 (GMT)
commit696e25ed993de4a631f5593cd66db659392dd98d (patch)
tree427ac077c045a3872a619489304b2b67d482b088
parent91183bb25977d84b6ed93e1a83335aef1e6fca54 (diff)
downloadblt-696e25ed993de4a631f5593cd66db659392dd98d.zip
blt-696e25ed993de4a631f5593cd66db659392dd98d.tar.gz
blt-696e25ed993de4a631f5593cd66db659392dd98d.tar.bz2
add ds9 scale parser
-rw-r--r--ds9/library/scale.tcl10
-rw-r--r--ds9/library/source.tcl2
-rw-r--r--ds9/parsers/scalelex.fcl39
-rw-r--r--ds9/parsers/scaleparser.tac100
4 files changed, 150 insertions, 1 deletions
diff --git a/ds9/library/scale.tcl b/ds9/library/scale.tcl
index 1fff336..14d9691 100644
--- a/ds9/library/scale.tcl
+++ b/ds9/library/scale.tcl
@@ -827,8 +827,15 @@ proc ProcessScaleCmd {varname iname} {
upvar $varname var
upvar $iname i
- global scale
+ global debug
+ if {$debug(tcl,parser)} {
+ scale::YY_FLUSH_BUFFER
+ scale::yy_scan_string [lrange $var $i end]
+ scale::yyparse
+ incr i [expr $scale::yycnt-1]
+ } else {
+ global scale
switch -- [string tolower [lindex $var $i]] {
match {
incr i
@@ -932,6 +939,7 @@ proc ProcessScaleCmd {varname iname} {
}
}
}
+}
proc ScaleCmdSet {which value {cmd {}}} {
global scale
diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl
index e3e1ca0..00c90cc 100644
--- a/ds9/library/source.tcl
+++ b/ds9/library/source.tcl
@@ -220,6 +220,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/scaleparser.tcl
+source $ds9(root)/library/scalelex.tcl
source $ds9(root)/library/skyviewparser.tcl
source $ds9(root)/library/skyviewlex.tcl
source $ds9(root)/library/threedparser.tcl
diff --git a/ds9/parsers/scalelex.fcl b/ds9/parsers/scalelex.fcl
new file mode 100644
index 0000000..3bf9827
--- /dev/null
+++ b/ds9/parsers/scalelex.fcl
@@ -0,0 +1,39 @@
+#tab scaleparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+asinh {return $ASINH_}
+close {return $CLOSE_}
+datasec {return $DATASEC_}
+exp {return $EXP_}
+global {return $GLOBAL_}
+histequ {return $HISTEQU_}
+limits {return $LIMITS_}
+linear {return $LINEAR_}
+local {return $LOCAL_}
+lock {return $LOCK_}
+log {return $LOG_}
+match {return $MATCH_}
+minmax {return $MINMAX_}
+mode {return $MODE_}
+open {return $OPEN_}
+pow {return $POW_}
+scalelimits {return $SCALELIMITS_}
+scope {return $SCOPE_}
+sinh {return $SINH_}
+sqrt {return $SQRT_}
+squared {return $SQUARED_}
+user {return $USER_}
+zmax {return $ZMAX_}
+zscale {return $ZSCALE_}
+
+#include yesno.fin
+#include numeric.fin
+#include string.fin
+
+%%
diff --git a/ds9/parsers/scaleparser.tac b/ds9/parsers/scaleparser.tac
new file mode 100644
index 0000000..61ffc87
--- /dev/null
+++ b/ds9/parsers/scaleparser.tac
@@ -0,0 +1,100 @@
+%{
+%}
+
+#include yesno.tin
+#include numeric.tin
+#include string.tin
+
+%start command
+
+%token ASINH_
+%token CLOSE_
+%token DATASEC_
+%token EXP_
+%token GLOBAL_
+%token HISTEQU_
+%token LIMITS_
+%token LINEAR_
+%token LOCAL_
+%token LOCK_
+%token LOG_
+%token MATCH_
+%token MINMAX_
+%token MODE_
+%token OPEN_
+%token POW_
+%token SCALELIMITS_
+%token SCOPE_
+%token SINH_
+%token SQRT_
+%token SQUARED_
+%token USER_
+%token ZMAX_
+%token ZSCALE_
+
+%%
+
+#include yesno.trl
+#include numeric.trl
+
+command : scale
+ | scale {yyclearin; YYACCEPT} STRING_
+ ;
+
+scale : OPEN_ {ScaleDialog}
+ | CLOSE_ {ScaleDestroyDialog}
+ | MATCH_ match
+ | LOCK_ lock
+ | scales {ScaleCmdSet type $1 ChangeScale}
+ | LOG_ log
+ | DATASEC_ yesno {ScaleCmdSet datasec $2 ChangeDATASEC}
+ | LIMITS_ numeric numeric {ScaleCmdSet min $2 {}; ScaleCmdSet max $3 ChangeScaleLimit}
+ | SCALELIMITS_ numeric numeric {ScaleCmdSet min $2 {}; ScaleCmdSet max $3 ChangeScaleLimit}
+ | mode {ScaleCmdSet mode $1 ChangeScaleMode}
+ | MODE_ mode {ScaleCmdSet mode $2 ChangeScaleMode}
+ | scope {ScaleCmdSet scope $1 ChangeScaleScope}
+ | SCOPE_ scope {ScaleCmdSet scope $2 ChangeScaleScope}
+ ;
+
+scales : LINEAR_ {set _ linear}
+ | POW_ {set _ pow}
+ | SQRT_ {set _ sqrt}
+ | SQUARED_ {set _ squared}
+ | ASINH_ {set _ asinh}
+ | HISTEQU_ {set _ histequ}
+ ;
+
+match : {MatchScaleCurrent}
+ | LIMITS_ {MatchScaleLimitsCurrent}
+ | SCALELIMITS_ {MatchScaleLimitsCurrent}
+ ;
+
+lock : yesno {ScaleCmdSet lock $1 LockScaleCurrent}
+ | LIMITS_ yesno {ScaleCmdSet lock,limits $2 LockScaleLimitsCurrent}
+ | SCALELIMITS_ yesno {ScaleCmdSet lock,limits $2 LockScaleLimitsCurrent}
+ ;
+
+log : {ScaleCmdSet type log ChangeScale}
+ | EXP_ numeric {ScaleCmdSet log $2 ChangeScale}
+ ;
+
+mode : numeric {set _ $1}
+ | MINMAX_ {set _ minmax}
+ | ZSCALE_ {set _ zscale}
+ | ZMAX_ {set _ zmax}
+ | USER_ {set _ user}
+ ;
+
+scope : LOCAL_ {set _ local}
+ | GLOBAL_ {set _ global}
+ ;
+
+%%
+
+proc scale::yyerror {msg} {
+ variable yycnt
+ variable yy_current_buffer
+ variable index_
+
+ ParserError $msg $yycnt $yy_current_buffer $index_
+}