mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 10:43:02 +00:00
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:
committed by
Akim Demaille
parent
2ca158c893
commit
10305f3e94
@@ -81,7 +81,7 @@ class CalcLexer(R) : Lexer
|
||||
YYSemanticType semanticVal_;
|
||||
YYSemanticType semanticVal() @property { return semanticVal_; }
|
||||
|
||||
TokenKind yylex()
|
||||
YYParser.Symbol yylex()
|
||||
{
|
||||
$2
|
||||
}
|
||||
@@ -143,16 +143,16 @@ AT_KEYWORDS([d])
|
||||
|
||||
AT_CHECK_D_MINIMAL_W_LEXER([
|
||||
%define api.token.raw true
|
||||
%union { int ival; }], [return TokenKind.END;])
|
||||
%union { int ival; }], [return YYParser.Symbol(TokenKind.END);])
|
||||
AT_CHECK_D_GREP([[ END = 3,]])
|
||||
|
||||
AT_CHECK_D_MINIMAL_W_LEXER([
|
||||
%define api.token.raw false
|
||||
%union { int ival; }], [return TokenKind.END;])
|
||||
%union { int ival; }], [return YYParser.Symbol(TokenKind.END);])
|
||||
AT_CHECK_D_GREP([[ END = 258,]])
|
||||
|
||||
AT_CHECK_D_MINIMAL_W_LEXER([
|
||||
%union { int ival; }], [return TokenKind.END;])
|
||||
%union { int ival; }], [return YYParser.Symbol(TokenKind.END);])
|
||||
AT_CHECK_D_GREP([[ END = 3,]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
Reference in New Issue
Block a user