summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ds9/library/command.tcl24
-rw-r--r--ds9/library/lex.fcl10
-rw-r--r--ds9/library/parser.tac44
-rw-r--r--fickle/fickle.tcl63
-rw-r--r--taccle/taccle.tcl13
5 files changed, 103 insertions, 51 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 ^]
}
diff --git a/fickle/fickle.tcl b/fickle/fickle.tcl
index e68396d..574aef7 100644
--- a/fickle/fickle.tcl
+++ b/fickle/fickle.tcl
@@ -4,6 +4,37 @@
set FICKLE_VERSION 2.1
+# no output()
+# no yymore()
+# no REJECT
+
+# input() ok
+# unput() ok
+# yyless() ok
+# yywrap() ok
+
+# yytext ok
+# yylineno ok
+# yyleng ok
+# yyin ok
+# yyout ok
+
+# BEGIN ok
+# ECHO ok
+# YY_INPUT ok
+
+# unknown
+# YY_FLUSH_BUFFER()
+# yyrestart()
+# yy_scan_string()
+
+# yy_buffer
+# yy_index
+# yy_done
+# yy_flex_debug
+# yy_state_stack
+# yy_state_table
+
#//#
# Fickle is a lexical analyzer generator written in pure Tcl. It
# reads a <em>fickle specification file</em> to generate pure Tcl code
@@ -326,11 +357,12 @@ proc write_scanner_utils {} {
puts $::dest "namespace eval ${::p} \{
variable yytext {}
variable yyleng 0
+ variable yyin stdin
+ variable yyout stdout
+
variable yy_buffer {}
variable yy_index 0
- variable yy_done 0
- variable yyin stdin
- variable yyout stdout"
+ variable yy_done 0"
if $::debugmode {
puts $::dest "
variable yy_flex_debug 1"
@@ -458,11 +490,11 @@ proc write_scanner_utils {} {
\}
"
if $::headers {
- puts $::dest "# yyunput(c) puts the character c back onto the input stream. It will
+ puts $::dest "# unput(c) puts the character c back onto the input stream. It will
# be the next character scanned.
# -- from the flex(1) man page"
}
- puts $::dest "proc ${::p}::yyunput \{c\} \{
+ puts $::dest "proc ${::p}::unput \{c\} \{
variable yy_buffer
variable yy_index
@@ -495,7 +527,7 @@ proc write_scanner_utils {} {
puts $::dest "# input() reads the next character from the input stream.
# -- from the flex(1) man page"
}
- puts $::dest "proc ${::p}::yyinput \{\} \{
+ puts $::dest "proc ${::p}::input \{\} \{
variable yy_buffer
variable yy_index
variable yy_done
@@ -513,7 +545,7 @@ proc write_scanner_utils {} {
if \$yy_done \{"
if $::callyywrap {
puts -nonewline $::dest " if \{\[yywrap\] == 0\} \{
- return \[yyinput\]
+ return \[input\]
\} else"
} else {
puts -nonewline $::dest " "
@@ -535,7 +567,7 @@ proc write_scanner_utils {} {
# BEGIN new_state.
# -- from the flex(1) man page"
}
- puts $::dest "proc ${::p}::yy_push_state \{new_state\} \{
+ puts $::dest "proc ${::p}::push_state \{new_state\} \{
variable yy_state_stack
lappend yy_state_stack \$new_state
@@ -546,12 +578,12 @@ proc write_scanner_utils {} {
# pushes the state \"INITIAL\".
# -- from the flex(1) man page"
}
- puts $::dest "proc ${::p}::yy_pop_state \{\} \{
+ puts $::dest "proc ${::p}::pop_state \{\} \{
variable yy_state_stack
set yy_state_stack \[lrange \$yy_state_stack 0 end-1\]
if \{\$yy_state_stack == \"\"\} \{
- yy_push_state INITIAL
+ push_state INITIAL
\}
\}
"
@@ -559,7 +591,7 @@ proc write_scanner_utils {} {
puts $::dest "# Returns the top of the stack without altering the stack's contents.
# -- from the flex(1) man page"
}
- puts $::dest "proc ${::p}::yy_top_state \{\} \{
+ puts $::dest "proc ${::p}::top_state \{\} \{
variable yy_state_stack
return \[lindex \$yy_state_stack end\]
@@ -604,18 +636,19 @@ proc write_scanner {} {
# one of its actions executes a return statement.
# -- from the flex(1) man page
proc ${::p}::yylex \{\} \{
+ variable yytext
+ variable yylineno
+ variable yyleng
+
variable yy_buffer
variable yy_index
variable yy_done
- variable yytext
- variable yyleng
variable yy_flex_debug
variable yy_state_table
- variable yylineno
while \{1\} \{"
if $::startstates {
- puts $::dest " set yy_current_state \[yy_top_state\]"
+ puts $::dest " set yy_current_state \[top_state\]"
}
puts $::dest " if \{\[string length \$yy_buffer\] - \$yy_index < $::BUFFER_SIZE\} \{
if \{\$yy_done == 0\} \{
diff --git a/taccle/taccle.tcl b/taccle/taccle.tcl
index e3d11fe..b2e67b3 100644
--- a/taccle/taccle.tcl
+++ b/taccle/taccle.tcl
@@ -4,6 +4,12 @@
set TACCLE_VERSION 1.2
+# no yydebug
+# no YYDEBUG
+# no yyerrok
+# no YYERROR
+# no YYRECOVERING
+
#//#
# Taccle is another compiler compiler written in pure Tcl. reads a
# <em>taccle specification file</em> to generate pure Tcl code that
@@ -837,6 +843,7 @@ namespace eval ${::p} \{
variable table
variable rules
variable token {}
+ variable yycnt 0
namespace export yylex
\}
@@ -851,7 +858,9 @@ proc ${::p}::YYACCEPT \{\} \{
proc ${::p}::yyclearin \{\} \{
variable token
+ variable yycnt
set token {}
+ incr yycnt -1
\}
proc ${::p}::yyerror \{s\} \{
@@ -889,6 +898,7 @@ proc write_parser {} {
variable table
variable rules
variable token
+ variable yycnt
set state_stack {0}
set value_stack {{}}
@@ -901,6 +911,9 @@ proc write_parser {} {
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