diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2018-02-28 22:28:33 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2018-02-28 22:28:33 (GMT) |
commit | 56ad365bc8fd33689420ab6c8a75844a847ac5e0 (patch) | |
tree | 73fa6c76d4677555d4522927d13b8c46618bc2c4 | |
parent | 86b28ca3e06fb4e2da993e29583abf8140dc187e (diff) | |
download | blt-56ad365bc8fd33689420ab6c8a75844a847ac5e0.zip blt-56ad365bc8fd33689420ab6c8a75844a847ac5e0.tar.gz blt-56ad365bc8fd33689420ab6c8a75844a847ac5e0.tar.bz2 |
add ds9 pan parser
-rw-r--r-- | ds9/library/panlex.tcl | 763 | ||||
-rw-r--r-- | ds9/library/panparser.tab.tcl | 48 | ||||
-rw-r--r-- | ds9/library/panparser.tcl | 1405 | ||||
-rw-r--r-- | ds9/library/panzoom.tcl | 13 | ||||
-rw-r--r-- | ds9/library/source.tcl | 2 | ||||
-rw-r--r-- | ds9/library/zoomparser.tcl | 154 | ||||
-rw-r--r-- | ds9/parsers/panlex.fcl | 98 | ||||
-rw-r--r-- | ds9/parsers/panparser.tac | 137 | ||||
-rw-r--r-- | ds9/parsers/zoomparser.tac | 8 |
9 files changed, 2547 insertions, 81 deletions
diff --git a/ds9/library/panlex.tcl b/ds9/library/panlex.tcl new file mode 100644 index 0000000..b0c0a5a --- /dev/null +++ b/ds9/library/panlex.tcl @@ -0,0 +1,763 @@ +source $ds9(root)/library/panparser.tab.tcl + +###### +# Begin autogenerated fickle (version 2.1) routines. +# Although fickle itself is protected by the GNU Public License (GPL) +# all user-supplied functions are protected by their respective +# author's license. See http://mini.net/tcl/fickle for other details. +###### + +namespace eval pan { + variable yytext {} + variable yyleng 0 + variable yyin stdin + variable yyout stdout + variable yy_current_buffer {} + + variable yylineno 1 + + variable index_ 0 + variable done_ 0 +} + +# ECHO copies yytext to the scanner's output if no arguments are +# given. The scanner writes its ECHO output to the yyout global +# (default, stdout), which may be redefined by the user simply by +# assigning it to some other channel. +# -- from the flex(1) man page +proc pan::ECHO {{s ""}} { + variable yytext + variable yyout + + if {$s == ""} { + puts -nonewline $yyout $yytext + } else { + puts -nonewline $yyout $s + } +} + +# YY_FLUSH_BUFFER flushes the scanner's internal buffer so that the +# next time the scanner attempts to match a token, it will first +# refill the buffer using YY_INPUT. +# -- from the flex(1) man page +proc pan::YY_FLUSH_BUFFER {} { + variable yy_current_buffer + variable index_ + variable done_ + + set yy_current_buffer "" + set index_ 0 + set done_ 0 +} + +# yyrestart(new_file) may be called to point yyin at the new input +# file. The switch-over to the new file is immediate (any previously +# buffered-up input is lost). Note that calling yyrestart with yyin +# as an argument thus throws away the current input buffer and +# continues scanning the same input file. +# -- from the flex(1) man page +proc pan::yyrestart {new_file} { + variable yyin + + set yyin $new_file + YY_FLUSH_BUFFER +} + +# The nature of how it gets its input can be controlled by defining +# the YY_INPUT macro. YY_INPUT's calling sequence is +# "YY_INPUT(buf,result,max_size)". Its action is to place up to +# max_size characters in the character array buf and return in the +# integer variable result either the number of characters read or the +# constant YY_NULL (0 on Unix systems) to indicate EOF. The default +# YY_INPUT reads from the global file-pointer "yyin". +# -- from the flex(1) man page +proc pan::YY_INPUT {buf result max_size} { + variable yyin + + upvar $result ret_val + upvar $buf new_data + if {$yyin != ""} { + set new_data [read $yyin $max_size] + set ret_val [string length $new_data] + } else { + set new_data "" + set ret_val 0 + } +} + +# yy_scan_string sets up input buffers for scanning in-memory +# strings instead of files. Note that switching input sources does +# not change the start condition. +# -- from the flex(1) man page +proc pan::yy_scan_string {str} { + variable yy_current_buffer + variable yyin + + append yy_current_buffer $str + set yyin "" +} + +# unput(c) puts the character c back onto the input stream. It will +# be the next character scanned. +# -- from the flex(1) man page +proc pan::unput {c} { + variable yy_current_buffer + variable index_ + + set s [string range $yy_current_buffer 0 [expr {$index_ - 1}]] + append s $c + set yy_current_buffer [append s [string range $yy_current_buffer $index_ end]] +} + +# Returns all but the first n characters of the current token back to +# the input stream, where they will be rescanned when the scanner +# looks for the next match. yytext and yyleng are adjusted +# appropriately. +# -- from the flex(1) man page +proc pan::yyless {n} { + variable yy_current_buffer + variable index_ + variable yytext + variable yyleng + + set s [string range $yy_current_buffer 0 [expr {$index_ - 1}]] + append s [string range $yytext $n end] + set yy_current_buffer [append s [string range $yy_current_buffer $index_ end]] + set yytext [string range $yytext 0 [expr {$n - 1}]] + set yyleng [string length $yytext] +} + +# input() reads the next character from the input stream. +# -- from the flex(1) man page +proc pan::input {} { + variable yy_current_buffer + variable index_ + variable done_ + + if {[string length $yy_current_buffer] - $index_ < 1024} { + set new_buffer "" + set new_buffer_size 0 + if {$done_ == 0} { + YY_INPUT new_buffer new_buffer_size 1024 + append yy_current_buffer $new_buffer + if {$new_buffer_size == 0} { + set done_ 1 + } + } + if $done_ { + if {[string length $yy_current_buffer] - $index_ == 0} { + return {} + } + } + } + set c [string index $yy_current_buffer $index_] + incr index_ + return $c +} + +###### +# autogenerated yylex function created by fickle +###### + +# Whenever yylex() is called, it scans tokens from the global input +# file yyin (which defaults to stdin). It continues until it either +# reaches an end-of-file (at which point it returns the value 0) or +# one of its actions executes a return statement. +# -- from the flex(1) man page +proc pan::yylex {} { + variable yytext + variable yylineno + variable yyleng + variable yy_current_buffer + variable yy_flex_debug + + variable index_ + variable done_ + variable state_table_ + + while {1} { + if {[string length $yy_current_buffer] - $index_ < 1024} { + if {$done_ == 0} { + set buffer_size 0 + set new_buffer "" + YY_INPUT new_buffer buffer_size 1024 + append yy_current_buffer $new_buffer + if {$buffer_size == 0 && \ + [string length $yy_current_buffer] - $index_ == 0} { + set done_ 1 + } + } + if $done_ { + if {[string length $yy_current_buffer] - $index_ == 0} { + break + } + } + } + set yyleng 0 + set matched_rule -1 + # rule 0: close + if {[regexp -start $index_ -indices -line -nocase -- {\A(close)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 0 + } + # rule 1: open + if {[regexp -start $index_ -indices -line -nocase -- {\A(open)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 1 + } + # rule 2: to + if {[regexp -start $index_ -indices -line -nocase -- {\A(to)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 2 + } + # rule 3: wcs + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcs)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 3 + } + # rule 4: wcsa + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsa)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 4 + } + # rule 5: wcsb + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsb)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 5 + } + # rule 6: wcsc + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsc)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 6 + } + # rule 7: wcsd + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsd)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 7 + } + # rule 8: wcse + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcse)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 8 + } + # rule 9: wcsf + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsf)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 9 + } + # rule 10: wcsg + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsg)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 10 + } + # rule 11: wcsh + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsh)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 11 + } + # rule 12: wcsi + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsi)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 12 + } + # rule 13: wcsj + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsj)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 13 + } + # rule 14: wcsk + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsk)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 14 + } + # rule 15: wcsl + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsl)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 15 + } + # rule 16: wcsm + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsm)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 16 + } + # rule 17: wcsn + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsn)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 17 + } + # rule 18: wcso + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcso)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 18 + } + # rule 19: wcsp + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsp)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 19 + } + # rule 20: wcsq + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsq)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 20 + } + # rule 21: wcsr + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsr)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 21 + } + # rule 22: wcss + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcss)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 22 + } + # rule 23: wcst + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcst)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 23 + } + # rule 24: wcsu + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsu)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 24 + } + # rule 25: wcsv + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsv)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 25 + } + # rule 26: wcsw + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsw)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 26 + } + # rule 27: wcsx + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsx)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 27 + } + # rule 28: wcsy + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsy)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 28 + } + # rule 29: wcsz + if {[regexp -start $index_ -indices -line -nocase -- {\A(wcsz)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 29 + } + # rule 30: image + if {[regexp -start $index_ -indices -line -nocase -- {\A(image)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 30 + } + # rule 31: physical + if {[regexp -start $index_ -indices -line -nocase -- {\A(physical)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 31 + } + # rule 32: amplifier + if {[regexp -start $index_ -indices -line -nocase -- {\A(amplifier)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 32 + } + # rule 33: detector + if {[regexp -start $index_ -indices -line -nocase -- {\A(detector)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 33 + } + # rule 34: fk4 + if {[regexp -start $index_ -indices -line -nocase -- {\A(fk4)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 34 + } + # rule 35: b1950 + if {[regexp -start $index_ -indices -line -nocase -- {\A(b1950)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 35 + } + # rule 36: fk5 + if {[regexp -start $index_ -indices -line -nocase -- {\A(fk5)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 36 + } + # rule 37: j2000 + if {[regexp -start $index_ -indices -line -nocase -- {\A(j2000)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 37 + } + # rule 38: galactic + if {[regexp -start $index_ -indices -line -nocase -- {\A(galactic)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 38 + } + # rule 39: ecliptic + if {[regexp -start $index_ -indices -line -nocase -- {\A(ecliptic)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 39 + } + # rule 40: [+-]?{D}+ + if {[regexp -start $index_ -indices -line -nocase -- {\A([+-]?([0-9])+)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 40 + } + # rule 41: [+-]?{D}+\.?({E})? + if {[regexp -start $index_ -indices -line -nocase -- {\A([+-]?([0-9])+\.?(([Ee][+-]?([0-9])+))?)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 41 + } + # rule 42: [+-]?{D}*\.{D}+({E})? + if {[regexp -start $index_ -indices -line -nocase -- {\A([+-]?([0-9])*\.([0-9])+(([Ee][+-]?([0-9])+))?)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 42 + } + # rule 43: [+-]?{D}+:{D}+:{D}+\.? + if {[regexp -start $index_ -indices -line -nocase -- {\A([+-]?([0-9])+:([0-9])+:([0-9])+\.?)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 43 + } + # rule 44: [+-]?{D}+:{D}+:{D}*\.{D}+ + if {[regexp -start $index_ -indices -line -nocase -- {\A([+-]?([0-9])+:([0-9])+:([0-9])*\.([0-9])+)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 44 + } + # rule 45: [+-]?{D}+h{D}+m{D}+\.?s + if {[regexp -start $index_ -indices -line -nocase -- {\A([+-]?([0-9])+h([0-9])+m([0-9])+\.?s)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 45 + } + # rule 46: [+-]?{D}+h{D}+m{D}*\.{D}+s + if {[regexp -start $index_ -indices -line -nocase -- {\A([+-]?([0-9])+h([0-9])+m([0-9])*\.([0-9])+s)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 46 + } + # rule 47: [+-]?{D}+d{D}+m{D}+\.?s + if {[regexp -start $index_ -indices -line -nocase -- {\A([+-]?([0-9])+d([0-9])+m([0-9])+\.?s)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 47 + } + # rule 48: [+-]?{D}+d{D}+m{D}*\.{D}+s + if {[regexp -start $index_ -indices -line -nocase -- {\A([+-]?([0-9])+d([0-9])+m([0-9])*\.([0-9])+s)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 48 + } + # rule 49: \"[^\"]*\" + if {[regexp -start $index_ -indices -line -nocase -- {\A(\"[^\"]*\")} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 49 + } + # rule 50: \'[^\']*\' + if {[regexp -start $index_ -indices -line -nocase -- {\A(\'[^\']*\')} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 50 + } + # rule 51: \{[^\}]*\} + if {[regexp -start $index_ -indices -line -nocase -- {\A(\{[^\}]*\})} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 51 + } + # rule 52: \S+\S+ + if {[regexp -start $index_ -indices -line -nocase -- {\A(\S+\S+)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 52 + } + # rule 53: \s + if {[regexp -start $index_ -indices -line -nocase -- {\A(\s)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 53 + } + # rule 54: . + if {[regexp -start $index_ -indices -line -nocase -- {\A(.)} $yy_current_buffer match] > 0 && \ + [lindex $match 1] - $index_ + 1 > $yyleng} { + set yytext [string range $yy_current_buffer $index_ [lindex $match 1]] + set yyleng [string length $yytext] + set matched_rule 54 + } + if {$matched_rule == -1} { + set yytext [string index $yy_current_buffer $index_] + set yyleng 1 + } + incr index_ $yyleng + # workaround for Tcl's circumflex behavior + if {[string index $yytext end] == "\n"} { + set yy_current_buffer [string range $yy_current_buffer $index_ end] + set index_ 0 + } + set numlines [expr {[llength [split $yytext "\n"]] - 1}] + switch -- $matched_rule { + 0 { +return $pan::CLOSE_ + } + 1 { +return $pan::OPEN_ + } + 2 { +return $pan::TO_ + } + 3 { +return $pan::WCS_ + } + 4 { +return $pan::WCSA_ + } + 5 { +return $pan::WCSB_ + } + 6 { +return $pan::WCSC_ + } + 7 { +return $pan::WCSD_ + } + 8 { +return $pan::WCSE_ + } + 9 { +return $pan::WCSF_ + } + 10 { +return $pan::WCSG_ + } + 11 { +return $pan::WCSH_ + } + 12 { +return $pan::WCSI_ + } + 13 { +return $pan::WCSJ_ + } + 14 { +return $pan::WCSK_ + } + 15 { +return $pan::WCSL_ + } + 16 { +return $pan::WCSM_ + } + 17 { +return $pan::WCSN_ + } + 18 { +return $pan::WCSO_ + } + 19 { +return $pan::WCSP_ + } + 20 { +return $pan::WCSQ_ + } + 21 { +return $pan::WCSR_ + } + 22 { +return $pan::WCSS_ + } + 23 { +return $pan::WCST_ + } + 24 { +return $pan::WCSU_ + } + 25 { +return $pan::WCSV_ + } + 26 { +return $pan::WCSW_ + } + 27 { +return $pan::WCSX_ + } + 28 { +return $pan::WCSY_ + } + 29 { +return $pan::WCSZ_ + } + 30 { +return $pan::IMAGE_ + } + 31 { +return $pan::PHYSICAL_ + } + 32 { +return $pan::AMPLIFIER_ + } + 33 { +return $pan::DETECTOR_ + } + 34 { +return $pan::FK4_ + } + 35 { +return $pan::FK4_ + } + 36 { +return $pan::FK5_ + } + 37 { +return $pan::FK5_ + } + 38 { +return $pan::GALACTIC_ + } + 39 { +return $pan::ECLIPTIC_ + } + 40 { +set pan::yylval $yytext; return $pan::INT_ + } + 41 - + 42 { +set pan::yylval $yytext; return $pan::REAL_ + } + 43 - + 44 { +set pan::yylval $yytext; return $pan::SEXSTR_ + } + 45 - + 46 { +set pan::yylval $yytext; return $pan::HMSSTR_ + } + 47 - + 48 { +set pan::yylval $yytext; return $pan::SMSSTR_ + } + 49 { +set pan::yylval [string range $yytext 1 end-1]; return $pan::STRING_ + } + 50 { +set pan::yylval [string range $yytext 1 end-1]; return $pan::STRING_ + } + 51 { +set pan::yylval [string range $yytext 1 end-1]; return $pan::STRING_ + } + 52 { +set pan::yylval $yytext; return $pan::STRING_ + } + 53 { +# ignore whitespace + } + 54 { +set pan::yylval $yytext; return $pan::yylval + } + default + { puts stderr "unmatched token: $yytext"; exit -1 } + } + incr yylineno $numlines + } + return 0 +} +###### +# end autogenerated fickle functions +###### + + diff --git a/ds9/library/panparser.tab.tcl b/ds9/library/panparser.tab.tcl new file mode 100644 index 0000000..dfdeed6 --- /dev/null +++ b/ds9/library/panparser.tab.tcl @@ -0,0 +1,48 @@ +namespace eval pan { +set INT_ 257 +set REAL_ 258 +set STRING_ 259 +set SEXSTR_ 260 +set CLOSE_ 261 +set OPEN_ 262 +set TO_ 263 +set IMAGE_ 264 +set PHYSICAL_ 265 +set AMPLIFIER_ 266 +set DETECTOR_ 267 +set WCS_ 268 +set WCSA_ 269 +set WCSB_ 270 +set WCSC_ 271 +set WCSD_ 272 +set WCSE_ 273 +set WCSF_ 274 +set WCSG_ 275 +set WCSH_ 276 +set WCSI_ 277 +set WCSJ_ 278 +set WCSK_ 279 +set WCSL_ 280 +set WCSM_ 281 +set WCSN_ 282 +set WCSO_ 283 +set WCSP_ 284 +set WCSQ_ 285 +set WCSR_ 286 +set WCSS_ 287 +set WCST_ 288 +set WCSU_ 289 +set WCSV_ 290 +set WCSW_ 291 +set WCSX_ 292 +set WCSY_ 293 +set WCSZ_ 294 +set FK4_ 295 +set FK5_ 296 +set ICRS_ 297 +set GALACTIC_ 298 +set ECLIPTIC_ 299 +set J2000_ 300 +set B1950_ 301 +set yylval {} +} diff --git a/ds9/library/panparser.tcl b/ds9/library/panparser.tcl new file mode 100644 index 0000000..e088689 --- /dev/null +++ b/ds9/library/panparser.tcl @@ -0,0 +1,1405 @@ + +###### +# Begin autogenerated taccle (version 1.2) routines. +# Although taccle itself is protected by the GNU Public License (GPL) +# all user-supplied functions are protected by their respective +# author's license. See http://mini.net/tcl/taccle for other details. +###### + +namespace eval pan { + variable yylval {} + variable table + variable rules + variable token {} + variable yycnt 0 + + namespace export yylex +} + +proc pan::YYABORT {} { + return -code return 1 +} + +proc pan::YYACCEPT {} { + return -code return 0 +} + +proc pan::yyclearin {} { + variable token + variable yycnt + set token {} + incr yycnt -1 +} + +proc pan::yyerror {s} { + puts stderr $s +} + +proc pan::setupvalues {stack pointer numsyms} { + upvar 1 1 y + set y {} + for {set i 1} {$i <= $numsyms} {incr i} { + upvar 1 $i y + set y [lindex $stack $pointer] + incr pointer + } +} + +proc pan::unsetupvalues {numsyms} { + for {set i 1} {$i <= $numsyms} {incr i} { + upvar 1 $i y + unset y + } +} + +array set pan::table { + 21:300 reduce + 21:301 reduce + 6:259,target 55 + 43:296,target 32 + 2:284,target 4 + 21:295 reduce + 48:0 reduce + 21:296 reduce + 14:274,target 44 + 21:297 reduce + 21:298 reduce + 10:298,target 50 + 21:299 reduce + 9:304 goto + 26:259 reduce + 1:258,target 3 + 27:259,target 16 + 37:295,target 26 + 33:0,target 22 + 21:0 reduce + 44:296,target 33 + 14:291,target 44 + 14:301,target 44 + 0:302,target 7 + 1:275,target 3 + 12:282,target 45 + 26:300 reduce + 2:258,target 4 + 26:301 reduce + 28:259,target 17 + 38:295,target 27 + 54:300,target 52 + 10:273,target 25 + 26:295 reduce + 26:296 reduce + 26:297 reduce + 26:298 reduce + 26:299 reduce + 32:259 reduce + 45:296,target 34 + 29:0,target 18 + 30:0,target 19 + 35:0 reduce + 1:292,target 3 + 12:298,target 45 + 2:275,target 4 + 14:265,target 43 + 29:259,target 18 + 30:259,target 19 + 40:295,target 29 + 39:295,target 28 + 10:289,target 41 + 10:290,target 42 + 10:300,target 52 + 9:0 reduce + 32:300 reduce + 32:301 reduce + 9:259,target 50 + 32:295 reduce + 46:296,target 35 + 32:296 reduce + 32:297 reduce + 32:298 reduce + 32:299 reduce + 37:259 reduce + 2:292,target 4 + 14:282,target 44 + 50:0 reduce + 49:0 reduce + 57:0,target 53 + 31:259,target 20 + 41:295,target 30 + 1:266,target 3 + 12:273,target 45 + 26:0,target 15 + 8:303,target 14 + 20:299,target 9 + 14:298,target 44 + 22:0 reduce + 37:300 reduce + 37:301 reduce + 0:309,target 11 + 32:259,target 21 + 42:295,target 31 + 1:283,target 3 + 12:289,target 45 + 12:290,target 45 + 12:300,target 45 + 37:295 reduce + 37:296 reduce + 2:266,target 4 + 37:297 reduce + 37:298 reduce + 54:297,target 49 + 37:299 reduce + 43:259 reduce + 10:281,target 33 + 0:257,target 1 + 21:299,target 10 + 54:0,target 52 + 13:259 reduce + 2:257 reduce + 23:0,target 12 + 2:258 reduce + 2:259 reduce + 2:264 reduce + 2:265 reduce + 2:266 reduce + 1:299,target 3 + 36:0 reduce + 2:267 reduce + 33:259,target 22 + 43:295,target 32 + 2:283,target 4 + 2:268 reduce + 2:270 reduce + 2:269 reduce + 2:271 reduce + 14:273,target 44 + 2:272 reduce + 2:273 reduce + 10:297,target 49 + 2:274 reduce + 2:275 reduce + 2:276 reduce + 43:300 reduce + 2:277 reduce + 1:257,target 3 + 43:301 reduce + 2:278 reduce + 22:299,target 11 + 2:280 reduce + 2:279 reduce + 2:281 reduce + 2:282 reduce + 43:295 reduce + 2:283 reduce + 43:296 reduce + 2:284 reduce + 43:297 reduce + 2:285 reduce + 20:301,target 9 + 43:298 reduce + 2:286 reduce + 43:299 reduce + 2:287 reduce + 9:267,target 18 + 48:259 reduce + 2:288 reduce + 2:300 reduce + 2:290 reduce + 2:289 reduce + 2:291 reduce + 2:301 reduce + 2:292 reduce + 2:293 reduce + 51:0,target 42 + 2:299,target 4 + 2:294 reduce + 18:259 reduce + 2:295 reduce + 34:259,target 23 + 44:295,target 33 + 2:296 reduce + 14:289,target 44 + 14:290,target 44 + 14:300,target 44 + 2:297 reduce + 2:298 reduce + 19:0,target 51 + 20:0,target 9 + 51:0 reduce + 2:299 reduce + 1:274,target 3 + 12:281,target 45 + 2:257,target 4 + 23:299,target 12 + 10:272,target 24 + 21:301,target 10 + 8:258,target 2 + 35:259,target 24 + 45:295,target 34 + 23:0 reduce + 1:301,target 3 + 1:291,target 3 + 5:0,target 47 + 12:297,target 45 + 54:259 reduce + 2:274,target 4 + 14:264,target 43 + 24:299,target 13 + 47:0,target 36 + 10:288,target 40 + 24:259 reduce + 16:0,target 6 + 22:301,target 11 + 36:259,target 25 + 46:295,target 35 + 2:291,target 4 + 2:301,target 4 + 37:0 reduce + 14:281,target 44 + 54:300 shift + 54:301 shift + 25:299,target 14 + 54:295 shift + 1:265,target 3 + 12:272,target 45 + 24:300 reduce + 54:296 shift + 54:306 goto + 24:301 reduce + 54:297 shift + 54:298 shift + 23:301,target 12 + 54:299 shift + 2:0,target 4 + 24:295 reduce + 24:296 reduce + 20:298,target 9 + 24:297 reduce + 24:298 reduce + 24:299 reduce + 44:0,target 33 + 29:259 reduce + 30:259 reduce + 37:259,target 26 + 13:0,target 49 + 14:297,target 44 + 0:308,target 10 + 52:0 reduce + 26:299,target 15 + 1:282,target 3 + 12:288,target 45 + 2:265,target 4 + 54:296,target 48 + 54:306,target 57 + 24:301,target 13 + 10:279,target 31 + 10:280,target 32 + 21:298,target 10 + 6:310,target 13 + 38:259,target 27 + 29:300 reduce + 30:300 reduce + 29:301 reduce + 30:301 reduce + 29:295 reduce + 30:295 reduce + 29:296 reduce + 30:296 reduce + 29:297 reduce + 30:297 reduce + 24:0 reduce + 29:298 reduce + 30:298 reduce + 1:298,target 3 + 29:299 reduce + 30:299 reduce + 41:0,target 30 + 27:299,target 16 + 35:259 reduce + 2:282,target 4 + 14:272,target 44 + 10:306,target 55 + 10:296,target 48 + 25:301,target 14 + 22:298,target 11 + 40:259,target 29 + 39:259,target 28 + 20:300,target 9 + 9:266,target 17 + 2:298,target 4 + 28:299,target 17 + 14:288,target 44 + 38:0 reduce + 35:300 reduce + 35:301 reduce + 26:301,target 15 + 1:273,target 3 + 12:279,target 45 + 12:280,target 45 + 35:295 reduce + 35:296 reduce + 35:297 reduce + 23:298,target 12 + 35:298 reduce + 35:299 reduce + 41:259 reduce + 37:0,target 26 + 10:271,target 23 + 41:259,target 30 + 21:300,target 10 + 11:259 shift + 0:257 shift + 0:258 shift + 0:259 reduce + 0:260 shift + 0:261 shift + 8:257,target 1 + 0:262 shift + 11:0 reduce + 29:299,target 18 + 30:299,target 19 + 0:263 shift + 1:300,target 3 + 1:290,target 3 + 1:289,target 3 + 12:296,target 45 + 53:0 reduce + 27:301,target 16 + 2:273,target 4 + 24:298,target 13 + 10:287,target 39 + 41:300 reduce + 42:259,target 31 + 41:301 reduce + 22:300,target 11 + 41:295 reduce + 41:296 reduce + 41:297 reduce + 41:298 reduce + 41:299 reduce + 46:259 reduce + 34:0,target 23 + 31:299,target 20 + 0:302 goto + 0:303 goto + 16:259 reduce + 25:0 reduce + 2:290,target 4 + 2:289,target 4 + 2:300,target 4 + 28:301,target 17 + 0:307 goto + 14:279,target 44 + 14:280,target 44 + 0:308 goto + 0:309 goto + 5:259 reduce + 25:298,target 14 + 0:0 reduce + 1:264,target 3 + 12:271,target 45 + 43:259,target 32 + 23:300,target 12 + 20:297,target 9 + 32:299,target 21 + 46:300 reduce + 46:301 reduce + 14:296,target 44 + 46:295 reduce + 29:301,target 18 + 30:301,target 19 + 46:296 reduce + 46:297 reduce + 40:0 reduce + 39:0 reduce + 46:298 reduce + 0:307,target 9 + 46:299 reduce + 26:298,target 15 + 52:259 reduce + 1:281,target 3 + 12:287,target 45 + 31:0,target 20 + 2:264,target 4 + 44:259,target 33 + 54:295,target 47 + 22:259 reduce + 24:300,target 13 + 10:278,target 30 + 21:297,target 10 + 33:299,target 22 + 31:301,target 20 + 1:297,target 3 + 27:298,target 16 + 2:281,target 4 + 54:0 reduce + 14:271,target 44 + 45:259,target 34 + 10:305,target 54 + 10:295,target 47 + 25:300,target 14 + 22:300 reduce + 22:301 reduce + 22:297,target 11 + 57:259 reduce + 22:295 reduce + 27:0,target 16 + 22:296 reduce + 22:297 reduce + 34:299,target 23 + 22:298 reduce + 22:299 reduce + 9:265,target 16 + 27:259 reduce + 32:301,target 21 + 2:297,target 4 + 26:0 reduce + 28:298,target 17 + 14:287,target 44 + 46:259,target 35 + 26:300,target 15 + 1:272,target 3 + 12:278,target 45 + 1:0 reduce + 23:297,target 12 + 10:269,target 21 + 10:270,target 22 + 35:299,target 24 + 27:300 reduce + 55:0,target 54 + 27:301 reduce + 33:301,target 22 + 24:0,target 13 + 27:295 reduce + 29:298,target 18 + 30:298,target 19 + 27:296 reduce + 27:297 reduce + 27:298 reduce + 41:0 reduce + 27:299 reduce + 47:259,target 36 + 1:288,target 3 + 12:295,target 45 + 33:259 reduce + 27:300,target 16 + 2:272,target 4 + 24:297,target 13 + 10:286,target 38 + 0:263,target 6 + 36:299,target 25 + 34:301,target 23 + 31:298,target 20 + 9:0,target 50 + 13:0 reduce + 48:259,target 38 + 2:288,target 4 + 28:300,target 17 + 14:278,target 44 + 33:300 reduce + 55:0 reduce + 52:0,target 39 + 33:301 reduce + 25:297,target 14 + 21:0,target 10 + 33:295 reduce + 12:269,target 45 + 12:270,target 45 + 33:296 reduce + 33:297 reduce + 37:299,target 26 + 33:298 reduce + 33:299 reduce + 38:259 reduce + 20:296,target 9 + 35:301,target 24 + 32:298,target 21 + 50:259,target 41 + 49:259,target 40 + 14:295,target 44 + 27:0 reduce + 29:300,target 18 + 30:300,target 19 + 26:297,target 15 + 1:280,target 3 + 1:279,target 3 + 12:286,target 45 + 6:0,target 55 + 38:299,target 27 + 2:0 reduce + 10:277,target 29 + 38:300 reduce + 48:0,target 38 + 38:301 reduce + 21:296,target 10 + 36:301,target 25 + 38:295 reduce + 17:0,target 7 + 38:296 reduce + 33:298,target 22 + 38:297 reduce + 38:298 reduce + 38:299 reduce + 44:259 reduce + 51:259,target 42 + 31:300,target 20 + 1:296,target 3 + 14:259 reduce + 42:0 reduce + 27:297,target 16 + 2:280,target 4 + 2:279,target 4 + 14:264 reduce + 14:269,target 44 + 14:270,target 44 + 14:265 reduce + 40:299,target 29 + 39:299,target 28 + 3:260 shift + 10:294,target 46 + 14:266 reduce + 14:267 reduce + 14:268 reduce + 14:269 reduce + 14:270 reduce + 14:271 reduce + 14:272 reduce + 22:296,target 11 + 37:301,target 26 + 14:273 reduce + 14:274 reduce + 14:275 reduce + 14:276 reduce + 14:277 reduce + 34:298,target 23 + 14:278 reduce + 14:279 reduce + 14:280 reduce + 9:264,target 15 + 14:281 reduce + 14:282 reduce + 52:259,target 39 + 14:283 reduce + 44:300 reduce + 14:284 reduce + 32:300,target 21 + 45:0,target 34 + 44:301 reduce + 14:285 reduce + 14:0 reduce + 14:286 reduce + 2:296,target 4 + 14:287 reduce + 14:288 reduce + 28:297,target 17 + 44:295 reduce + 14:0,target 43 + 14:286,target 44 + 14:289 reduce + 14:290 reduce + 14:300 reduce + 44:296 reduce + 14:291 reduce + 14:301 reduce + 44:297 reduce + 14:292 reduce + 56:0 reduce + 44:298 reduce + 14:293 reduce + 44:299 reduce + 41:299,target 30 + 14:294 reduce + 50:259 reduce + 49:259 reduce + 14:295 reduce + 1:271,target 3 + 12:277,target 45 + 14:296 reduce + 14:297 reduce + 14:298 reduce + 14:299 reduce + 23:296,target 12 + 38:301,target 27 + 19:259 reduce + 20:259 reduce + 10:268,target 20 + 8:257 shift + 35:298,target 24 + 8:258 shift + 53:259,target 37 + 33:300,target 22 + 29:297,target 18 + 30:297,target 19 + 28:0 reduce + 0:0,target 46 + 42:299,target 31 + 1:287,target 3 + 12:294,target 45 + 2:271,target 4 + 42:0,target 31 + 24:296,target 13 + 40:301,target 29 + 39:301,target 28 + 10:285,target 37 + 0:262,target 5 + 11:0,target 1 + 20:300 reduce + 20:301 reduce + 36:298,target 25 + 55:259 reduce + 20:295 reduce + 20:296 reduce + 54:259,target 52 + 20:297 reduce + 20:298 reduce + 34:300,target 23 + 8:303 goto + 20:299 reduce + 25:259 reduce + 31:297,target 20 + 43:299,target 32 + 2:287,target 4 + 43:0 reduce + 14:277,target 44 + 25:296,target 14 + 41:301,target 30 + 12:268,target 45 + 37:298,target 26 + 55:259,target 54 + 20:295,target 9 + 38:0,target 27 + 35:300,target 24 + 25:300 reduce + 32:297,target 21 + 25:301 reduce + 15:0 reduce + 44:299,target 33 + 14:294,target 44 + 25:295 reduce + 25:296 reduce + 25:297 reduce + 25:298 reduce + 25:299 reduce + 57:0 reduce + 26:296,target 15 + 31:259 reduce + 42:301,target 31 + 1:278,target 3 + 12:285,target 45 + 38:298,target 27 + 10:276,target 28 + 11:259,target 56 + 21:295,target 10 + 36:300,target 25 + 33:297,target 22 + 45:299,target 34 + 29:0 reduce + 30:0 reduce + 35:0,target 24 + 1:295,target 3 + 27:296,target 16 + 43:301,target 32 + 2:278,target 4 + 31:300 reduce + 14:268,target 44 + 31:301 reduce + 40:298,target 29 + 39:298,target 28 + 10:293,target 45 + 4:0 reduce + 31:295 reduce + 31:296 reduce + 31:297 reduce + 57:259,target 53 + 22:295,target 11 + 31:298 reduce + 37:300,target 26 + 31:299 reduce + 36:259 reduce + 34:297,target 23 + 46:299,target 35 + 2:295,target 4 + 28:296,target 17 + 44:301,target 33 + 14:285,target 44 + 44:0 reduce + 41:298,target 30 + 1:270,target 3 + 1:269,target 3 + 12:276,target 45 + 13:259,target 49 + 23:295,target 12 + 32:0,target 21 + 38:300,target 27 + 36:300 reduce + 36:301 reduce + 35:297,target 24 + 36:295 reduce + 36:296 reduce + 36:297 reduce + 36:298 reduce + 36:299 reduce + 42:259 reduce + 16:0 reduce + 29:296,target 18 + 30:296,target 19 + 45:301,target 34 + 42:298,target 31 + 1:286,target 3 + 12:293,target 45 + 2:270,target 4 + 2:269,target 4 + 1:257 reduce + 1:258 reduce + 14:259,target 43 + 1:259 reduce + 24:295,target 13 + 40:300,target 29 + 39:300,target 28 + 10:284,target 36 + 12:268 reduce + 0:261,target 4 + 12:269 reduce + 12:270 reduce + 1:264 reduce + 12:271 reduce + 36:297,target 25 + 1:265 reduce + 12:272 reduce + 1:266 reduce + 12:273 reduce + 1:267 reduce + 12:274 reduce + 1:268 reduce + 12:275 reduce + 1:269 reduce + 1:270 reduce + 12:276 reduce + 1:271 reduce + 12:277 reduce + 1:272 reduce + 12:278 reduce + 1:273 reduce + 12:279 reduce + 12:280 reduce + 28:0,target 17 + 1:274 reduce + 12:281 reduce + 1:275 reduce + 12:282 reduce + 1:276 reduce + 12:283 reduce + 31:296,target 20 + 46:301,target 35 + 42:300 reduce + 1:277 reduce + 12:284 reduce + 42:301 reduce + 1:278 reduce + 12:285 reduce + 1:280 reduce + 1:279 reduce + 12:286 reduce + 1:281 reduce + 12:287 reduce + 31:0 reduce + 43:298,target 32 + 2:286,target 4 + 1:282 reduce + 12:288 reduce + 42:295 reduce + 1:283 reduce + 12:289 reduce + 12:290 reduce + 12:300 reduce + 42:296 reduce + 1:284 reduce + 12:291 reduce + 12:301 reduce + 14:276,target 44 + 42:297 reduce + 1:285 reduce + 12:292 reduce + 42:298 reduce + 1:286 reduce + 12:293 reduce + 15:259,target 5 + 42:299 reduce + 1:287 reduce + 12:294 reduce + 25:295,target 14 + 47:259 reduce + 41:300,target 30 + 1:288 reduce + 12:295 reduce + 1:300 reduce + 1:290 reduce + 1:289 reduce + 12:296 reduce + 1:301 reduce + 1:291 reduce + 5:0 reduce + 12:297 reduce + 1:292 reduce + 12:298 reduce + 37:297,target 26 + 1:293 reduce + 12:299 reduce + 1:294 reduce + 17:259 reduce + 1:295 reduce + 1:296 reduce + 1:297 reduce + 1:298 reduce + 1:299 reduce + 6:259 reduce + 32:296,target 21 + 56:0,target 2 + 44:298,target 33 + 14:293,target 44 + 45:0 reduce + 16:259,target 6 + 25:0,target 14 + 26:295,target 15 + 42:300,target 31 + 1:277,target 3 + 12:284,target 45 + 38:297,target 27 + 10:275,target 27 + 53:259 reduce + 33:296,target 22 + 23:259 reduce + 45:298,target 34 + 17:0 reduce + 6:310 goto + 1:294,target 3 + 17:259,target 7 + 27:295,target 16 + 43:300,target 32 + 2:277,target 4 + 14:267,target 43 + 40:297,target 29 + 39:297,target 28 + 10:292,target 44 + 53:0,target 37 + 22:0,target 11 + 34:296,target 23 + 46:298,target 35 + 23:300 reduce + 23:301 reduce + 2:294,target 4 + 18:259,target 8 + 23:295 reduce + 28:295,target 17 + 32:0 reduce + 44:300,target 33 + 14:284,target 44 + 23:296 reduce + 23:297 reduce + 23:298 reduce + 23:299 reduce + 41:297,target 30 + 28:259 reduce + 1:268,target 3 + 12:275,target 45 + 6:0 reduce + 7:0,target 0 + 35:296,target 24 + 50:0,target 41 + 49:0,target 40 + 18:0,target 8 + 19:259,target 51 + 20:259,target 9 + 29:295,target 18 + 30:295,target 19 + 45:300,target 34 + 46:0 reduce + 42:297,target 31 + 1:285,target 3 + 12:292,target 45 + 2:268,target 4 + 28:300 reduce + 28:301 reduce + 54:299,target 51 + 10:283,target 35 + 28:295 reduce + 0:259,target 46 + 0:260,target 3 + 28:296 reduce + 28:297 reduce + 36:296,target 25 + 28:298 reduce + 28:299 reduce + 34:259 reduce + 21:259,target 10 + 4:0,target 48 + 31:295,target 20 + 46:300,target 35 + 18:0 reduce + 43:297,target 32 + 2:285,target 4 + 46:0,target 35 + 14:275,target 44 + 10:299,target 51 + 15:0,target 5 + 1:259,target 3 + 37:296,target 26 + 34:300 reduce + 34:301 reduce + 22:259,target 11 + 34:295 reduce + 32:295,target 21 + 34:296 reduce + 34:297 reduce + 34:298 reduce + 34:299 reduce + 40:259 reduce + 39:259 reduce + 44:297,target 33 + 14:292,target 44 + 33:0 reduce + 0:303,target 8 + 1:276,target 3 + 12:283,target 45 + 1:0,target 3 + 2:259,target 4 + 38:296,target 27 + 7:0 accept + 54:301,target 53 + 10:268 shift + 10:274,target 26 + 43:0,target 32 + 10:269 shift + 10:270 shift + 10:271 shift + 10:272 shift + 10:273 shift + 10:274 shift + 10:275 shift + 10:276 shift + 23:259,target 12 + 10:277 shift + 33:295,target 22 + 10:278 shift + 10:279 shift + 10:280 shift + 10:281 shift + 10:282 shift + 45:297,target 34 + 10:283 shift + 40:300 reduce + 39:300 reduce + 10:284 shift + 40:301 reduce + 39:301 reduce + 10:285 shift + 10:286 shift + 1:293,target 3 + 10:287 shift + 12:299,target 45 + 47:0 reduce + 10:288 shift + 40:295 reduce + 39:295 reduce + 2:276,target 4 + 10:289 shift + 10:290 shift + 10:300 shift + 40:296 reduce + 39:296 reduce + 10:291 shift + 10:301 shift + 40:297 reduce + 39:297 reduce + 3:260,target 12 + 10:292 shift + 14:266,target 43 + 40:298 reduce + 39:298 reduce + 10:293 shift + 40:299 reduce + 40:296,target 29 + 39:299 reduce + 39:296,target 28 + 10:291,target 43 + 10:294 shift + 10:301,target 53 + 45:259 reduce + 10:305 goto + 10:295 shift + 10:306 goto + 10:296 shift + 10:297 shift + 10:298 shift + 10:299 shift + 15:259 reduce + 24:259,target 13 + 34:295,target 23 + 4:259 reduce + 46:297,target 35 + 40:0,target 29 + 39:0,target 28 + 19:0 reduce + 20:0 reduce + 2:293,target 4 + 14:283,target 44 + 4:259,target 48 + 41:296,target 30 + 1:267,target 3 + 12:274,target 45 + 45:300 reduce + 45:301 reduce + 45:295 reduce + 45:296 reduce + 25:259,target 14 + 45:297 reduce + 35:295,target 24 + 45:298 reduce + 45:299 reduce + 51:259 reduce + 21:259 reduce + 14:299,target 44 + 34:0 reduce + 5:259,target 47 + 9:259 reduce + 42:296,target 31 + 1:284,target 3 + 12:291,target 45 + 12:301,target 45 + 36:0,target 25 + 2:267,target 4 + 9:264 shift + 9:265 shift + 54:298,target 50 + 9:266 shift + 9:267 shift + 10:282,target 34 + 0:258,target 2 + 9:304,target 19 + 26:259,target 15 + 36:295,target 25 +} + +array set pan::rules { + 9,l 305 + 11,l 305 + 32,l 305 + 53,l 309 + 6,l 304 + 28,l 305 + 50,l 309 + 49,l 309 + 3,l 303 + 25,l 305 + 46,l 309 + 0,l 311 + 22,l 305 + 43,l 307 + 18,l 305 + 40,l 306 + 39,l 306 + 15,l 305 + 36,l 306 + 12,l 305 + 33,l 305 + 54,l 309 + 7,l 304 + 29,l 305 + 30,l 305 + 51,l 309 + 4,l 303 + 26,l 305 + 47,l 309 + 1,l 302 + 23,l 305 + 44,l 308 + 19,l 305 + 20,l 305 + 41,l 306 + 16,l 305 + 37,l 306 + 13,l 305 + 34,l 305 + 55,l 310 + 8,l 304 + 10,l 305 + 31,l 305 + 52,l 309 + 5,l 304 + 27,l 305 + 48,l 309 + 2,l 302 + 24,l 305 + 45,l 308 + 21,l 305 + 42,l 306 + 17,l 305 + 38,l 306 + 14,l 305 + 35,l 305 +} + +array set pan::rules { + 12,dc 1 + 26,dc 1 + 3,dc 1 + 41,dc 1 + 55,dc 0 + 18,dc 1 + 33,dc 1 + 9,dc 1 + 47,dc 1 + 11,dc 1 + 25,dc 1 + 2,dc 2 + 40,dc 1 + 39,dc 1 + 54,dc 2 + 17,dc 1 + 32,dc 1 + 8,dc 1 + 46,dc 0 + 10,dc 1 + 24,dc 1 + 1,dc 1 + 38,dc 1 + 53,dc 3 + 16,dc 1 + 31,dc 1 + 7,dc 1 + 45,dc 2 + 23,dc 1 + 0,dc 1 + 37,dc 1 + 52,dc 2 + 15,dc 1 + 29,dc 1 + 30,dc 1 + 6,dc 1 + 44,dc 2 + 22,dc 1 + 36,dc 1 + 51,dc 2 + 14,dc 1 + 28,dc 1 + 5,dc 1 + 43,dc 2 + 21,dc 1 + 35,dc 1 + 50,dc 1 + 49,dc 2 + 13,dc 1 + 27,dc 1 + 4,dc 1 + 42,dc 1 + 19,dc 1 + 20,dc 1 + 34,dc 1 + 48,dc 1 +} + +array set pan::rules { + 41,line 107 + 7,line 69 + 37,line 103 + 4,line 64 + 34,line 98 + 1,line 59 + 31,line 95 + 27,line 91 + 24,line 88 + 21,line 85 + 17,line 81 + 14,line 78 + 11,line 75 + 53,line 125 + 50,line 122 + 49,line 121 + 46,line 118 + 43,line 111 + 9,line 73 + 40,line 106 + 39,line 105 + 6,line 68 + 36,line 102 + 3,line 63 + 33,line 97 + 29,line 93 + 30,line 94 + 26,line 90 + 23,line 87 + 19,line 83 + 20,line 84 + 16,line 80 + 13,line 77 + 10,line 74 + 55,line 129 + 52,line 124 + 48,line 120 + 45,line 115 + 42,line 108 + 8,line 70 + 38,line 104 + 5,line 67 + 35,line 99 + 2,line 60 + 32,line 96 + 28,line 92 + 25,line 89 + 22,line 86 + 18,line 82 + 15,line 79 + 12,line 76 + 54,line 126 + 51,line 123 + 47,line 119 + 44,line 114 +} + +proc pan::yyparse {} { + variable yylval + variable table + variable rules + variable token + variable yycnt + + set state_stack {0} + set value_stack {{}} + set token "" + set accepted 0 + + while {$accepted == 0} { + set state [lindex $state_stack end] + if {$token == ""} { + set yylval "" + set token [yylex] + set buflval $yylval + if {$token>0} { + incr yycnt + } + } + if {![info exists table($state:$token)]} { + # pop off states until error token accepted + while {[llength $state_stack] > 0 && \ + ![info exists table($state:error)]} { + set state_stack [lrange $state_stack 0 end-1] + set value_stack [lrange $value_stack 0 \ + [expr {[llength $state_stack] - 1}]] + set state [lindex $state_stack end] + } + if {[llength $state_stack] == 0} { + yyerror "parse error" + return 1 + } + lappend state_stack [set state $table($state:error,target)] + lappend value_stack {} + # consume tokens until it finds an acceptable one + while {![info exists table($state:$token)]} { + if {$token == 0} { + yyerror "end of file while recovering from error" + return 1 + } + set yylval {} + set token [yylex] + set buflval $yylval + } + continue + } + switch -- $table($state:$token) { + shift { + lappend state_stack $table($state:$token,target) + lappend value_stack $buflval + set token "" + } + reduce { + set rule $table($state:$token,target) + set ll $rules($rule,l) + if {[info exists rules($rule,e)]} { + set dc $rules($rule,e) + } else { + set dc $rules($rule,dc) + } + set stackpointer [expr {[llength $state_stack]-$dc}] + setupvalues $value_stack $stackpointer $dc + set _ $1 + set yylval [lindex $value_stack end] + switch -- $rule { + 2 { pan::yyclearin } + 3 { set _ $1 } + 4 { set _ $1 } + 5 { set _ image } + 6 { set _ physical } + 7 { set _ amplifier } + 8 { set _ detector } + 9 { set _ wcs } + 10 { set _ wcsa } + 11 { set _ wcsb } + 12 { set _ wcsc } + 13 { set _ wcsd } + 14 { set _ wcse } + 15 { set _ wcsf } + 16 { set _ wcsg } + 17 { set _ wcsh } + 18 { set _ wcsi } + 19 { set _ wcsj } + 20 { set _ wcsk } + 21 { set _ wcsl } + 22 { set _ wcsm } + 23 { set _ wcsn } + 24 { set _ wcso } + 25 { set _ wcsp } + 26 { set _ wcsq } + 27 { set _ wcsr } + 28 { set _ wcss } + 29 { set _ wcst } + 30 { set _ wcsu } + 31 { set _ wcsv } + 32 { set _ wcsw } + 33 { set _ wcsx } + 34 { set _ wcsy } + 35 { set _ wcsz } + 36 { set _ fk4 } + 37 { set _ fk4 } + 38 { set _ fk5 } + 39 { set _ fk5 } + 40 { set _ icrs } + 41 { set _ galactic } + 42 { set _ ecliptic } + 43 { set pan::yy(x) $1; set pan::yy(y) $2 } + 44 { set pan::yy(x) $1; set pan::yy(y) $2 } + 45 { set pan::yy(x) $1; set pan::yy(y) $2 } + 47 { PanZoomDialog } + 48 { PanZoomDestroyDialog } + } + unsetupvalues $dc + # pop off tokens from the stack if normal rule + if {![info exists rules($rule,e)]} { + incr stackpointer -1 + set state_stack [lrange $state_stack 0 $stackpointer] + set value_stack [lrange $value_stack 0 $stackpointer] + } + # now do the goto transition + lappend state_stack $table([lindex $state_stack end]:$ll,target) + lappend value_stack $_ + } + accept { + set accepted 1 + } + goto - + default { + puts stderr "Internal parser error: illegal command $table($state:$token)" + return 2 + } + } + } + return 0 +} + +###### +# end autogenerated taccle functions +###### + +proc pan::yyerror {msg} { + puts stderr "$msg:" + puts stderr "$pan::yy_current_buffer" + puts stderr [format "%*s" $pan::index_ ^] +} diff --git a/ds9/library/panzoom.tcl b/ds9/library/panzoom.tcl index 9fa7a89..0dceff2 100644 --- a/ds9/library/panzoom.tcl +++ b/ds9/library/panzoom.tcl @@ -673,6 +673,19 @@ proc ProcessPanCmd {varname iname} { # we need to be realized ProcessRealizeDS9 + pan::YY_FLUSH_BUFFER + pan::yy_scan_string [lrange $var $i end] + pan::yyparse + incr i [expr $pan::yycnt-1] +} + +proc oProcessPanCmd {varname iname} { + upvar $varname var + upvar $iname i + + # we need to be realized + ProcessRealizeDS9 + switch -- [string tolower [lindex $var $i]] { open {PanZoomDialog} close {PanZoomDestroyDialog} diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index feba385..b1be59f 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -188,6 +188,8 @@ source $ds9(root)/library/xmfbox.tcl source $ds9(root)/library/xmlrpc.tcl source $ds9(root)/library/xpa.tcl +source $ds9(root)/library/panparser.tcl +source $ds9(root)/library/panlex.tcl source $ds9(root)/library/zoomparser.tcl source $ds9(root)/library/zoomlex.tcl diff --git a/ds9/library/zoomparser.tcl b/ds9/library/zoomparser.tcl index 8263584..88e3fe0 100644 --- a/ds9/library/zoomparser.tcl +++ b/ds9/library/zoomparser.tcl @@ -53,164 +53,164 @@ proc zoom::unsetupvalues {numsyms} { } array set zoom::table { - 15:259 reduce 0:257 shift 0:258 shift 0:260 shift 2:257 reduce - 5:0,target 5 - 15:0,target 4 + 5:0,target 7 + 15:0,target 2 9:0 reduce - 6:259,target 8 + 6:259,target 10 0:261 shift 0:266,target 8 2:258 reduce 11:0 reduce 2:259 reduce - 10:258,target 2 0:263 shift 0:264 shift - 1:259,target 13 + 1:259,target 3 4:259 reduce - 13:269 goto 0:265 shift 15:0 reduce 6:259 reduce 0:266 goto 13:259,target 11 0:267 goto - 13:269,target 16 + 0:268 goto 0:265,target 7 - 6:0,target 8 - 0:269 goto - 16:0,target 12 - 10:257,target 1 + 6:0,target 10 + 16:0,target 14 2:0 reduce - 1:258,target 13 - 9:259,target 14 + 1:258,target 3 + 9:259,target 5 7:262,target 11 - 13:258,target 2 6:0 reduce 0:264,target 6 - 4:259,target 7 - 16:259,target 12 - 1:257,target 13 + 4:259,target 9 + 16:259,target 14 + 1:257,target 3 12:0 reduce - 10:0,target 3 - 13:257,target 1 - 11:259,target 10 + 9:258,target 2 + 10:0,target 1 + 11:259,target 12 0:263,target 5 16:0 reduce - 10:257 shift - 10:258 shift - 10:259 reduce + 12:257 shift + 10:259 shift + 12:258 shift + 9:257,target 1 12:259 reduce + 9:267,target 14 8:0,target 0 7:269,target 13 3:0 reduce - 1:0,target 13 - 11:0,target 10 - 2:259,target 14 + 1:0,target 3 + 14:259 reduce + 11:0,target 12 + 2:259,target 4 16:259 reduce 1:257 reduce + 14:259,target 6 1:258 reduce 7:258,target 2 1:259 reduce - 10:269 goto - 7:268,target 12 + 12:267 goto 3:259 reduce 13:0 reduce - 9:0,target 1 + 9:0,target 5 0:261,target 4 - 2:258,target 14 + 2:258,target 4 7:257 shift - 2:0,target 14 + 2:0,target 4 5:259 reduce - 12:0,target 9 + 12:0,target 13 7:258 shift + 9:257 shift + 9:258 shift 7:257,target 1 - 5:259,target 5 - 9:259 shift + 5:259,target 7 + 9:259 reduce + 7:267,target 12 7:262 shift 0:260,target 3 - 2:257,target 14 - 0:269,target 10 + 2:257,target 4 4:0 reduce - 12:259,target 9 - 3:0,target 6 + 12:259,target 13 + 7:267 goto + 3:0,target 8 13:0,target 11 - 7:268 goto + 9:267 goto 8:0 accept 7:269 goto 10:0 reduce 0:258,target 2 + 0:268,target 10 14:0 reduce - 3:259,target 6 - 4:0,target 7 - 14:0,target 2 - 15:259,target 4 + 12:258,target 2 + 3:259,target 8 + 4:0,target 9 + 14:0,target 6 0:257,target 1 1:0 reduce - 13:257 shift 11:259 reduce 0:267,target 9 - 13:258 shift 13:259 reduce - 10:259,target 3 - 10:269,target 15 + 12:257,target 1 + 10:259,target 15 + 12:267,target 16 5:0 reduce } array set zoom::rules { - 9,l 267 + 9,l 268 11,l 268 2,l 266 - 6,l 267 - 12,l 268 + 6,l 268 + 12,l 269 3,l 267 - 7,l 267 + 7,l 268 13,l 269 0,l 270 4,l 267 - 8,l 267 + 8,l 268 10,l 268 14,l 269 1,l 266 - 5,l 267 + 5,l 268 } array set zoom::rules { 5,dc 1 0,dc 1 - 12,dc 2 + 12,dc 1 8,dc 1 3,dc 1 10,dc 1 - 6,dc 1 + 6,dc 2 1,dc 1 13,dc 1 - 9,dc 2 - 4,dc 2 - 11,dc 1 + 9,dc 1 + 4,dc 1 + 11,dc 2 7,dc 1 2,dc 2 - 14,dc 1 + 14,dc 2 } array set zoom::rules { 13,line 38 - 7,line 28 + 7,line 30 10,line 33 4,line 25 1,line 20 - 9,line 30 - 12,line 35 - 6,line 27 + 9,line 32 + 12,line 37 + 6,line 29 3,line 24 14,line 39 - 8,line 29 + 8,line 31 11,line 34 - 5,line 26 + 5,line 28 2,line 21 } @@ -283,17 +283,17 @@ proc zoom::yyparse {} { set yylval [lindex $value_stack end] switch -- $rule { 2 { zoom::yyclearin } - 3 { Zoom $1 $1 } - 4 { Zoom $1 $2 } - 5 { PanZoomDialog } - 6 { PanZoomDestroyDialog } - 7 { Zoom 2 2 } - 8 { Zoom .5 .5 } - 10 { ZoomToFit } - 11 { global zoom; set current(zoom) "$1 $1"; ChangeZoom } - 12 { global zoom; set current(zoom) "$1 $2"; ChangeZoom } - 13 { set _ $1 } - 14 { set _ $1 } + 3 { set _ $1 } + 4 { set _ $1 } + 5 { Zoom $1 $1 } + 6 { Zoom $1 $2 } + 7 { PanZoomDialog } + 8 { PanZoomDestroyDialog } + 9 { Zoom 2 2 } + 10 { Zoom .5 .5 } + 12 { ZoomToFit } + 13 { global zoom; set current(zoom) "$1 $1"; ChangeZoom } + 14 { global zoom; set current(zoom) "$1 $2"; ChangeZoom } } unsetupvalues $dc # pop off tokens from the stack if normal rule diff --git a/ds9/parsers/panlex.fcl b/ds9/parsers/panlex.fcl new file mode 100644 index 0000000..29d2861 --- /dev/null +++ b/ds9/parsers/panlex.fcl @@ -0,0 +1,98 @@ +%{ +source $ds9(root)/library/panparser.tab.tcl +%} + +%option noyywrap +%option caseless +%option nodefault +%option nointeractive +#%option stack +%option yylineno +#%option debug + +D [0-9] +E [Ee][+-]?{D}+ + +%% + +close {return $pan::CLOSE_} +open {return $pan::OPEN_} +to {return $pan::TO_} + +wcs {return $pan::WCS_} +wcsa {return $pan::WCSA_} +wcsb {return $pan::WCSB_} +wcsc {return $pan::WCSC_} +wcsd {return $pan::WCSD_} +wcse {return $pan::WCSE_} +wcsf {return $pan::WCSF_} +wcsg {return $pan::WCSG_} +wcsh {return $pan::WCSH_} +wcsi {return $pan::WCSI_} +wcsj {return $pan::WCSJ_} +wcsk {return $pan::WCSK_} +wcsl {return $pan::WCSL_} +wcsm {return $pan::WCSM_} +wcsn {return $pan::WCSN_} +wcso {return $pan::WCSO_} +wcsp {return $pan::WCSP_} +wcsq {return $pan::WCSQ_} +wcsr {return $pan::WCSR_} +wcss {return $pan::WCSS_} +wcst {return $pan::WCST_} +wcsu {return $pan::WCSU_} +wcsv {return $pan::WCSV_} +wcsw {return $pan::WCSW_} +wcsx {return $pan::WCSX_} +wcsy {return $pan::WCSY_} +wcsz {return $pan::WCSZ_} + +image {return $pan::IMAGE_} +physical {return $pan::PHYSICAL_} +amplifier {return $pan::AMPLIFIER_} +detector {return $pan::DETECTOR_} + +fk4 {return $pan::FK4_} +b1950 {return $pan::FK4_} +fk5 {return $pan::FK5_} +j2000 {return $pan::FK5_} +galactic {return $pan::GALACTIC_} +ecliptic {return $pan::ECLIPTIC_} + +# INT +[+-]?{D}+ {set pan::yylval $yytext; return $pan::INT_} + +# REAL +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? {set pan::yylval $yytext; return $pan::REAL_} + +# SEXAGESIMAL +[+-]?{D}+:{D}+:{D}+"."? | +[+-]?{D}+:{D}+:{D}*"."{D}+ {set pan::yylval $yytext; return $pan::SEXSTR_} + +# HMS +[+-]?{D}+h{D}+m{D}+"."?s | +[+-]?{D}+h{D}+m{D}*"."{D}+s {set pan::yylval $yytext; return $pan::HMSSTR_} + +# DMS +[+-]?{D}+d{D}+m{D}+"."?s | +[+-]?{D}+d{D}+m{D}*"."{D}+s {set pan::yylval $yytext; return $pan::SMSSTR_} + +# Quoted STRING +\"[^\"]*\" {set pan::yylval [string range $yytext 1 end-1]; return $pan::STRING_} + +# Quoted STRING +\'[^\']*\' {set pan::yylval [string range $yytext 1 end-1]; return $pan::STRING_} + +# Quoted STRING +\{[^\}]*\} {set pan::yylval [string range $yytext 1 end-1]; return $pan::STRING_} + +# STRING +\S+\S+ {set pan::yylval $yytext; return $pan::STRING_} + +\s # ignore whitespace + +. {set pan::yylval $yytext; return $pan::yylval} + +%% + diff --git a/ds9/parsers/panparser.tac b/ds9/parsers/panparser.tac new file mode 100644 index 0000000..ada0476 --- /dev/null +++ b/ds9/parsers/panparser.tac @@ -0,0 +1,137 @@ +%{ +%} + +%token INT_ +%token REAL_ +%token STRING_ +%token SEXSTR_ + +%start command + +%token CLOSE_ +%token OPEN_ +%token TO_ + +%token IMAGE_ +%token PHYSICAL_ +%token AMPLIFIER_ +%token DETECTOR_ + +%token WCS_ +%token WCSA_ +%token WCSB_ +%token WCSC_ +%token WCSD_ +%token WCSE_ +%token WCSF_ +%token WCSG_ +%token WCSH_ +%token WCSI_ +%token WCSJ_ +%token WCSK_ +%token WCSL_ +%token WCSM_ +%token WCSN_ +%token WCSO_ +%token WCSP_ +%token WCSQ_ +%token WCSR_ +%token WCSS_ +%token WCST_ +%token WCSU_ +%token WCSV_ +%token WCSW_ +%token WCSX_ +%token WCSY_ +%token WCSZ_ + +%token FK4_ +%token FK5_ +%token ICRS_ +%token GALACTIC_ +%token ECLIPTIC_ +%token J2000_ +%token B1950_ + +%% + +command : pan + | pan STRING_ {pan::yyclearin} + ; + +numeric : INT_ {set _ $1} + | REAL_ {set _ $1} + ; + +coordsys : IMAGE_ {set _ image} + | PHYSICAL_ {set _ physical} + | AMPLIFIER_ {set _ amplifier} + | DETECTOR_ {set _ detector} + ; + +wcssys : WCS_ {set _ wcs} + | WCSA_ {set _ wcsa} + | WCSB_ {set _ wcsb} + | WCSC_ {set _ wcsc} + | WCSD_ {set _ wcsd} + | WCSE_ {set _ wcse} + | WCSF_ {set _ wcsf} + | WCSG_ {set _ wcsg} + | WCSH_ {set _ wcsh} + | WCSI_ {set _ wcsi} + | WCSJ_ {set _ wcsj} + | WCSK_ {set _ wcsk} + | WCSL_ {set _ wcsl} + | WCSM_ {set _ wcsm} + | WCSN_ {set _ wcsn} + | WCSO_ {set _ wcso} + | WCSP_ {set _ wcsp} + | WCSQ_ {set _ wcsq} + | WCSR_ {set _ wcsr} + | WCSS_ {set _ wcss} + | WCST_ {set _ wcst} + | WCSU_ {set _ wcsu} + | WCSV_ {set _ wcsv} + | WCSW_ {set _ wcsw} + | WCSX_ {set _ wcsx} + | WCSY_ {set _ wcsy} + | WCSZ_ {set _ wcsz} + ; + +skyframe : FK4_ {set _ fk4} + | B1950_ {set _ fk4} + | FK5_ {set _ fk5} + | J2000_ {set _ fk5} + | ICRS_ {set _ icrs} + | GALACTIC_ {set _ galactic} + | ECLIPTIC_ {set _ ecliptic} + ; + +coord : numeric numeric {set pan::yy(x) $1; set pan::yy(y) $2} + ; + +skycoord : numeric numeric {set pan::yy(x) $1; set pan::yy(y) $2} + | SEXSTR_ SEXSTR_ {set pan::yy(x) $1; set pan::yy(y) $2} + ; + +pan : {} + | OPEN_ {PanZoomDialog} + | CLOSE_ {PanZoomDestroyDialog} + | TO_ panTo + | coord + | coord coordsys + | skycoord wcssys + | skycoord wcssys skyframe + | skycoord skyframe + ; + +panTo : {} + ; + +%% + +proc pan::yyerror {msg} { + puts stderr "$msg:" + puts stderr "$pan::yy_current_buffer" + puts stderr [format "%*s" $pan::index_ ^] +} diff --git a/ds9/parsers/zoomparser.tac b/ds9/parsers/zoomparser.tac index 3cdc132..7328e34 100644 --- a/ds9/parsers/zoomparser.tac +++ b/ds9/parsers/zoomparser.tac @@ -20,6 +20,10 @@ command : zoom | zoom STRING_ {zoom::yyclearin} ; +numeric : INT_ {set _ $1} + | REAL_ {set _ $1} + ; + zoom : numeric {Zoom $1 $1} | numeric numeric {Zoom $1 $2} | OPEN_ {PanZoomDialog} @@ -34,10 +38,6 @@ zoomTo: FIT_ {ZoomToFit} | numeric numeric {global zoom; set current(zoom) "$1 $2"; ChangeZoom} ; -numeric : INT_ {set _ $1} - | REAL_ {set _ $1} - ; - %% proc zoom::yyerror {msg} { |