diff options
Diffstat (limited to 'taccle/taccle.tcl')
-rw-r--r-- | taccle/taccle.tcl | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/taccle/taccle.tcl b/taccle/taccle.tcl index d4ae6d2..d97a607 100644 --- a/taccle/taccle.tcl +++ b/taccle/taccle.tcl @@ -7,7 +7,6 @@ set TACCLE_VERSION 1.3 # no yydebug # no YYDEBUG # no yyerrok -# no YYERROR # no YYRECOVERING # add %define parse.error verbose @@ -865,6 +864,8 @@ namespace eval ${::p} \{ variable rules variable token {} variable yycnt 0 + variable yyerr 0 + variable save_state 0 namespace export yylex \} @@ -877,6 +878,11 @@ proc ${::p}::YYACCEPT \{\} \{ return -code return 0 \} +proc ${::p}::YYERROR \{\} \{ + variable yyerr + set yyerr 1 +\} + proc ${::p}::yyclearin \{\} \{ variable token variable yycnt @@ -926,12 +932,16 @@ proc write_parser {} { variable yycnt variable lr1_table variable token_id_table + variable yyerr + variable save_state set yycnt 0 set state_stack {0} set value_stack {{}} set token \"\" set accepted 0 + set yyerr 0 + set save_state 0 while {\$accepted == 0} { set state \[lindex \$state_stack end\] @@ -943,8 +953,10 @@ proc write_parser {} { incr yycnt } } - if {!\[info exists table(\$state:\$token)\]} { - set save_state \$state + if {!\[info exists table(\$state:\$token)\] || \$yyerr} { + if {!\$yyerr} { + set save_state \$state + } \# pop off states until error token accepted while {\[llength \$state_stack\] > 0 && \\ !\[info exists table(\$state:error)]} { |