mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 10:43:02 +00:00
examples: bistromathic: demonstrate error recovery
* examples/c/bistromathic/parse.y: here. * examples/c/bistromathic/bistromathic.test: Check it. Included a stupid case where the error is actually ignored.
This commit is contained in:
@@ -82,11 +82,26 @@ run 0 '> 1 / 0
|
||||
> ''
|
||||
err: 1.1-5: error: division by zero'
|
||||
|
||||
# Error recovery.
|
||||
cat >input <<EOF
|
||||
100%
|
||||
((1 ++ 2) ** 3)
|
||||
(1 ++ 2) + (3 ** 4)
|
||||
EOF
|
||||
run 0 '> 100%
|
||||
100
|
||||
run 0 '> ((1 ++ 2) ** 3)
|
||||
666
|
||||
> (1 ++ 2) + (3 ** 4)
|
||||
1332
|
||||
> ''
|
||||
err: 1.6: syntax error: expected - or ( or number or function or variable before +
|
||||
err: 2.5: syntax error: expected - or ( or number or function or variable before +
|
||||
err: 2.16: syntax error: expected - or ( or number or function or variable before *'
|
||||
|
||||
# This is really stupid: we just discarded % and did not enter error recovery.
|
||||
cat >input <<EOF
|
||||
100% + 10
|
||||
EOF
|
||||
run 0 '> 100% + 10
|
||||
110
|
||||
> ''
|
||||
err: 1.4: error: invalid character'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user