summaryrefslogtreecommitdiffstats
path: root/taccle
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-10-01 18:22:46 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-10-01 18:22:46 (GMT)
commit5130749bcb63ad668268d6a2c314193df575da35 (patch)
treeaffb56f2af657dfa4020fc282629c2e7c9287d8d /taccle
parent2b9b1beea143017ffa57e3829ecc643b0eb068d2 (diff)
downloadblt-5130749bcb63ad668268d6a2c314193df575da35.zip
blt-5130749bcb63ad668268d6a2c314193df575da35.tar.gz
blt-5130749bcb63ad668268d6a2c314193df575da35.tar.bz2
support YYERROR
Diffstat (limited to 'taccle')
-rw-r--r--taccle/taccle.tcl18
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)]} {