diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2018-02-24 19:21:53 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2018-02-24 19:21:53 (GMT) |
commit | 9bfe0e4b83c2b315ead079a9e6c746173878f0af (patch) | |
tree | b27da73b31fb3726391576b43970ba43bdf8dfc0 /ds9/library | |
parent | 64443ae4af0357574ac3108258ac0f315e2a3bc9 (diff) | |
download | blt-9bfe0e4b83c2b315ead079a9e6c746173878f0af.zip blt-9bfe0e4b83c2b315ead079a9e6c746173878f0af.tar.gz blt-9bfe0e4b83c2b315ead079a9e6c746173878f0af.tar.bz2 |
add support for namespaces
Diffstat (limited to 'ds9/library')
-rw-r--r-- | ds9/library/command.tcl | 24 | ||||
-rw-r--r-- | ds9/library/lex.fcl | 10 | ||||
-rw-r--r-- | ds9/library/parser.tac | 44 |
3 files changed, 42 insertions, 36 deletions
diff --git a/ds9/library/command.tcl b/ds9/library/command.tcl index 26d9b14..63395d0 100644 --- a/ds9/library/command.tcl +++ b/ds9/library/command.tcl @@ -96,13 +96,6 @@ proc ProcessCommand {argv argc} { while {$i < $argc} { set item [lindex $argv $i] switch -- $item { - -foo { - puts "argc: $argc" - yy::YY_FLUSH_BUFFER - yy::yy_scan_string [string range $argv $i end] - yy::yyparse - set argc 0 - } -- {set noopts 1} -? - -help - @@ -457,7 +450,22 @@ proc ProcessCommand {argv argc} { } -zscale {incr i; ProcessZScaleCmd argv i} -zmax {set scale(mode) zmax; ChangeScaleMode} - -zoom {incr i; ProcessZoomCmd argv i} + -zoom { + incr i; + puts "***b: $i [lrange $argv $i end]***" +# ProcessZoomCmd argv i + + if {1} { + puts "start: $i out of $argc" + yy::YY_FLUSH_BUFFER + yy::yy_scan_string [lrange $argv $i end] + yy::yyparse + puts "found $yy::yycnt" + set cnt [expr $yy::yycnt-1] + incr i $cnt + puts "***a: $i [lrange $argv $i end]***" + } + } default { # allow abc, -, and -[foo] but not -abc diff --git a/ds9/library/lex.fcl b/ds9/library/lex.fcl index f5d25a3..3a5c6e6 100644 --- a/ds9/library/lex.fcl +++ b/ds9/library/lex.fcl @@ -6,7 +6,7 @@ source $ds9(root)/library/parser.tab.tcl %option caseless %option nodefault %option nointeractive -%option stack +#%option stack #%option debug D [0-9] @@ -14,9 +14,11 @@ E [Ee][+-]?{D}+ %% --foo {return $yy::FOOCMD_} --bar {return $yy::BARCMD_} - +close {return $yy::CLOSE_} +in {return $yy::IN_} +fit {return $yy::FIT_} +open {return $yy::OPEN_} +out {return $yy::OUT_} to {return $yy::TO_} # INT diff --git a/ds9/library/parser.tac b/ds9/library/parser.tac index a5c5b77..bf92271 100644 --- a/ds9/library/parser.tac +++ b/ds9/library/parser.tac @@ -5,46 +5,42 @@ %token REAL_ %token STRING_ -%token FOOCMD_ -%token BARCMD_ +%start command +%token CLOSE_ +%token IN_ +%token FIT_ +%token OPEN_ +%token OUT_ %token TO_ %% -commands : commands command - | command +command : {ProcessRealizeDS9} zoom ; -command : FOOCMD_ foo - | BARCMD_ bar +zoom : numeric {Zoom $1 $1} + | numeric numeric {Zoom $1 $2} + | OPEN_ {PanZoomDialog} + | CLOSE_ {PanZoomDestroyDialog} + | IN_ {Zoom 2 2} + | OUT_ {Zoom .5 .5} + | TO_ zoomTo ; -int : INT_ {set _ $1} +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} +numeric : INT_ {set _ $1} | REAL_ {set _ $1} ; -foo : STRING_ {puts "FOO STRING $1"} - | INT_ {puts "FOO INT $1"} - | REAL_ {puts "FOO REAL $1"} - | TO_ fooTo - ; - -fooTo: STRING_ {puts "FOO TO STRING $1"} - | numeric {puts "FOO TO NUMERIC $1"} - ; - -bar : #ANY_ {puts "BAR ANY $1} - | INT_ {puts "BAR INT $1"} - ; - %% -proc yy::yyerror {s} { - puts stderr "parse error:" +proc yy::yyerror {msg} { + puts stderr "$msg:" puts stderr "$yy::yy_buffer" puts stderr [format "%*s" $yy::yy_index ^] } |