[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/10] java: use getExpectedTokens, not yyexpectedTokens
From: |
Akim Demaille |
Subject: |
[PATCH 05/10] java: use getExpectedTokens, not yyexpectedTokens |
Date: |
Tue, 7 Apr 2020 07:13:52 +0200 |
* data/skeletons/lalr1.java, examples/java/calc/Calc.y, tests/local.at:
here.
---
README-hacking.md | 7 ++++++-
data/skeletons/lalr1.java | 8 ++++----
examples/java/calc/Calc.y | 2 +-
tests/local.at | 2 +-
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/README-hacking.md b/README-hacking.md
index 4f6c0371..978163da 100644
--- a/README-hacking.md
+++ b/README-hacking.md
@@ -70,7 +70,9 @@ we are free to change them without fear of backward
compatibility issues.
Use `*_t` for types, especially for `yy*_t` in which case we shouldn't worry
about the C standard introducing such a name.
-In C++, use `*_type` for type aliases.
+#### C++
+Use `*_type` for type aliases. Use `foo_get()` and `foo_set(v)` for
+accessors, or simply `foo()` and `foo(v)`.
#### Java
We follow https://www.oracle.com/technetwork/java/codeconventions-150003.pdf
@@ -81,6 +83,9 @@ are standardizing the code, it is currently inconsistent.
Use a 2-space indentation (Google) rather than 4 (Oracle).
+Don't use the "yy" prefix for public members: "getExpectedTokens", not
+"yyexpectedTokens" or "yygetExpectedTokens".
+
## Commit Messages
Imitate the style we use. Use `git log` to get sources of inspiration.
diff --git a/data/skeletons/lalr1.java b/data/skeletons/lalr1.java
index 5627f293..0a6ed652 100644
--- a/data/skeletons/lalr1.java
+++ b/data/skeletons/lalr1.java
@@ -896,12 +896,12 @@ b4_dollar_popdef[]dnl
current YYCTX, and return the number of tokens stored in YYARG. If
YYARG is null, return the number of expected tokens (guaranteed to
be less than YYNTOKENS). */
- int yyexpectedTokens (SymbolKind yyarg[], int yyargn)
+ int getExpectedTokens (SymbolKind yyarg[], int yyargn)
{
- return yyexpectedTokens (yyarg, 0, yyargn);
+ return getExpectedTokens (yyarg, 0, yyargn);
}
- int yyexpectedTokens (SymbolKind yyarg[], int yyoffset, int yyargn)
+ int getExpectedTokens (SymbolKind yyarg[], int yyoffset, int yyargn)
{
int yycount = yyoffset;
int yyn = yypact_[this.yystack.stateAt (0)];
@@ -972,7 +972,7 @@ b4_dollar_popdef[]dnl
if (yyctx.getToken () != SymbolKind.YYSYMBOL_YYEMPTY)
{
yyarg[yycount++] = yyctx.getToken ();
- yycount += yyctx.yyexpectedTokens (yyarg, 1, yyargn);
+ yycount += yyctx.getExpectedTokens (yyarg, 1, yyargn);
}
return yycount;
}
diff --git a/examples/java/calc/Calc.y b/examples/java/calc/Calc.y
index 5a711b30..b45a8061 100644
--- a/examples/java/calc/Calc.y
+++ b/examples/java/calc/Calc.y
@@ -122,7 +122,7 @@ class CalcLexer implements Calc.Lexer {
{
final int TOKENMAX = 10;
Calc.SymbolKind[] arg = new Calc.SymbolKind[TOKENMAX];
- int n = ctx.yyexpectedTokens (arg, TOKENMAX);
+ int n = ctx.getExpectedTokens (arg, TOKENMAX);
for (int i = 0; i < n; ++i)
System.err.print ((i == 0 ? ": expected " : " or ")
+ ctx.yysymbolName (arg[i]));
diff --git a/tests/local.at b/tests/local.at
index 7626c04b..7a55dedf 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -987,7 +987,7 @@ m4_define([AT_YYERROR_DEFINE(java)],
}
{
Calc.SymbolKind[] arg = new Calc.SymbolKind[ctx.NTOKENS];
- int n = ctx.yyexpectedTokens (arg, ctx.NTOKENS);
+ int n = ctx.getExpectedTokens (arg, ctx.NTOKENS);
if (0 < n)
{
System.err.print (" (expected:");
--
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 <=
- [PATCH 04/10] java: style: fix coding style, Akim Demaille, 2020/04/07
- [PATCH 07/10] java: prefer null to YYSYMBOL_YYEMPTY, Akim Demaille, 2020/04/07
- [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