diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2018-10-01 19:42:14 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2018-10-01 19:42:14 (GMT) |
commit | b8bcb02d9cf15aba8a4575ad007af8e75f322381 (patch) | |
tree | 039945b0b459d09f5ece86c3db13f848d7fdda14 | |
parent | a6add060cc96819bfaddc736f81a92a3fe40e51d (diff) | |
download | blt-b8bcb02d9cf15aba8a4575ad007af8e75f322381.zip blt-b8bcb02d9cf15aba8a4575ad007af8e75f322381.tar.gz blt-b8bcb02d9cf15aba8a4575ad007af8e75f322381.tar.bz2 |
Squashed 'taccle/' changes from 60bf59d7..0ac939d3
0ac939d3 support YYERROR
git-subtree-dir: taccle
git-subtree-split: 0ac939d33e2853c2f5aa9754f817518f9fe56820
-rw-r--r-- | taccle.tcl | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -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)]} { |