summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-02-27 21:38:03 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-02-27 21:38:03 (GMT)
commitce6caae3395949230e685564a975433fb2b3cd32 (patch)
tree1940ae3da0df4c93451d89f4210feef4923743bb
parent79990d84c0f50dd1c64a56dc6670e3478088cf66 (diff)
downloadblt-ce6caae3395949230e685564a975433fb2b3cd32.zip
blt-ce6caae3395949230e685564a975433fb2b3cd32.tar.gz
blt-ce6caae3395949230e685564a975433fb2b3cd32.tar.bz2
add ds9 parsers
-rw-r--r--ds9/parsers/zoomlex.fcl49
-rw-r--r--ds9/parsers/zoomparser.tac46
2 files changed, 95 insertions, 0 deletions
diff --git a/ds9/parsers/zoomlex.fcl b/ds9/parsers/zoomlex.fcl
new file mode 100644
index 0000000..79ff034
--- /dev/null
+++ b/ds9/parsers/zoomlex.fcl
@@ -0,0 +1,49 @@
+%{
+source $ds9(root)/library/zoomparser.tab.tcl
+%}
+
+%option noyywrap
+%option caseless
+%option nodefault
+%option nointeractive
+#%option stack
+%option yylineno
+#%option debug
+
+D [0-9]
+E [Ee][+-]?{D}+
+
+%%
+
+close {return $zoom::CLOSE_}
+in {return $zoom::IN_}
+fit {return $zoom::FIT_}
+open {return $zoom::OPEN_}
+out {return $zoom::OUT_}
+to {return $zoom::TO_}
+
+# INT
+[+-]?{D}+ {set zoom::yylval $yytext; return $zoom::INT_}
+
+# REAL
+[+-]?{D}+"."?({E})? |
+[+-]?{D}*"."{D}+({E})? {set zoom::yylval $yytext; return $zoom::REAL_}
+
+# Quoted STRING
+\"[^\"]*\" {set zoom::yylval [string range $yytext 1 end-1]; return $zoom::STRING_}
+
+# Quoted STRING
+\'[^\']*\' {set zoom::yylval [string range $yytext 1 end-1]; return $zoom::STRING_}
+
+# Quoted STRING
+\{[^\}]*\} {set zoom::yylval [string range $yytext 1 end-1]; return $zoom::STRING_}
+
+# STRING
+\S+\S+ {set zoom::yylval $yytext; return $zoom::STRING_}
+
+\s # ignore whitespace
+
+. {set zoom::yylval $yytext; return $zoom::yylval}
+
+%%
+
diff --git a/ds9/parsers/zoomparser.tac b/ds9/parsers/zoomparser.tac
new file mode 100644
index 0000000..16d7ade
--- /dev/null
+++ b/ds9/parsers/zoomparser.tac
@@ -0,0 +1,46 @@
+%{
+%}
+
+%token INT_
+%token REAL_
+%token STRING_
+
+%start command
+
+%token CLOSE_
+%token IN_
+%token FIT_
+%token OPEN_
+%token OUT_
+%token TO_
+
+%%
+
+command : {ProcessRealizeDS9} zoom
+ ;
+
+zoom : numeric {Zoom $1 $1}
+ | numeric numeric {Zoom $1 $2}
+ | OPEN_ {PanZoomDialog}
+ | CLOSE_ {PanZoomDestroyDialog}
+ | IN_ {Zoom 2 2}
+ | OUT_ {Zoom .5 .5}
+ | TO_ zoomTo
+ ;
+
+zoomTo: FIT_ {ZoomToFit}
+ | numeric {global zoom; set current(zoom) " $1 $1 "; ChangeZoom}
+ | numeric numeric {global zoom; set current(zoom) " $1 $2 "; ChangeZoom}
+ ;
+
+numeric : INT_ {set _ $1}
+ | REAL_ {set _ $1}
+ ;
+
+%%
+
+proc zoom::yyerror {msg} {
+ puts stderr "$msg:"
+ puts stderr "$zoom::yy_current_buffer"
+ puts stderr [format "%*s" $zoom::index_ ^]
+}