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:
Akim Demaille
2022-01-15 10:28:16 +01:00
parent a475c4d5c1
commit 6ee1494d6e
4 changed files with 79 additions and 5 deletions

View File

@@ -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)