summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ds9/library/command.tcl3
-rw-r--r--ds9/library/lex.fcl19
-rw-r--r--ds9/library/parser.tac26
-rw-r--r--taccle/taccle.tcl6
4 files changed, 24 insertions, 30 deletions
diff --git a/ds9/library/command.tcl b/ds9/library/command.tcl
index b6f4f77..26d9b14 100644
--- a/ds9/library/command.tcl
+++ b/ds9/library/command.tcl
@@ -97,8 +97,9 @@ proc ProcessCommand {argv argc} {
set item [lindex $argv $i]
switch -- $item {
-foo {
+ puts "argc: $argc"
yy::YY_FLUSH_BUFFER
- yy::yy_scan_string $argv
+ yy::yy_scan_string [string range $argv $i end]
yy::yyparse
set argc 0
}
diff --git a/ds9/library/lex.fcl b/ds9/library/lex.fcl
index 2e9e2c2..f5d25a3 100644
--- a/ds9/library/lex.fcl
+++ b/ds9/library/lex.fcl
@@ -15,35 +15,32 @@ E [Ee][+-]?{D}+
%%
-foo {return $yy::FOOCMD_}
--exit {return $yy::EXITCMD_}
+-bar {return $yy::BARCMD_}
-close {return $yy::CLOSE_}
-fit {return $yy::FIT_}
-open {return $yy::OPEN_}
to {return $yy::TO_}
# INT
-[+-]?{D}+ {set ::yylval $yytext; return $yy::INT_}
+[+-]?{D}+ {set yy::yylval $yytext; return $yy::INT_}
# REAL
[+-]?{D}+"."?({E})? |
-[+-]?{D}*"."{D}+({E})? {set ::yylval $yytext; return $yy::REAL_}
+[+-]?{D}*"."{D}+({E})? {set yy::yylval $yytext; return $yy::REAL_}
# Quoted STRING
-\"[^\"]*\" {set ::yylval [string range $yytext 1 end-1]; return $yy::STRING_}
+\"[^\"]*\" {set yy::yylval [string range $yytext 1 end-1]; return $yy::STRING_}
# Quoted STRING
-\'[^\']*\' {set ::yylval [string range $yytext 1 end-1]; return $yy::STRING_}
+\'[^\']*\' {set yy::yylval [string range $yytext 1 end-1]; return $yy::STRING_}
# Quoted STRING
-\{[^\}]*\} {set ::yylval [string range $yytext 1 end-1]; return $yy::STRING_}
+\{[^\}]*\} {set yy::yylval [string range $yytext 1 end-1]; return $yy::STRING_}
# STRING
-\S+\S+ {set ::yylval $yytext; return $yy::STRING_}
+\S+\S+ {set yy::yylval $yytext; return $yy::STRING_}
\s # ignore whitespace
-. {set ::yylval $yytext; return $::yylval}
+. {set yy::yylval $yytext; return $yy::yylval}
%%
diff --git a/ds9/library/parser.tac b/ds9/library/parser.tac
index 059c96d..a5c5b77 100644
--- a/ds9/library/parser.tac
+++ b/ds9/library/parser.tac
@@ -6,11 +6,8 @@
%token STRING_
%token FOOCMD_
-%token EXITCMD_
+%token BARCMD_
-%token CLOSE_
-%token FIT_
-%token OPEN_
%token TO_
%%
@@ -19,30 +16,29 @@ commands : commands command
| command
;
-int : INT_ {set _ $1}
+command : FOOCMD_ foo
+ | BARCMD_ bar
;
-command : FOOCMD_ foo
- | EXITCMD_ exit
+int : INT_ {set _ $1}
;
numeric : int {set _ $1}
| REAL_ {set _ $1}
;
-foo : STRING_ {puts "STRING $1"}
- | INT_ {puts "INT $1"}
- | REAL_ {puts "REAL $1"}
- | OPEN_ {puts "OPEN"}
- | CLOSE_ {puts "CLOSE"}
+foo : STRING_ {puts "FOO STRING $1"}
+ | INT_ {puts "FOO INT $1"}
+ | REAL_ {puts "FOO REAL $1"}
| TO_ fooTo
;
-fooTo: FIT_ {puts "TO FIT"}
- | numeric {puts "TO NUMERIC $1"}
+fooTo: STRING_ {puts "FOO TO STRING $1"}
+ | numeric {puts "FOO TO NUMERIC $1"}
;
-exit: {puts "EXIT"; QuitDS9}
+bar : #ANY_ {puts "BAR ANY $1}
+ | INT_ {puts "BAR INT $1"}
;
%%
diff --git a/taccle/taccle.tcl b/taccle/taccle.tcl
index 3cae470..e3d11fe 100644
--- a/taccle/taccle.tcl
+++ b/taccle/taccle.tcl
@@ -1002,16 +1002,16 @@ proc write_array {fd name values} {
# Writes a header file that should be [source]d by the lexer.
proc write_header_file {} {
# scan through token_table and write out all non-implicit terminals
- puts $::header "namespace eval ${::p} \{\}"
- puts $::header ""
+ puts $::header "namespace eval ${::p} \{"
foreach tok_id $::token_list {
if {$::token_id_table($tok_id,t) == $::TERMINAL && \
[string is integer $tok_id] && $tok_id >= 256} {
set token $::token_id_table($tok_id)
- puts $::header "set ${::p}::${token} $tok_id"
+ puts $::header "set ${token} $tok_id"
}
}
puts $::header "set yylval \{\}"
+ puts $::header "\}"
}
######################################################################