summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ds9/library/command.tcl10
-rw-r--r--ds9/library/lex.fcl27
-rw-r--r--ds9/library/parser.tac29
-rw-r--r--ds9/make.include2
-rw-r--r--fickle/fickle.tcl71
5 files changed, 71 insertions, 68 deletions
diff --git a/ds9/library/command.tcl b/ds9/library/command.tcl
index 71462dd..d728953 100644
--- a/ds9/library/command.tcl
+++ b/ds9/library/command.tcl
@@ -97,15 +97,11 @@ proc ProcessCommand {argv argc} {
set item [lindex $argv $i]
switch -- $item {
-foo {
- YY_FLUSH_BUFFER
- yy_scan_string $argv
+ yy::YY_FLUSH_BUFFER
+ yy::yy_scan_string $argv
yyparse
set argc 0
}
-# YY_FLUSH_BUFFER
-# yy_scan_string $argv
-# yyparse
-
-- {set noopts 1}
-? -
-help -
@@ -175,7 +171,7 @@ proc ProcessCommand {argv argc} {
-geometry {
# already processed
}
-p -gif {set file(type) gif}
+ -gif {set file(type) gif}
-green {set current(rgb) green; RGBChannel}
-grid {incr i; ProcessGridCmd argv i}
-nogrid {set grid(view) 0; GridUpdateCurrent}
diff --git a/ds9/library/lex.fcl b/ds9/library/lex.fcl
index 625aaca..63c3437 100644
--- a/ds9/library/lex.fcl
+++ b/ds9/library/lex.fcl
@@ -9,40 +9,37 @@ source $ds9(root)/library/parser.tab.tcl
%option stack
%option debug
-%s CMD
-
D [0-9]
E [Ee][+-]?{D}+
%%
--foo {return $::FOOCMD_}
+-foo {return $yy::FOOCMD_}
+-exit {return $yy::EXITCMD_}
-close {return $::CLOSE_}
-fit {return $::FIT_}
-in {return $::IN_}
-open {return $::OPEN_}
-out {return $::OUT_}
-to {return $::TO_}
+close {return $yy::CLOSE_}
+fit {return $yy::FIT_}
+open {return $yy::OPEN_}
+to {return $yy::TO_}
# INT
-[+-]?{D}+ {set ::yylval $yytext; return $::INT_}
+[+-]?{D}+ {set ::yylval $yytext; return $yy::INT_}
# REAL
[+-]?{D}+"."?({E})? |
-[+-]?{D}*"."{D}+({E})? {set ::yylval $yytext; return $::REAL_}
+[+-]?{D}*"."{D}+({E})? {set ::yylval $yytext; return $yy::REAL_}
# Quoted STRING
-\"[^\"]*\" {set ::yylval [string range $yytext 1 end-1]; return $::STRING_}
+\"[^\"]*\" {set ::yylval [string range $yytext 1 end-1]; return $yy::STRING_}
# Quoted STRING
-\'[^\']*\' {set ::yylval [string range $yytext 1 end-1]; return $::STRING_}
+\'[^\']*\' {set ::yylval [string range $yytext 1 end-1]; return $yy::STRING_}
# Quoted STRING
-\{[^\}]*\} {set ::yylval [string range $yytext 1 end-1]; return $::STRING_}
+\{[^\}]*\} {set ::yylval [string range $yytext 1 end-1]; return $yy::STRING_}
# STRING
-\S+\S+ {set ::yylval $yytext; return $::STRING_}
+\S+\S+ {set ::yylval $yytext; return $yy::STRING_}
\s # ignore whitespace
diff --git a/ds9/library/parser.tac b/ds9/library/parser.tac
index ac92da2..94da214 100644
--- a/ds9/library/parser.tac
+++ b/ds9/library/parser.tac
@@ -1,5 +1,4 @@
%{
-
%}
%token INT_
@@ -7,12 +6,11 @@
%token STRING_
%token FOOCMD_
+%token EXITCMD_
%token CLOSE_
%token FIT_
-%token IN_
%token OPEN_
-%token OUT_
%token TO_
%%
@@ -24,26 +22,27 @@ commands : commands command
int : INT_ {set _ $1}
;
-command : FOOCMD_ zoom
+command : FOOCMD_ foo
+ | EXITCMD_ exit
;
numeric : int {set _ $1}
| REAL_ {set _ $1}
;
-zoom : STRING_ {puts "ZOOM $1"}
- | numeric {puts "ZOOM $1"}
- | numeric numeric {puts "ZOOM $1 $2"}
- | OPEN_ {puts "ZOOM open"}
- | CLOSE_ {puts "ZOOM close"}
- | IN_ {puts "ZOOM in"}
- | OUT_ {puts "ZOOM out"}
- | TO_ zoomTo
+foo : STRING_ {puts "STRING $1"}
+ | INT_ {puts "INT $1"}
+ | REAL_ {puts "REAL $1"}
+ | OPEN_ {puts "OPEN"}
+ | CLOSE_ {puts "CLOSE"}
+ | TO_ fooTo
+ ;
+
+fooTo: FIT_ {puts "TO FIT"}
+ | numeric {puts "TO NUMERIC $1"}
;
-zoomTo: FIT_ {puts "ZOOM to fit"}
- | numeric {puts "ZOOM to $1"}
- | numeric numeric {puts "ZOOM to $1 $2"}
+exit: {puts "EXIT"; QuitDS9}
;
%%
diff --git a/ds9/make.include b/ds9/make.include
index dcf27d8..59006e5 100644
--- a/ds9/make.include
+++ b/ds9/make.include
@@ -8,7 +8,7 @@
#--------------------------framework
-$(LIBDIR)/library : $(prefix)/ds9/library/parser.tcl $(prefix)/ds9/library/lex.tcl $(prefix)/ds9/library/*.tcl
+$(LIBDIR)/library : $(prefix)/ds9/library/parser.tcl $(prefix)/ds9/library/parser.tab.tcl $(prefix)/ds9/library/lex.tcl $(prefix)/ds9/library/*.tcl
mkdir -p "$@"
cp -p $? "$@"
# must do it this way for win
diff --git a/fickle/fickle.tcl b/fickle/fickle.tcl
index f346cbc..f78f752 100644
--- a/fickle/fickle.tcl
+++ b/fickle/fickle.tcl
@@ -326,6 +326,8 @@ proc write_scanner_utils {} {
puts $::dest "namespace eval ${::p} \{
variable yytext {}
variable yyleng 0
+ variable yy_buffer {}
+ variable yy_index 0
variable yy_done 0
variable yyin stdin
variable yyout stdout"
@@ -372,10 +374,12 @@ proc write_scanner_utils {} {
# -- from the flex(1) man page"
}
puts $::dest "proc ${::p}::YY_FLUSH_BUFFER \{\} \{
+ variable yy_buffer
+ variable yy_index
variable yy_done
- set ::${::p}_buffer \"\"
- set ::${::p}_index 0
+ set yy_buffer \"\"
+ set yy_index 0
set yy_done 0
\}
"
@@ -432,9 +436,10 @@ proc write_scanner_utils {} {
# -- from the flex(1) man page"
}
puts $::dest "proc ${::p}::yy_scan_string \{str\} \{
+ variable yy_buffer
variable yyin
- append ::${::p}_buffer \$str
+ append yy_buffer \$str
set yyin \"\"
\}
"
@@ -444,25 +449,30 @@ proc write_scanner_utils {} {
# -- from the flex(1) man page"
}
puts $::dest "proc ${::p}::yyunput \{c\} \{
- set s \[string range \$::${::p}_buffer 0 \[expr \{\$::${::p}_index - 1\}\]\]
+ variable yy_buffer
+ variable yy_index
+
+ set s \[string range \$yy_buffer 0 \[expr \{\$yy_index - 1\}\]\]
append s \$c
- set ::${::p}_buffer \[append s \[string range \$::${::p}_buffer \$::${::p}_index end\]\]
+ set yy_buffer \[append s \[string range \$yy_buffer \$yy_index end\]\]
\}
"
if $::headers {
puts $::dest "# Returns all but the first n characters of the current token back to
# the input stream, where they will be rescanned when the scanner
-# looks for the next match. yytext and ${::p}leng are adjusted
+# looks for the next match. yytext and yyleng are adjusted
# appropriately.
# -- from the flex(1) man page"
}
puts $::dest "proc ${::p}::yyless \{n\} \{
+ variable yy_buffer
+ variable yy_index
variable yytext
variable yyleng
- set s \[string range \$::${::p}_buffer 0 \[expr \{\$::${::p}_index - 1\}\]\]
+ set s \[string range \$yy_buffer 0 \[expr \{\$yy_index - 1\}\]\]
append s \[string range \$yytext \$n end\]
- set ::${::p}_buffer \[append s \[string range \$::${::p}_buffer \$::${::p}_index end\]\]
+ set yy_buffer \[append s \[string range \$yy_buffer \$yy_index end\]\]
set yytext \[string range \$yytext 0 \[expr \{\$n - 1\}\]\]
set yyleng \[string length \$yytext\]
\}
@@ -472,13 +482,15 @@ proc write_scanner_utils {} {
# -- from the flex(1) man page"
}
puts $::dest "proc ${::p}::yyinput \{\} \{
+ variable yy_buffer
+ variable yy_index
variable yy_done
- if \{\[string length \$::${::p}_buffer\] - \$::${::p}_index < $::BUFFER_SIZE\} \{
+ if \{\[string length \$yy_buffer\] - \$yy_index < $::BUFFER_SIZE\} \{
set new_buffer_size 0
if \{\$yy_done == 0\} \{
YY_INPUT new_buffer new_buffer_size $::BUFFER_SIZE
- append ::${::p}_buffer \$new_buffer
+ append yy_buffer \$new_buffer
if \{\$new_buffer_size == 0\} \{
set yy_done 1
\}
@@ -491,13 +503,13 @@ proc write_scanner_utils {} {
} else {
puts -nonewline $::dest " "
}
- puts $::dest "if \{\[string length \$::${::p}_buffer\] - \$::${::p}_index == 0\} \{
+ puts $::dest "if \{\[string length \$yy_buffer\] - \$yy_index == 0\} \{
return \{\}
\}
\}
\}
- set c \[string index \$::${::p}_buffer \$::${::p}_index\]
- incr ::${::p}_index
+ set c \[string index \$yy_buffer \$yy_index\]
+ incr yy_index
return \$c
\}
"
@@ -549,9 +561,6 @@ proc write_scanner_utils {} {
"
}
- puts $::dest "# initialize values used by the lexer
-set ::${::p}_buffer \{\}
-set ::${::p}_index 0"
if $::startstates {
puts $::dest "set ::${::p}_state_stack \{\}
${::p}::BEGIN INITIAL
@@ -571,7 +580,7 @@ array set ::${::p}_state_table \{[array get ::state_table]\}"
# was given at the command line.
proc write_scanner {} {
puts $::dest "######
-# autogenerated ${::p}lex function created by fickle
+# autogenerated yylex function created by fickle
######
# Whenever yylex() is called, it scans tokens from the global input
@@ -580,6 +589,8 @@ proc write_scanner {} {
# one of its actions executes a return statement.
# -- from the flex(1) man page
proc ${::p}::yylex \{\} \{
+ variable yy_buffer
+ variable yy_index
variable yy_done
variable yytext
variable yyleng
@@ -588,20 +599,20 @@ proc ${::p}::yylex \{\} \{
if $::startstates {
puts $::dest " set ${::p}_current_state \[${::p}::yy_top_state\]"
}
- puts $::dest " if \{\[string length \$::${::p}_buffer\] - \$::${::p}_index < $::BUFFER_SIZE\} \{
+ puts $::dest " if \{\[string length \$yy_buffer\] - \$yy_index < $::BUFFER_SIZE\} \{
if \{\$yy_done == 0\} \{
set ${::p}_new_buffer \"\"
- ${::p}::YY_INPUT ${::p}_new_buffer ${::p}_buffer_size $::BUFFER_SIZE
- append ::${::p}_buffer \$${::p}_new_buffer
+ YY_INPUT ${::p}_new_buffer ${::p}_buffer_size $::BUFFER_SIZE
+ append yy_buffer \$${::p}_new_buffer
if \{\$${::p}_buffer_size == 0 && \\
- \[string length \$::${::p}_buffer\] - \$::${::p}_index == 0\} \{
+ \[string length \$yy_buffer\] - \$yy_index == 0\} \{
set yy_done 1
\}
\}
if \$yy_done \{"
if $::debugmode {
puts $::dest " if \$::${::p}_flex_debug \{
- puts stderr \" --reached end of input buffer\"
+ puts stderr \" ${::p} --reached end of input buffer\"
\}"
}
if $::callyywrap {
@@ -612,7 +623,7 @@ proc ${::p}::yylex \{\} \{
} else {
puts -nonewline $::dest " "
}
- puts $::dest "if \{\[string length \$::${::p}_buffer\] - \$::${::p}_index == 0\} \{
+ puts $::dest "if \{\[string length \$yy_buffer\] - \$yy_index == 0\} \{
break
\}
\}
@@ -640,9 +651,9 @@ proc ${::p}::yylex \{\} \{
puts -nonewline $::dest "\$${::p}_current_state == \"$state_name\" && \\\n "
}
}
- puts $::dest "\[regexp -start \$::${::p}_index -indices -line $scan_args -- \{\\A($pattern)\} \$::${::p}_buffer ${::p}_match\] > 0\ && \\
- \[lindex \$${::p}_match 1\] - \$::${::p}_index + 1 > \$yyleng\} \{
- set yytext \[string range \$::${::p}_buffer \$::${::p}_index \[lindex \$${::p}_match 1\]\]
+ puts $::dest "\[regexp -start \$yy_index -indices -line $scan_args -- \{\\A($pattern)\} \$yy_buffer ${::p}_match\] > 0\ && \\
+ \[lindex \$${::p}_match 1\] - \$yy_index + 1 > \$yyleng\} \{
+ set yytext \[string range \$yy_buffer \$yy_index \[lindex \$${::p}_match 1\]\]
set yyleng \[string length \$yytext\]
set ${::p}_matched_rule $rule_num"
if $::debugmode {
@@ -653,17 +664,17 @@ proc ${::p}::yylex \{\} \{
}
# now add the default case
puts $::dest " if \{\$${::p}_matched_rule == -1\} \{
- set yytext \[string index \$::${::p}_buffer \$::${::p}_index\]
+ set yytext \[string index \$yy_buffer \$yy_index\]
set yyleng 1"
if $::debugmode {
puts $::dest " set ${::p}rule_num \"default rule\""
}
puts $::dest " \}
- incr ::${::p}_index \$yyleng
+ incr yy_index \$yyleng
# workaround for Tcl's circumflex behavior
if \{\[string index \$yytext end\] == \"\\n\"\} \{
- set ::${::p}_buffer \[string range \$::${::p}_buffer \$::${::p}_index end\]
- set ::${::p}_index 0
+ set yy_buffer \[string range \$yy_buffer \$yy_index end\]
+ set yy_index 0
\}"
if $::debugmode {
puts $::dest " if \$::${::p}_flex_debug \{