summaryrefslogtreecommitdiffstats
path: root/ds9
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-05-17 18:14:32 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-05-17 18:14:32 (GMT)
commitfe9e2f84b0be4fe156e2e2945c1b24acc3afc074 (patch)
tree8585d5401906ee60493487cd5ef66f6f28e870f8 /ds9
parent59df5db3b995a8af29721dda14dad28e99307913 (diff)
downloadblt-fe9e2f84b0be4fe156e2e2945c1b24acc3afc074.zip
blt-fe9e2f84b0be4fe156e2e2945c1b24acc3afc074.tar.gz
blt-fe9e2f84b0be4fe156e2e2945c1b24acc3afc074.tar.bz2
add ds9 fits parser
Diffstat (limited to 'ds9')
-rw-r--r--ds9/library/fits.tcl35
-rw-r--r--ds9/library/source.tcl2
-rw-r--r--ds9/parsers/fitslex.fcl16
-rw-r--r--ds9/parsers/fitsparser.tac37
4 files changed, 87 insertions, 3 deletions
diff --git a/ds9/library/fits.tcl b/ds9/library/fits.tcl
index 6ceb311..36548cd 100644
--- a/ds9/library/fits.tcl
+++ b/ds9/library/fits.tcl
@@ -107,12 +107,20 @@ proc ProcessFitsCmd {varname iname sock fn} {
return
}
- global loadParam
- global current
+ global debug
+ if {$debug(tcl,parser)} {
+ global parse
+ set parse(sock) $sock
+ set parse(fn) $fn
+
+ fits::YY_FLUSH_BUFFER
+ fits::yy_scan_string [lrange $var $i end]
+ fits::yyparse
+ incr i [expr $fits::yycnt-1]
+ } else {
set layer {}
set mode {}
-
switch -- [string tolower [lindex $var $i]] {
new {
incr i
@@ -145,6 +153,27 @@ proc ProcessFitsCmd {varname iname sock fn} {
}
FinishLoad
}
+}
+
+proc FitsCmdLoad {param layer mode} {
+ global parse
+
+ if {$parse(sock) != {}} {
+ # xpa
+ if {![LoadFitsSocket $parse(sock) $param $layer $mode]} {
+ InitError xpa
+ LoadFitsFile $param $layer $mode
+ }
+ } else {
+ # comm
+ if {$parse(fn) != {}} {
+ LoadFitsAlloc $parse(fn) $param $layer $mode
+ } else {
+ LoadFitsFile $param $layer $mode
+ }
+ }
+ FinishLoad
+}
proc ProcessSendFitsCmd {proc id param sock fn} {
global current
diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl
index 26c60f2..2e72c37 100644
--- a/ds9/library/source.tcl
+++ b/ds9/library/source.tcl
@@ -230,6 +230,8 @@ source $ds9(root)/library/enviparser.tcl
source $ds9(root)/library/envilex.tcl
source $ds9(root)/library/exportparser.tcl
source $ds9(root)/library/exportlex.tcl
+source $ds9(root)/library/fitsparser.tcl
+source $ds9(root)/library/fitslex.tcl
source $ds9(root)/library/frameparser.tcl
source $ds9(root)/library/framelex.tcl
source $ds9(root)/library/gridparser.tcl
diff --git a/ds9/parsers/fitslex.fcl b/ds9/parsers/fitslex.fcl
new file mode 100644
index 0000000..c23f70e
--- /dev/null
+++ b/ds9/parsers/fitslex.fcl
@@ -0,0 +1,16 @@
+#tab fitsparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+mask {return $MASK_}
+new {return $NEW_}
+slice {return $SLICE_}
+
+#include string.fin
+
+%%
diff --git a/ds9/parsers/fitsparser.tac b/ds9/parsers/fitsparser.tac
new file mode 100644
index 0000000..d9e27ca
--- /dev/null
+++ b/ds9/parsers/fitsparser.tac
@@ -0,0 +1,37 @@
+%{
+%}
+
+#include string.tin
+
+%start command
+
+%token MASK_
+%token NEW_
+%token SLICE_
+
+%%
+
+# XPA/SAMP only
+command : fits
+ ;
+
+fits: NEW_ {CreateFrame; FitsCmdLoad {} {} {}}
+ | new STRING_ {FitsCmdLoad $2 {} {}}
+ | new MASK_ STRING_ {FitsCmdLoad $3 mask {}}
+ | new SLICE_ STRING_ {FitsCmdLoad $3 {} slice}
+ | new MASK_ SLICE_ STRING_ {FitsCmdLoad $4 mask slice}
+;
+
+new :
+ | NEW_ {CreateFrame}
+ ;
+
+%%
+
+proc fits::yyerror {msg} {
+ variable yycnt
+ variable yy_current_buffer
+ variable index_
+
+ ParserError $msg $yycnt $yy_current_buffer $index_
+}