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 authored and Akim Demaille committed 2020-11-20 22:09:31 +01:00
1 parent 2ca158c893
commit 10305f3e94
8 files changed
+95 -62

No files matched your search

+3 -3
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()