examples: lexcalc: demonstrate location tracking

The bistromathic example should not use Flex, it makes it too complex.
But it was the only example to show location tracking with Flex.

* examples/c/lexcalc/lexcalc.test, examples/c/lexcalc/parse.y,
* examples/c/lexcalc/scan.l: Demonstrate location tracking as is done
in bistromathic.
This commit is contained in:
Akim Demaille
2020-02-29 09:54:34 +01:00
parent b870d5fee4
commit 388e12ac0f
8 changed files with 46 additions and 16 deletions

View File

@@ -28,7 +28,8 @@ Extracted from the documentation: "Multi-Function Calculator: mfcalc".
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.
The calculator with precedence directives and location tracking. It uses
Flex to generate the scanner.
## reccalc - recursive calculator with Flex and Bison
The example builds on top of the previous one to provide a reentrant parser.
@@ -53,7 +54,7 @@ This example demonstrates the best practices when using Bison.
- Its interface is pure.
- It uses a custom syntax error with location tracking, lookahead correction
and token internationalization.
- It enables debug trace support with formatting of semantic values.
- It supports debug traces with semantic values.
- It uses named references instead of the traditional $1, $2, etc.
It also uses Flex to generate the scanner.