mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
doc: explain why location's "column" are defined vaguely
Suuggested by Frank Heckenbach. <https://lists.gnu.org/r/bug-bison/2022-01/msg00000.html> * doc/bison.texi (Location Type): Explain why location's "column" are defined vaguely. Show tab handling in ltcalc and calc++. * examples/c/bistromathic/parse.y: Show tab handling. * examples/c++/calc++/calc++.test, * examples/c/bistromathic/bistromathic.test: Check tab handling.
This commit is contained in:
@@ -50,6 +50,21 @@ EOF
|
||||
run 1 'err: -:2.1: syntax error, unexpected end of file, expecting ( or identifier or number'
|
||||
|
||||
|
||||
# Check handling of tabs.
|
||||
cat >input <<EOF
|
||||
*1
|
||||
EOF
|
||||
run 1 'err: -:1.9: syntax error, unexpected *, expecting ( or identifier or number'
|
||||
cat >input <<EOF
|
||||
*2
|
||||
EOF
|
||||
run 1 'err: -:1.9: syntax error, unexpected *, expecting ( or identifier or number'
|
||||
cat >input <<EOF
|
||||
*3
|
||||
EOF
|
||||
run 1 'err: -:1.9: syntax error, unexpected *, expecting ( or identifier or number'
|
||||
|
||||
|
||||
# LAC finds many more tokens.
|
||||
cat >input <<EOF
|
||||
a := 1
|
||||
|
||||
@@ -366,3 +366,26 @@ err: 1.15: syntax error: expected - or ( or number or function or variable befor
|
||||
err: 1 | (1++2) + 3 + ''
|
||||
err: | ^
|
||||
'
|
||||
|
||||
# Check handling of literal tabs. "Escape" them with a C-v, so that
|
||||
# they are not processed as completion requests.
|
||||
cat >input<<EOF
|
||||
*1
|
||||
*2
|
||||
*3
|
||||
EOF
|
||||
# readline processes the tabs itself, and replaces then with spaces.
|
||||
run -n 0 '> *1
|
||||
> *2
|
||||
> *3
|
||||
> ''
|
||||
err: 1.9: syntax error: expected end of file or - or ( or exit or number or function etc., before *
|
||||
err: 1 | *1
|
||||
err: | ^
|
||||
err: 2.9: syntax error: expected end of file or - or ( or exit or number or function etc., before *
|
||||
err: 2 | *2
|
||||
err: | ^
|
||||
err: 3.9: syntax error: expected end of file or - or ( or exit or number or function etc., before *
|
||||
err: 3 | *3
|
||||
err: | ^
|
||||
'
|
||||
|
||||
@@ -308,14 +308,15 @@ yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc,
|
||||
{
|
||||
int c;
|
||||
|
||||
// Ignore white space, get first nonwhite character.
|
||||
// Get next character, ignore white spaces.
|
||||
do {
|
||||
// Move the first position onto the last.
|
||||
yylloc->first_line = yylloc->last_line;
|
||||
yylloc->first_column = yylloc->last_column;
|
||||
|
||||
yylloc->last_column += 1;
|
||||
c = *((*line)++);
|
||||
// Tab characters go to the next column multiple of 8.
|
||||
yylloc->last_column +=
|
||||
c == '\t' ? 8 - ((yylloc->last_column - 1) & 7) : 1;
|
||||
} while (c == ' ' || c == '\t');
|
||||
|
||||
switch (c)
|
||||
|
||||
Reference in New Issue
Block a user