diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2018-02-22 21:03:01 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2018-02-22 21:03:01 (GMT) |
commit | 64443ae4af0357574ac3108258ac0f315e2a3bc9 (patch) | |
tree | 4ef9a36e76bc596aec60cb1f17b1df4ac104ac34 | |
parent | ea5e6ca2e6523f0b2a585112b5fd5f18e9fcf969 (diff) | |
download | blt-64443ae4af0357574ac3108258ac0f315e2a3bc9.zip blt-64443ae4af0357574ac3108258ac0f315e2a3bc9.tar.gz blt-64443ae4af0357574ac3108258ac0f315e2a3bc9.tar.bz2 |
add namespace
-rw-r--r-- | ds9/library/command.tcl | 3 | ||||
-rw-r--r-- | ds9/library/lex.fcl | 19 | ||||
-rw-r--r-- | ds9/library/parser.tac | 26 | ||||
-rw-r--r-- | taccle/taccle.tcl | 6 |
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 "\}" } ###################################################################### |