mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 02:33:03 +00:00
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:
@@ -3,7 +3,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.
|
||||
|
||||
@@ -209,10 +209,10 @@ yyreport_syntax_error (const yyparse_context_t *ctx)
|
||||
}
|
||||
|
||||
// Called by yyparse on error.
|
||||
void yyerror (YYLTYPE *loc, char const *s)
|
||||
void yyerror (YYLTYPE *loc, char const *msg)
|
||||
{
|
||||
YY_LOCATION_PRINT (stderr, *loc);
|
||||
fprintf (stderr, ": %s\n", s);
|
||||
fprintf (stderr, ": %s\n", msg);
|
||||
}
|
||||
|
||||
int main (int argc, char const* argv[])
|
||||
|
||||
Reference in New Issue
Block a user