java: beware not to alias the locations of the various symbols

* examples/java/calc/Calc.y, tests/calc.at, tests/local.at
(getStartPos, getEndPos): Always return a new object.
* doc/bison.texi: Clarify this.
This commit is contained in:
Akim Demaille
2020-02-11 20:42:05 +01:00
parent cdb42f7730
commit 163a35d6dd
4 changed files with 22 additions and 7 deletions

View File

@@ -12889,9 +12889,12 @@ Default is @code{java.io.IOException}.
@deftypemethod {Lexer} {Position} getStartPos ()
@deftypemethodx {Lexer} {Position} getEndPos ()
Return respectively the first position of the last token that
@code{yylex} returned, and the first position beyond it. These
methods are not needed unless location tracking is active.
Return respectively the first position of the last token that @code{yylex}
returned, and the first position beyond it. These methods are not needed
unless location tracking is active.
They should return new objects for each call, to avoid that all the symbol
share the same Position boundaries.
The return type can be changed using @code{%define api.position.type
@{@var{class-name}@}}.