summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-05-08 20:25:26 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-05-08 20:25:26 (GMT)
commitc052962410047d3b2a444b693f7c3bd678b539ed (patch)
tree8edda856a0647ea68b07ce9cdd1f18760c7a9634
parent58f6608644d76112394217f1ab6d419a140a1a73 (diff)
downloadblt-c052962410047d3b2a444b693f7c3bd678b539ed.zip
blt-c052962410047d3b2a444b693f7c3bd678b539ed.tar.gz
blt-c052962410047d3b2a444b693f7c3bd678b539ed.tar.bz2
add ds9 mode parser
-rw-r--r--ds9/library/source.tcl2
-rw-r--r--ds9/library/util.tcl10
-rw-r--r--ds9/parsers/modelex.fcl23
-rw-r--r--ds9/parsers/modeparser.tac49
4 files changed, 83 insertions, 1 deletions
diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl
index 0354058..304f996 100644
--- a/ds9/library/source.tcl
+++ b/ds9/library/source.tcl
@@ -250,6 +250,8 @@ source $ds9(root)/library/matchparser.tcl
source $ds9(root)/library/matchlex.tcl
source $ds9(root)/library/minmaxparser.tcl
source $ds9(root)/library/minmaxlex.tcl
+source $ds9(root)/library/modeparser.tcl
+source $ds9(root)/library/modelex.tcl
source $ds9(root)/library/nanparser.tcl
source $ds9(root)/library/nanlex.tcl
source $ds9(root)/library/nvssparser.tcl
diff --git a/ds9/library/util.tcl b/ds9/library/util.tcl
index c6273e6..6c6c709 100644
--- a/ds9/library/util.tcl
+++ b/ds9/library/util.tcl
@@ -1582,8 +1582,15 @@ proc ProcessModeCmd {varname iname} {
upvar $varname var
upvar $iname i
- global current
+ global debug
+ if {$debug(tcl,parser)} {
+ mode::YY_FLUSH_BUFFER
+ mode::yy_scan_string [lrange $var $i end]
+ mode::yyparse
+ incr i [expr $mode::yycnt-1]
+ } else {
+ global current
set current(mode) [string tolower [lindex $var $i]]
# backward compatibility
switch $current(mode) {
@@ -1591,6 +1598,7 @@ proc ProcessModeCmd {varname iname} {
}
ChangeMode
}
+}
proc ProcessQuitCmd {varname iname} {
upvar $varname var
diff --git a/ds9/parsers/modelex.fcl b/ds9/parsers/modelex.fcl
new file mode 100644
index 0000000..6be1a90
--- /dev/null
+++ b/ds9/parsers/modelex.fcl
@@ -0,0 +1,23 @@
+#tab modeparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+none {return $NONE_}
+region {return $REGION_}
+crosshair {return $CROSSHAIR_}
+colorbar {return $COLORBAR_}
+pan {return $PAN_}
+zoom {return $ZOOM_}
+rotate {return $ROTATE_}
+catalog {return $CATALOG_}
+examine {return $EXAMINE_}
+pointer {return $POINTER_}
+
+#include string.fin
+
+%%
diff --git a/ds9/parsers/modeparser.tac b/ds9/parsers/modeparser.tac
new file mode 100644
index 0000000..862ea8c
--- /dev/null
+++ b/ds9/parsers/modeparser.tac
@@ -0,0 +1,49 @@
+%{
+%}
+
+#include string.tin
+
+%start command
+
+%token NONE_
+%token REGION_
+%token CROSSHAIR_
+%token COLORBAR_
+%token PAN_
+%token ZOOM_
+%token ROTATE_
+%token CATALOG_
+%token EXAMINE_
+%token POINTER_
+
+%%
+
+command : mode
+ | mode {yyclearin; YYACCEPT} STRING_
+ ;
+
+mode : item {CurrentCmdSet mode $1 ChangeMode}
+ ;
+
+item : NONE_ {set _ none}
+ | REGION_ {set _ region}
+ | CROSSHAIR_ {set _ crosshair}
+ | COLORBAR_ {set _ colorbar}
+ | PAN_ {set _ pan}
+ | ZOOM_ {set _ zoom}
+ | ROTATE_ {set _ rotate}
+ | CATALOG_ {set _ catalog}
+ | EXAMINE_ {set _ examine}
+# backward compatibilty
+ | POINTER_ {set _ region}
+ ;
+
+%%
+
+proc mode::yyerror {msg} {
+ variable yycnt
+ variable yy_current_buffer
+ variable index_
+
+ ParserError $msg $yycnt $yy_current_buffer $index_
+}