d: change the return value of yylex from TokenKind to YYParser.Symbol

The complete symbol approach was deemed to be the right approach for Dlang.
Now, the user can return from yylex() an instance of YYParser.Symbol structure,
which binds together the TokenKind, the semantic value and the location. Before,
the last two were reported separately to the parser.
Only the user API is changed, Bisons's internal structure is kept the same.

* data/skeletons/d.m4 (struct YYParser.Symbol): New.
* data/skeletons/lalr1.d: Change the return value.
* doc/bison.texi: Document it.
* examples/d/calc/calc.y, examples/d/simple/calc.y: Demonstrate it.
* tests/calc.at, tests/scanner.at: Test it.
This commit is contained in:
Adela Vais
2020-11-11 22:35:30 +02:00
committed by Akim Demaille
parent 2ca158c893
commit 10305f3e94
8 changed files with 95 additions and 62 deletions

View File

@@ -14011,9 +14011,9 @@ This method is defined by the user to emit an error message. The first
parameter is omitted if location tracking is not active.
@end deftypemethod
@deftypemethod {Lexer} {TokenKind} yylex()
Return the next token. Its type is the return value, its semantic value and
location are saved and returned by the their methods in the interface.
@deftypemethod {Lexer} {YYParser.Symbol} yylex()
Return the next token. The return value is of type YYParser.Symbol, which
binds together the TokenKind, the semantic value and the location.
@end deftypemethod
@deftypemethod {Lexer} {YYPosition} getStartPos()