[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/10] java: prefer null to YYSYMBOL_YYEMPTY
From: |
Akim Demaille |
Subject: |
[PATCH 07/10] java: prefer null to YYSYMBOL_YYEMPTY |
Date: |
Tue, 7 Apr 2020 07:13:54 +0200 |
That's one nice benefit from using enums.
* data/skeletons/lalr1.java (YYSYMBOL_YYEMPTY): No longer define it.
Use 'null' instead.
* examples/java/calc/Calc.y, tests/local.at: Adjust.
---
TODO | 3 +++
data/skeletons/lalr1.java | 8 ++++----
examples/java/calc/Calc.y | 2 +-
tests/local.at | 2 +-
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/TODO b/TODO
index 1e589ddc..6d5a1480 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,7 @@
* Bison 3.6
+** syntax_error_arguments
+Don't store the lookahead if !argv.
+
** Documentation
- yyexpected_tokens in all the languages.
- YYNOMEM
diff --git a/data/skeletons/lalr1.java b/data/skeletons/lalr1.java
index 328c8bf7..f2e64e44 100644
--- a/data/skeletons/lalr1.java
+++ b/data/skeletons/lalr1.java
@@ -55,7 +55,7 @@ b4_use_push_for_pull_if([
m4_define([b4_define_state],[[
/* Lookahead and lookahead in internal form. */
int yychar = YYEMPTY_;
- SymbolKind yytoken = SymbolKind.YYSYMBOL_YYEMPTY;
+ SymbolKind yytoken = null;
/* State. */
int yyn = 0;
@@ -681,7 +681,7 @@ b4_dollar_popdef[]dnl
{
++yynerrs;
if (yychar == YYEMPTY_)
- yytoken = SymbolKind.YYSYMBOL_YYEMPTY;
+ yytoken = null;
yyreportSyntaxError (new Context (yystack,
yytoken]b4_locations_if([[, yylloc]])[));
}
@@ -795,7 +795,7 @@ b4_dollar_popdef[]dnl
{
/* Lookahead and lookahead in internal form. */
this.yychar = YYEMPTY_;
- this.yytoken = SymbolKind.YYSYMBOL_YYEMPTY;
+ this.yytoken = null;
/* State. */
this.yyn = 0;
@@ -972,7 +972,7 @@ b4_dollar_popdef[]dnl
to an error action in a later state.
*/
int yycount = 0;
- if (yyctx.getToken () != SymbolKind.YYSYMBOL_YYEMPTY)
+ if (yyctx.getToken () != null)
{
yyarg[yycount++] = yyctx.getToken ();
yycount += yyctx.getExpectedTokens (yyarg, 1, yyargn);
diff --git a/examples/java/calc/Calc.y b/examples/java/calc/Calc.y
index 790f6f47..edccb94c 100644
--- a/examples/java/calc/Calc.y
+++ b/examples/java/calc/Calc.y
@@ -129,7 +129,7 @@ class CalcLexer implements Calc.Lexer {
}
{
Calc.SymbolKind lookahead = ctx.getToken ();
- if (lookahead != Calc.SymbolKind.YYSYMBOL_YYEMPTY)
+ if (lookahead != null)
System.err.print (" before " + ctx.yysymbolName (lookahead));
}
System.err.println ("");
diff --git a/tests/local.at b/tests/local.at
index cd16419b..1b656a80 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -982,7 +982,7 @@ m4_define([AT_YYERROR_DEFINE(java)],
+ )["syntax error");
{
Calc.SymbolKind token = ctx.getToken ();
- if (token != Calc.SymbolKind.YYSYMBOL_YYEMPTY)
+ if (token != null)
System.err.print (" on token @<:@" + ctx.yysymbolName (token) +
"@:>@");
}
{
--
2.26.0
- [PATCH 00/10] Make recent feature better looking, Akim Demaille, 2020/04/07
- [PATCH 01/10] c: make the generated YYSTYPE nicer to read, Akim Demaille, 2020/04/07
- [PATCH 02/10] c: make the token kind definition nicer to read, Akim Demaille, 2020/04/07
- [PATCH 03/10] c: make the symbol kind definition nicer to read, Akim Demaille, 2020/04/07
- [PATCH 05/10] java: use getExpectedTokens, not yyexpectedTokens, Akim Demaille, 2020/04/07
- [PATCH 04/10] java: style: fix coding style, Akim Demaille, 2020/04/07
- [PATCH 07/10] java: prefer null to YYSYMBOL_YYEMPTY,
Akim Demaille <=
- [PATCH 10/10] todo: update, Akim Demaille, 2020/04/07
- [PATCH 06/10] java: rename Lexer.yyreportSyntaxError as reportSyntaxError, Akim Demaille, 2020/04/07
- [PATCH 08/10] java: document new features, Akim Demaille, 2020/04/07
- [PATCH 09/10] skeletons: beware not to use yyarg when it's null, Akim Demaille, 2020/04/07