summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ds9/library/samp.tcl50
-rw-r--r--ds9/library/source.tcl2
-rw-r--r--ds9/parsers/blinkparser.tac10
-rw-r--r--ds9/parsers/samplex.fcl20
-rw-r--r--ds9/parsers/sampparser.tac50
-rw-r--r--ds9/parsers/tileparser.tac10
-rw-r--r--ds9/parsers/yesno.trl9
7 files changed, 127 insertions, 24 deletions
diff --git a/ds9/library/samp.tcl b/ds9/library/samp.tcl
index e486257..9af0e1d 100644
--- a/ds9/library/samp.tcl
+++ b/ds9/library/samp.tcl
@@ -1705,15 +1705,22 @@ proc ProcessSAMPCmd {varname iname} {
upvar $varname var
upvar $iname i
- global samp
- global ds9
- global env
-
# we need to be realized
ProcessRealizeDS9
SAMPUpdate
+ global debug
+ if {$debug(tcl,parser)} {
+ samp::YY_FLUSH_BUFFER
+ samp::yy_scan_string [lrange $var $i end]
+ samp::yyparse
+ incr i [expr $samp::yycnt-1]
+ } else {
+
+ global samp
+ global ds9
+ global env
switch -- [string tolower [lindex $var $i]] {
send {
incr i
@@ -1789,3 +1796,38 @@ proc ProcessSAMPCmd {varname iname} {
}
}
}
+}
+
+proc SAMPCmdSendImage {name} {
+ global samp
+
+ if {[info exists samp]} {
+ foreach arg $samp(apps,image) {
+ foreach {key val} $arg {
+ if {[string tolower $val] == $name} {
+ SAMPSendImageLoadFits $key
+ break
+ }
+ }
+ }
+ } else {
+ Error "SAMP: [msgcat::mc {not connected}]"
+ }
+}
+
+proc SAMPCmdSendTable {name} {
+ global samp
+
+ if {[info exists samp]} {
+ foreach arg $samp(apps,table) {
+ foreach {key val} $arg {
+ if {[string tolower $val] == $name} {
+ SAMPSendTableLoadFits $key
+ break
+ }
+ }
+ }
+ } else {
+ Error "SAMP: [msgcat::mc {not connected}]"
+ }
+}
diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl
index d503984..fc00f74 100644
--- a/ds9/library/source.tcl
+++ b/ds9/library/source.tcl
@@ -278,6 +278,8 @@ source $ds9(root)/library/regionparser.tcl
source $ds9(root)/library/regionlex.tcl
source $ds9(root)/library/rgbparser.tcl
source $ds9(root)/library/rgblex.tcl
+source $ds9(root)/library/sampparser.tcl
+source $ds9(root)/library/samplex.tcl
source $ds9(root)/library/saveparser.tcl
source $ds9(root)/library/savelex.tcl
source $ds9(root)/library/saveimageparser.tcl
diff --git a/ds9/parsers/blinkparser.tac b/ds9/parsers/blinkparser.tac
index 370535e..48f34a2 100644
--- a/ds9/parsers/blinkparser.tac
+++ b/ds9/parsers/blinkparser.tac
@@ -14,16 +14,6 @@
#include yesno.trl
#include numeric.trl
-yes : YES_ {set _ 1}
- | ON_ {set _ 1}
- | TRUE_ {set _ 1}
- ;
-
-no : NO_ {set _ 0}
- | OFF_ {set _ 0}
- | FALSE_ {set _ 0}
- ;
-
command : blink
| blink {yyclearin; YYACCEPT} STRING_
;
diff --git a/ds9/parsers/samplex.fcl b/ds9/parsers/samplex.fcl
new file mode 100644
index 0000000..7d4d16d
--- /dev/null
+++ b/ds9/parsers/samplex.fcl
@@ -0,0 +1,20 @@
+#tab sampparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+broadcast {return $BROADCAST_}
+connect {return $CONNECT_}
+disconnect {return $DISCONNECT_}
+image {return $IMAGE_}
+send {return $SEND_}
+table {return $TABLE_}
+
+#include yesno.fin
+#include string.fin
+
+%%
diff --git a/ds9/parsers/sampparser.tac b/ds9/parsers/sampparser.tac
new file mode 100644
index 0000000..2c3d4ba
--- /dev/null
+++ b/ds9/parsers/sampparser.tac
@@ -0,0 +1,50 @@
+%{
+%}
+
+#include yesno.tin
+#include string.tin
+
+%start command
+
+%token BROADCAST_
+%token CONNECT_
+%token DISCONNECT_
+%token IMAGE_
+%token SEND_
+%token TABLE_
+
+%%
+
+#include yesno.trl
+
+command : samp
+ | samp {yyclearin; YYACCEPT} STRING_
+ ;
+
+samp : yes {SAMPConnect}
+ | no {SAMPDisconnect}
+ | CONNECT_ {SAMPConnect}
+ | DISCONNECT_ {SAMPDisconnect}
+ | BROADCAST_ broadcast
+ | SEND_ send
+ ;
+
+broadcast : {SAMPSendImageLoadFits {}}
+ | IMAGE_ {SAMPSendImageLoadFits {}}
+ | TABLE_ {SAMPSendTableLoadFits {}}
+ ;
+
+send : STRING_ {SAMPCmdSendImage $1}
+ | IMAGE_ STRING_ {SAMPCmdSendImage $2}
+ | TABLE_ STRING_ {SAMPCmdSendTable $2}
+ ;
+
+%%
+
+proc samp::yyerror {msg} {
+ variable yycnt
+ variable yy_current_buffer
+ variable index_
+
+ ParserError $msg $yycnt $yy_current_buffer $index_
+}
diff --git a/ds9/parsers/tileparser.tac b/ds9/parsers/tileparser.tac
index 0f2e453..a0f8690 100644
--- a/ds9/parsers/tileparser.tac
+++ b/ds9/parsers/tileparser.tac
@@ -22,16 +22,6 @@
#include yesno.trl
#include numeric.trl
-yes : YES_ {set _ 1}
- | ON_ {set _ 1}
- | TRUE_ {set _ 1}
- ;
-
-no : NO_ {set _ 0}
- | OFF_ {set _ 0}
- | FALSE_ {set _ 0}
- ;
-
command : tile
| tile {yyclearin; YYACCEPT} STRING_
;
diff --git a/ds9/parsers/yesno.trl b/ds9/parsers/yesno.trl
index a34d258..bee9006 100644
--- a/ds9/parsers/yesno.trl
+++ b/ds9/parsers/yesno.trl
@@ -12,3 +12,12 @@ yesno : {set _ 1}
# YYABORT
# }
+yes : YES_ {set _ 1}
+ | ON_ {set _ 1}
+ | TRUE_ {set _ 1}
+ ;
+
+no : NO_ {set _ 0}
+ | OFF_ {set _ 0}
+ | FALSE_ {set _ 0}
+ ;