summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ds9/library/lex.fcl7
-rw-r--r--fickle/fickle.tcl17
2 files changed, 14 insertions, 10 deletions
diff --git a/ds9/library/lex.fcl b/ds9/library/lex.fcl
index 7e37754..fe661be 100644
--- a/ds9/library/lex.fcl
+++ b/ds9/library/lex.fcl
@@ -10,13 +10,16 @@ source $ds9(root)/library/parser.tab.tcl
%option yylineno
%option debug
+%x FOO
+%s BAR
+
D [0-9]
E [Ee][+-]?{D}+
%%
-close {return $yy::CLOSE_}
-in {return $yy::IN_}
+<FOO>close {return $yy::CLOSE_}
+<BAR>in {return $yy::IN_}
fit {return $yy::FIT_}
open {return $yy::OPEN_}
out {return $yy::OUT_}
diff --git a/fickle/fickle.tcl b/fickle/fickle.tcl
index 0a8ec26..ac97612 100644
--- a/fickle/fickle.tcl
+++ b/fickle/fickle.tcl
@@ -543,7 +543,7 @@ proc write_scanner_utils {} {
# BEGIN new_state.
# -- from the flex(1) man page"
}
- puts $::dest "proc ${::p}::push_state \{new_state\} \{
+ puts $::dest "proc ${::p}::yy_push_state \{new_state\} \{
variable state_stack_
lappend state_stack_ \$new_state
@@ -554,12 +554,12 @@ proc write_scanner_utils {} {
# pushes the state \"INITIAL\".
# -- from the flex(1) man page"
}
- puts $::dest "proc ${::p}::pop_state \{\} \{
+ puts $::dest "proc ${::p}::yy_pop_state \{\} \{
variable state_stack_
set state_stack_ \[lrange \$state_stack_ 0 end-1\]
if \{\$state_stack_ == \"\"\} \{
- push_state INITIAL
+ yy_push_state INITIAL
\}
\}
"
@@ -567,7 +567,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}::top_state \{\} \{
+ puts $::dest "proc ${::p}::yy_top_state \{\} \{
variable state_stack_
return \[lindex \$state_stack_ end\]
@@ -624,7 +624,7 @@ proc ${::p}::yylex \{\} \{
while \{1\} \{"
if $::startstates {
- puts $::dest " set current_state \[top_state\]"
+ puts $::dest " set yy_current_state \[yy_top_state\]"
}
puts $::dest " if \{\[string length \$yy_current_buffer\] - \$index_ < $::BUFFER_SIZE\} \{
if \{\$done_ == 0\} \{
@@ -674,9 +674,9 @@ proc ${::p}::yylex \{\} \{
puts -nonewline $::dest " if \{"
if $::startstates {
if {$state_name == ""} {
- puts -nonewline $::dest "\$state_table_(\$current_state) && \\\n "
+ puts -nonewline $::dest "\$state_table_(\$yy_current_state) && \\\n "
} elseif {$state_name != "*"} {
- puts -nonewline $::dest "\$current_state == \"$state_name\" && \\\n "
+ puts -nonewline $::dest "\$yy_current_state == \"$state_name\" && \\\n "
}
}
puts $::dest "\[regexp -start \$index_ -indices -line $scan_args -- \{\\A($pattern)\} \$yy_current_buffer match\] > 0\ && \\
@@ -730,7 +730,7 @@ proc ${::p}::yylex \{\} \{
} else {
puts -nonewline $::dest " \{ puts stderr \"unmatched token: \$yytext"
if $::startstates {
- puts -nonewline $::dest " in state `\$current_state'"
+ puts -nonewline $::dest " in state `\$yy_current_state'"
}
puts $::dest "\"; exit -1 \}"
}
@@ -942,6 +942,7 @@ proc fickle_main {} {
}
}
}
+ puts [array get ::state_table]
}
######################################################################