mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 02:03:03 +00:00
multistart: also give access to yynerrs
This is something that has always bothered me: with pure parsers (and they all should be) the user does not have an (easy) access to yynerrs at the end of the parse. In the case of error recovery, that's the only direct means to know if there were errors. The usual approach being having the user maintain a counter incremented each time yyerror is called. So here, also capture yynerrs in the return value of the start-symbol parsing functions. * data/skeletons/yacc.c (yy_parse_impl_t): New. (yy_parse_impl): Use it. (b4_accept): Fill it. * examples/c/lexcalc/parse.y, examples/c/lexcalc/scan.l: No longer pass nerrs as lex- and parse-param, just use the resulting yynerrs. bistromathic and reccalc both demonstrate %param.
This commit is contained in:
@@ -38,12 +38,14 @@ run -noerr 0 9 -p
|
||||
cat >input <<EOF
|
||||
(1+2) *
|
||||
EOF
|
||||
run 1 'err: 1.8-2.0: syntax error, unexpected end of line, expecting ( or number'
|
||||
run 1 'err: 1.8-2.0: syntax error, unexpected end of line, expecting ( or number
|
||||
err: errors: 1'
|
||||
|
||||
cat >input <<EOF
|
||||
1 / (2 - 2)
|
||||
EOF
|
||||
run 1 'err: 1.1-11: error: division by zero'
|
||||
run 1 'err: 1.1-11: error: division by zero
|
||||
err: errors: 1'
|
||||
|
||||
|
||||
# Multistart: parse "expression" instead of "input".
|
||||
@@ -57,4 +59,5 @@ cat >input <<EOF
|
||||
2
|
||||
EOF
|
||||
run 1 'expression: failure
|
||||
err: 2.1: syntax error, unexpected number, expecting end of file' -e
|
||||
err: 2.1: syntax error, unexpected number, expecting end of file
|
||||
err: errors: 1' -e
|
||||
|
||||
Reference in New Issue
Block a user