mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 15:53:03 +00:00
examples: add an example with a reentrant parser in Flex+Bison
Suggested by Eric S. Raymond. https://lists.gnu.org/archive/html/bison-patches/2019-02/msg00066.html * examples/c/reentrant-calc/Makefile, examples/c/reentrant-calc/README.md, * examples/c/reentrant-calc/parse.y, examples/c/reentrant-calc/scan.l * examples/c/reentrant-calc/lexcalc.test, * examples/c/reentrant-calc/local.mk: New.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
This directory contains simple examples of Bison grammar files in C.
|
||||
|
||||
Most of them come from the documentation, which should be installed together
|
||||
Some of them come from the documentation, which should be installed together
|
||||
with Bison. The URLs are provided for convenience.
|
||||
|
||||
## rpcalc - Reverse Polish Notation Calculator
|
||||
@@ -16,7 +16,7 @@ https://www.gnu.org/software/bison/manual/html_node/RPN-Calc.html
|
||||
## calc - Simple Calculator
|
||||
This example is slightly more complex than rpcalc: it features infix
|
||||
operators (`1 + 2`, instead of `1 2 +` in rpcalc), but it does so using a
|
||||
unambiguous grammar of the arithmetics instead of using precedence
|
||||
unambiguous grammar of the arithmetic instead of using precedence
|
||||
directives (%left, etc.).
|
||||
|
||||
## mfcalc - Multi-Function Calculator
|
||||
@@ -30,6 +30,13 @@ https://www.gnu.org/software/bison/manual/html_node/Multi_002dfunction-Calc.html
|
||||
## lexcalc - calculator with Flex and Bison
|
||||
The calculator, redux. This time using a scanner generated by Flex.
|
||||
|
||||
## reccalc - recursive calculator with Flex and Bison
|
||||
The example builds on top of the previous one to provide a reentrant parser.
|
||||
Such parsers can be called concurrently in different threads, or even
|
||||
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.
|
||||
|
||||
|
||||
<!---
|
||||
|
||||
@@ -47,5 +54,6 @@ Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
# LocalWords: mfcalc calc parsers yy
|
||||
# LocalWords: mfcalc calc parsers yy rpcalc lexcalc redux reccalc ispell
|
||||
# LocalWords: reentrant tokenized american postfix
|
||||
--->
|
||||
|
||||
Reference in New Issue
Block a user