mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-23 11:13:03 +00:00
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:
@@ -46,3 +46,8 @@ cat >input <<EOF
|
|||||||
*
|
*
|
||||||
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 *"
|
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 *"
|
||||||
|
|||||||
@@ -13,13 +13,19 @@
|
|||||||
// Each time a rule is matched, advance the end cursor/position.
|
// Each time a rule is matched, advance the end cursor/position.
|
||||||
#define YY_USER_ACTION \
|
#define YY_USER_ACTION \
|
||||||
yylloc->last_column += yyleng;
|
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.
|
// Each time yylex is called, move the head position to the end one.
|
||||||
yylloc->first_line = yylloc->last_line;
|
LOCATION_STEP ();
|
||||||
yylloc->first_column = yylloc->last_column;
|
|
||||||
%}
|
%}
|
||||||
/* Rules. */
|
/* Rules. */
|
||||||
|
|
||||||
@@ -52,7 +58,7 @@
|
|||||||
"\n" yylloc->last_line++; yylloc->last_column = 1; return TOK_EOL;
|
"\n" yylloc->last_line++; yylloc->last_column = 1; return TOK_EOL;
|
||||||
|
|
||||||
/* Ignore white spaces. */
|
/* Ignore white spaces. */
|
||||||
[ \t]+ continue;
|
[ \t]+ LOCATION_STEP (); continue;
|
||||||
|
|
||||||
<<EOF>> return TOK_EOF;
|
<<EOF>> return TOK_EOF;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user