summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-05-11 17:39:25 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-05-11 17:39:25 (GMT)
commitd51c41654a715f539154ec29fe1603a07dbcec58 (patch)
tree0d70c49ac862ccdce03e40ac2ada18679b0c5b2d
parent92fc6a10347cc38b62c621728ed33aa267dcc75b (diff)
downloadblt-d51c41654a715f539154ec29fe1603a07dbcec58.zip
blt-d51c41654a715f539154ec29fe1603a07dbcec58.tar.gz
blt-d51c41654a715f539154ec29fe1603a07dbcec58.tar.bz2
add ds9 movie parser
-rw-r--r--ds9/library/movie.tcl20
-rw-r--r--ds9/library/source.tcl2
-rw-r--r--ds9/parsers/movielex.fcl26
-rw-r--r--ds9/parsers/movieparser.tac60
4 files changed, 106 insertions, 2 deletions
diff --git a/ds9/library/movie.tcl b/ds9/library/movie.tcl
index 1036199..a6d33c0 100644
--- a/ds9/library/movie.tcl
+++ b/ds9/library/movie.tcl
@@ -456,12 +456,19 @@ proc ProcessMovieCmd {varname iname} {
upvar $varname var
upvar $iname i
- global movie
-
# we need to be realized
# already implemented
# ProcessRealizeDS9
+ global debug
+ if {$debug(tcl,parser)} {
+ movie::YY_FLUSH_BUFFER
+ movie::yy_scan_string [lrange $var $i end]
+ movie::yyparse
+ incr i [expr $movie::yycnt-1]
+ } else {
+
+ global movie
set item [string tolower [lindex $var $i]]
switch -- $item {
slice -
@@ -530,5 +537,14 @@ proc ProcessMovieCmd {varname iname} {
Movie $fn
}
+}
+
+proc MovieCmdSet {which value {cmd {}}} {
+ global movie
+ set movie($which) $value
+ if {$cmd != {}} {
+ eval $cmd
+ }
+}
diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl
index e750ddb..236441f 100644
--- a/ds9/library/source.tcl
+++ b/ds9/library/source.tcl
@@ -266,6 +266,8 @@ source $ds9(root)/library/mosaicimagewcsparser.tcl
source $ds9(root)/library/mosaicimagewcslex.tcl
source $ds9(root)/library/mosaicimagewfpc2parser.tcl
source $ds9(root)/library/mosaicimagewfpc2lex.tcl
+source $ds9(root)/library/movieparser.tcl
+source $ds9(root)/library/movielex.tcl
source $ds9(root)/library/multiframeparser.tcl
source $ds9(root)/library/multiframelex.tcl
source $ds9(root)/library/nanparser.tcl
diff --git a/ds9/parsers/movielex.fcl b/ds9/parsers/movielex.fcl
new file mode 100644
index 0000000..ce77dc7
--- /dev/null
+++ b/ds9/parsers/movielex.fcl
@@ -0,0 +1,26 @@
+#tab movieparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+3d {return $3D_}
+azfrom {return $AZFROM_}
+azto {return $AZTO_}
+elfrom {return $ELFROM_}
+elto {return $ELTO_}
+frame {return $FRAME_}
+number {return $NUMBER_}
+oscillate {return $OSCILLATE_}
+repeat {return $REPEAT_}
+slice {return $SLICE_}
+slfrom {return $SLFROM_}
+slto {return $SLTO_}
+
+#include numeric.fin
+#include string.fin
+
+%%
diff --git a/ds9/parsers/movieparser.tac b/ds9/parsers/movieparser.tac
new file mode 100644
index 0000000..f8e3a96
--- /dev/null
+++ b/ds9/parsers/movieparser.tac
@@ -0,0 +1,60 @@
+%{
+%}
+
+#include numeric.tin
+#include string.tin
+
+%start command
+
+%token 3D_
+%token AZFROM_
+%token AZTO_
+%token ELFROM_
+%token ELTO_
+%token FRAME_
+%token NUMBER_
+%token OSCILLATE_
+%token REPEAT_
+%token SLICE_
+%token SLFROM_
+%token SLTO_
+
+%%
+
+#include numeric.trl
+
+command : movie
+ | movie {yyclearin; YYACCEPT} STRING_
+ ;
+
+movie : STRING_ {MovieCmdSet action frame; Movie $1}
+ | FRAME_ STRING_ {MovieCmdSet action frame; Movie $2}
+ | SLICE_ STRING_ {MovieCmdSet action slice; Movie $2}
+ | 3D_ STRING_ {MovieCmdSet action 3d; Movie $2}
+ | 3D_ STRING_ opts {MovieCmdSet action 3d; Movie $2}
+ ;
+
+opts : opts opt
+ | opt
+ ;
+
+opt : NUMBER_ INT_ {MovieCmdSet number $2}
+ | AZFROM_ numeric {MovieCmdSet azfrom $2}
+ | AZTO_ numeric {MovieCmdSet azto $2}
+ | ELFROM_ numeric {MovieCmdSet elfrom $2}
+ | ELTO_ numeric {MovieCmdSet elto $2}
+ | SLFROM_ INT_ {MovieCmdSet slfrom $2}
+ | SLTO_ INT_ {MovieCmdSet slto $2}
+ | OSCILLATE_ INT_ {MovieCmdSet repeat oscillate; MovieCmdSet repeat,num $2}
+ | REPEAT_ INT_ {MovieCmdSet repeat repeat; MovieCmdSet repeat,num $2}
+ ;
+
+%%
+
+proc movie::yyerror {msg} {
+ variable yycnt
+ variable yy_current_buffer
+ variable index_
+
+ ParserError $msg $yycnt $yy_current_buffer $index_
+}