examples: bistromathic: fix location tracking

* examples/c/bistromathic/scan.l (LOCATION_STEP): New.
Use to properly ignore blanks.
* examples/c/bistromathic/bistromathic.test: Check that case.
This commit is contained in:
Akim Demaille
2020-02-02 08:59:54 +01:00
parent 23ba9e5dfa
commit 493359b758
2 changed files with 14 additions and 3 deletions

View File

@@ -46,3 +46,8 @@ cat >input <<EOF
*
EOF
run 0 "err: 1.1: syntax error expected end of file or - or ( or end of line or double precision number or function or variable before *"
cat >input <<EOF
1 + 2 * * 3
EOF
run 0 "err: 1.9: syntax error expected - or ( or double precision number or function or variable before *"

View File

@@ -13,13 +13,19 @@
// Each time a rule is matched, advance the end cursor/position.
#define YY_USER_ACTION \
yylloc->last_column += yyleng;
// Move the first position onto the last.
#define LOCATION_STEP() \
do { \
yylloc->first_line = yylloc->last_line; \
yylloc->first_column = yylloc->last_column; \
} while (0)
%}
%%
%{
// Each time yylex is called, move the head position to the end one.
yylloc->first_line = yylloc->last_line;
yylloc->first_column = yylloc->last_column;
LOCATION_STEP ();
%}
/* Rules. */
@@ -52,7 +58,7 @@
"\n" yylloc->last_line++; yylloc->last_column = 1; return TOK_EOL;
/* Ignore white spaces. */
[ \t]+ continue;
[ \t]+ LOCATION_STEP (); continue;
<<EOF>> return TOK_EOF;