mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 00:33:03 +00:00
examples: add an example of a push parser
Add an example to demonstrate the use of push parser. I'm pleasantly surprised: parse.error=detailed works like a charm with push parsers. * examples/c/local.mk, examples/c/pushcalc/Makefile * examples/c/pushcalc/README.md, examples/c/pushcalc/calc.test, * examples/c/pushcalc/calc.y, examples/c/pushcalc/local.mk: New.
This commit is contained in:
@@ -37,6 +37,17 @@ recursively. To demonstrate this feature, expressions in parentheses are
|
||||
tokenized as strings, and then recursively parsed from the parser. So
|
||||
`(((1)+(2))*((3)+(4)))` uses eight parsers, with a depth of four.
|
||||
|
||||
## pushcalc - calculator implemented with a push parser
|
||||
All the previous examples are so called "pull parsers": the user invokes the
|
||||
parser once, which repeatedly calls the scanner until the input is drained.
|
||||
|
||||
This example demonstrates the "push parsers": the user calls the scanner to
|
||||
fetch the next token, passes it to the parser, and repeats the operation
|
||||
until the input is drained.
|
||||
|
||||
This example is a straightforward conversion of the 'calc' example to the
|
||||
push-parser model.
|
||||
|
||||
|
||||
<!---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user