summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-04-13 19:07:24 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-04-13 19:07:24 (GMT)
commitc035c9899e98dd4963f4e26948c4a5159f294f56 (patch)
tree9c614ce9d8910642704d598656ef2bca68cf2372
parent9dbeaaa6ccc5cb8f3bef0bd33f26b9f7c5332cd4 (diff)
downloadblt-c035c9899e98dd4963f4e26948c4a5159f294f56.zip
blt-c035c9899e98dd4963f4e26948c4a5159f294f56.tar.gz
blt-c035c9899e98dd4963f4e26948c4a5159f294f56.tar.bz2
add ds9 lock/match parser
-rw-r--r--ds9/library/frame.tcl19
-rw-r--r--ds9/library/panzoom.tcl9
-rw-r--r--ds9/library/source.tcl4
-rw-r--r--ds9/parsers/locklex.fcl29
-rw-r--r--ds9/parsers/lockparser.tac67
-rw-r--r--ds9/parsers/matchlex.fcl28
-rw-r--r--ds9/parsers/matchparser.tac65
7 files changed, 220 insertions, 1 deletions
diff --git a/ds9/library/frame.tcl b/ds9/library/frame.tcl
index 112bde6..5322d26 100644
--- a/ds9/library/frame.tcl
+++ b/ds9/library/frame.tcl
@@ -2526,6 +2526,14 @@ proc ProcessLockCmd {varname iname} {
# we need to be realized
ProcessRealizeDS9
+ global debug
+ if {$debug(tcl,parser)} {
+ lock::YY_FLUSH_BUFFER
+ lock::yy_scan_string [lrange $var $i end]
+ lock::yyparse
+ incr i [expr $lock::yycnt-1]
+ } else {
+
switch -- [string tolower [lindex $var $i]] {
frame -
frames {
@@ -2651,6 +2659,7 @@ proc ProcessLockCmd {varname iname} {
}
}
}
+}
proc ProcessSendLockCmd {proc id param} {
global panzoom
@@ -2700,6 +2709,14 @@ proc ProcessMatchCmd {varname iname} {
# we need to be realized
ProcessRealizeDS9
+ global debug
+ if {$debug(tcl,parser)} {
+ match::YY_FLUSH_BUFFER
+ match::yy_scan_string [lrange $var $i end]
+ match::yyparse
+ incr i [expr $match::yycnt-1]
+ } else {
+
switch -- [string tolower [lindex $var $i]] {
frame -
frames {
@@ -2745,4 +2762,4 @@ proc ProcessMatchCmd {varname iname} {
3d {Match3DCurrent}
}
}
-
+}
diff --git a/ds9/library/panzoom.tcl b/ds9/library/panzoom.tcl
index 207a04a..851e003 100644
--- a/ds9/library/panzoom.tcl
+++ b/ds9/library/panzoom.tcl
@@ -677,6 +677,15 @@ proc PanZoomBackup {ch which} {
# Process Cmds
+proc PanZoomCmdSet {which value {cmd {}}} {
+ global panzoom
+
+ set panzoom($which) $value
+ if {$cmd != {}} {
+ eval $cmd
+ }
+}
+
proc ProcessPanCmd {varname iname} {
upvar $varname var
upvar $iname i
diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl
index 0256231..904c6a2 100644
--- a/ds9/library/source.tcl
+++ b/ds9/library/source.tcl
@@ -232,6 +232,10 @@ source $ds9(root)/library/gridparser.tcl
source $ds9(root)/library/gridlex.tcl
source $ds9(root)/library/headerparser.tcl
source $ds9(root)/library/headerlex.tcl
+source $ds9(root)/library/lockparser.tcl
+source $ds9(root)/library/locklex.tcl
+source $ds9(root)/library/matchparser.tcl
+source $ds9(root)/library/matchlex.tcl
source $ds9(root)/library/nanparser.tcl
source $ds9(root)/library/nanlex.tcl
source $ds9(root)/library/nvssparser.tcl
diff --git a/ds9/parsers/locklex.fcl b/ds9/parsers/locklex.fcl
new file mode 100644
index 0000000..d4ab3b7
--- /dev/null
+++ b/ds9/parsers/locklex.fcl
@@ -0,0 +1,29 @@
+#tab lockparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+3d {return $3D_}
+axes {return $AXES_}
+bin {return $BIN_}
+block {return $BLOCK_}
+colorbar {return $COLORBAR_}
+crop {return $CROP_}
+crosshair {return $CROSSHAIR_}
+frame {return $FRAME_}
+none {return $NONE_}
+scale {return $SCALE_}
+scalelimits {return $SCALELIMITS_}
+slice {return $SLICE_}
+smooth {return $SMOOTH_}
+
+#include coords.fin
+#include yesno.fin
+#include numeric.fin
+#include string.fin
+
+%%
diff --git a/ds9/parsers/lockparser.tac b/ds9/parsers/lockparser.tac
new file mode 100644
index 0000000..d6136db
--- /dev/null
+++ b/ds9/parsers/lockparser.tac
@@ -0,0 +1,67 @@
+%{
+%}
+
+#include coords.tin
+#include yesno.tin
+#include numeric.tin
+#include string.tin
+
+%start command
+
+%token 3D_
+%token AXES_
+%token BIN_
+%token BLOCK_
+%token COLORBAR_
+%token CROP_
+%token CROSSHAIR_
+%token FRAME_
+%token NONE_
+%token SCALE_
+%token SCALELIMITS_
+%token SLICE_
+%token SMOOTH_
+
+%%
+
+#include coords.trl
+#include yesno.trl
+#include numeric.trl
+
+command : lock
+ | lock {yyclearin; YYACCEPT} STRING_
+ ;
+
+lock : FRAME_ coordnone {PanZoomCmdSet lock $2 LockFrameCurrent}
+ | CROSSHAIR_ coordnone {CrosshairCmdSet lock $2 LockCrosshairCurrent}
+ | CROP_ coordnone {CropCmdSet lock $2 LockCropCurrent}
+ | SLICE_ slice {CubeCmdSet lock $2 LockCubeCurrent}
+ | BIN_ yesno {BinCmdSet lock $2 LockBinCurrent}
+ | AXES_ yesno {CubeCmdSet lock,axes $2 LockAxesCurrent}
+ | SCALE_ yesno {ScaleCmdSet lock $2 LockScaleCurrent}
+ | SCALELIMITS_ yesno {ScaleCmdSet lock,limits $2 LockScaleLimitsCurrent}
+ | COLORBAR_ yesno {ColorbarCmdSet lock $2 LockColorCurrent}
+ | BLOCK_ yesno {BlockCmdSet lock $2 LockBlockCurrent}
+ | SMOOTH_ yesno {SmoothCmdSet lock $2 LockSmoothCurrent}
+ | 3D_ yesno {ThreedCmdSet lock $2 Lock3DCurrent}
+ ;
+
+coordnone : coordsys {set _ $1}
+ | wcssys {set _ $1}
+ | NONE_ {set _ none}
+ ;
+
+slice : IMAGE_ {set _ image}
+ | wcssys {set _ $1}
+ | NONE_ {set _ none}
+ ;
+
+%%
+
+proc lock::yyerror {msg} {
+ variable yycnt
+ variable yy_current_buffer
+ variable index_
+
+ ParserError $msg $yycnt $yy_current_buffer $index_
+}
diff --git a/ds9/parsers/matchlex.fcl b/ds9/parsers/matchlex.fcl
new file mode 100644
index 0000000..7e5c5af
--- /dev/null
+++ b/ds9/parsers/matchlex.fcl
@@ -0,0 +1,28 @@
+#tab matchparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+3d {return $3D_}
+axes {return $AXES_}
+bin {return $BIN_}
+block {return $BLOCK_}
+colorbar {return $COLORBAR_}
+crop {return $CROP_}
+crosshair {return $CROSSHAIR_}
+frame {return $FRAME_}
+none {return $NONE_}
+scale {return $SCALE_}
+scalelimits {return $SCALELIMITS_}
+slice {return $SLICE_}
+smooth {return $SMOOTH_}
+
+#include coords.fin
+#include numeric.fin
+#include string.fin
+
+%%
diff --git a/ds9/parsers/matchparser.tac b/ds9/parsers/matchparser.tac
new file mode 100644
index 0000000..3d81696
--- /dev/null
+++ b/ds9/parsers/matchparser.tac
@@ -0,0 +1,65 @@
+%{
+%}
+
+#include coords.tin
+#include numeric.tin
+#include string.tin
+
+%start command
+
+%token 3D_
+%token AXES_
+%token BIN_
+%token BLOCK_
+%token COLORBAR_
+%token CROP_
+%token CROSSHAIR_
+%token FRAME_
+%token NONE_
+%token SCALE_
+%token SCALELIMITS_
+%token SLICE_
+%token SMOOTH_
+
+%%
+
+#include coords.trl
+#include numeric.trl
+
+command : match
+ | match {yyclearin; YYACCEPT} STRING_
+ ;
+
+match : FRAME_ coordnone {MatchFrameCurrent $2}
+ | CROSSHAIR_ coordnone {MatchCrosshairCurrent $2}
+ | CROP_ coordnone {MatchCropCurrent $2}
+ | SLICE_ slice {MatchCubeCurrent $2}
+ | BIN_ {MatchBinCurrent}
+ | AXES_ {MatchAxesCurrent}
+ | SCALE_ {MatchScaleCurrent}
+ | SCALELIMITS_ {MatchScaleLimitsCurrent}
+ | COLORBAR_ {MatchColorCurrent}
+ | BLOCK_ {MatchBlockCurrent}
+ | SMOOTH_ {MatchSmoothCurrent}
+ | 3D_ {Match3DCurrent}
+ ;
+
+coordnone : coordsys {set _ $1}
+ | wcssys {set _ $1}
+ | NONE_ {set _ none}
+ ;
+
+slice : IMAGE_ {set _ image}
+ | wcssys {set _ $1}
+ | NONE_ {set _ none}
+ ;
+
+%%
+
+proc match::yyerror {msg} {
+ variable yycnt
+ variable yy_current_buffer
+ variable index_
+
+ ParserError $msg $yycnt $yy_current_buffer $index_
+}