examples: clean up

* examples/c/calc/calc.y: Restore to its original state, with
parse.error=detailed instead of parse.error=custom (this example
should be simple).
* examples/c/calc/calc.test: Check syntax errors.
* examples/c/lexcalc/parse.y: Add comments.
This commit is contained in:
Akim Demaille
2020-01-25 07:59:26 +01:00
parent 0917f4dc76
commit c592202345
5 changed files with 42 additions and 58 deletions

View File

@@ -1,4 +1,4 @@
/* Prologue (directives). -*- C++ -*- */
/* Prologue (directives). -*- C -*- */
/* Disable Flex features we don't need, to avoid warnings. */
%option nodefault noinput nounput noyywrap
@@ -17,10 +17,14 @@
%%
%{
// Number of opened parentheses.
int nesting = 0;
// A buffer storing the text inside the outer parentheses.
char *str = NULL;
int size = 0;
// Its allocated size.
int capacity = 0;
// Its used size.
int size = 0;
#define STR_APPEND() \
do { \
if (capacity < size + yyleng + 1) \