[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
style: update comments in the skeletons
From: |
Akim Demaille |
Subject: |
style: update comments in the skeletons |
Date: |
Sun, 5 Jul 2020 10:00:15 +0200 |
commit 49f1e5f42813f9d8bccedac9e5108b59ae71e8b7
Author: Akim Demaille <akim.demaille@gmail.com>
Date: Sun Jul 5 09:14:17 2020 +0200
style: update comments in the skeletons
* data/skeletons/c++.m4, data/skeletons/glr.c, data/skeletons/lalr1.d,
* data/skeletons/lalr1.java, data/skeletons/yacc.c:
Be more accurate about yychar and yytoken.
Don't name local variables as if they were members.
diff --git a/data/skeletons/c++.m4 b/data/skeletons/c++.m4
index 5536b1a0..b7a2a3a8 100644
--- a/data/skeletons/c++.m4
+++ b/data/skeletons/c++.m4
@@ -594,11 +594,12 @@ m4_define([b4_yytranslate_define],
{
]b4_translate[
};
- const int code_max_ = ]b4_code_max[;
+ // Last valid token kind.
+ const int code_max = ]b4_code_max[;
if (t <= 0)
return symbol_kind::]b4_symbol_prefix[YYEOF;
- else if (t <= code_max_)
+ else if (t <= code_max)
return YY_CAST (symbol_kind_type, translate_table[t]);
else
return symbol_kind::]b4_symbol_prefix[YYUNDEF;]])[
diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index 6ae27fa1..a50f1804 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -333,7 +333,7 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
accessed by $0, $-1, etc., in any rule. */
#define YYMAXLEFT ]b4_max_left_semantic_context[
-/* YYMAXUTOK -- Last valid token number (for yychar). */
+/* YYMAXUTOK -- Last valid token kind. */
#define YYMAXUTOK ]b4_code_max[
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
diff --git a/data/skeletons/lalr1.d b/data/skeletons/lalr1.d
index 85001b72..761125cb 100644
--- a/data/skeletons/lalr1.d
+++ b/data/skeletons/lalr1.d
@@ -428,8 +428,9 @@ b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
*/
public bool parse ()
{
- /// Lookahead and lookahead in internal form.
+ // Lookahead token kind.
int yychar = TokenKind.YYEMPTY;
+ // Lookahead symbol kind.
SymbolKind yytoken = ]b4_symbol(-2, kind)[;
/* State. */
@@ -841,11 +842,12 @@ m4_popdef([b4_at_dollar])])dnl
]b4_translate[
@};
- immutable int code_max_ = ]b4_code_max[;
+ // Last valid token kind.
+ immutable int code_max = ]b4_code_max[;
if (t <= 0)
return ]b4_symbol(0, kind)[;
- else if (t <= code_max_)
+ else if (t <= code_max)
{
import std.conv : to;
return to!SymbolKind (translate_table[t]);
diff --git a/data/skeletons/lalr1.java b/data/skeletons/lalr1.java
index 419d5c49..b85c16a0 100644
--- a/data/skeletons/lalr1.java
+++ b/data/skeletons/lalr1.java
@@ -53,8 +53,9 @@ b4_use_push_for_pull_if([
# allows them to be defined either in parse() when doing pull parsing,
# or as class instance variable when doing push parsing.
m4_define([b4_define_state],[[
- /* Lookahead and lookahead in internal form. */
+ /* Lookahead token kind. */
int yychar = YYEMPTY_;
+ /* Lookahead symbol kind. */
SymbolKind yytoken = null;
/* State. */
@@ -1078,17 +1079,18 @@ b4_dollar_popdef[]dnl
/* YYTRANSLATE_(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, with out-of-bounds checking. */
- private static final SymbolKind yytranslate_ (int t)
+ private static final SymbolKind yytranslate_(int t)
]b4_api_token_raw_if(dnl
[[ {
return SymbolKind.get(t);
}
]],
[[ {
- int code_max_ = ]b4_code_max[;
+ // Last valid token kind.
+ int code_max = ]b4_code_max[;
if (t <= 0)
return ]b4_symbol(0, kind)[;
- else if (t <= code_max_)
+ else if (t <= code_max)
return SymbolKind.get(yytranslate_table_[t]);
else
return ]b4_symbol(2, kind)[;
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index 08ec9883..43838d01 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -155,7 +155,7 @@ m4_define([b4_rhs_location],
# Declare the variables that are global, or local to YYPARSE if
# pure-parser.
m4_define([b4_declare_scanner_communication_variables], [[
-/* The lookahead symbol. */
+/* Lookahead token kind. */
int yychar;
]b4_pure_if([[
@@ -571,6 +571,7 @@ union yyalloc
/* YYNSTATES -- Number of states. */
#define YYNSTATES ]b4_states_number[
+/* YYMAXUTOK -- Last valid token kind. */
#define YYMAXUTOK ]b4_code_max[
@@ -1544,7 +1545,7 @@ yyparse (]m4_ifset([b4_parse_param],
[b4_formals(b4_parse_param)], [void])[)]])[
int yyn;
/* The return value of yyparse. */
int yyresult;
- /* Lookahead token as an internal (translated) token number. */
+ /* Lookahead symbol kind. */
yysymbol_kind_t yytoken = ]b4_symbol(-2, kind)[;
/* The variables used to return semantic value and location from the
action routines. */
diff --git a/src/parse-gram.c b/src/parse-gram.c
index 89e5064c..1eaaf794 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -627,6 +627,7 @@ union yyalloc
/* YYNSTATES -- Number of states. */
#define YYNSTATES 167
+/* YYMAXUTOK -- Last valid token kind. */
#define YYMAXUTOK 315
@@ -1752,7 +1753,7 @@ yydestruct (const char *yymsg,
int
yyparse (void)
{
-/* The lookahead symbol. */
+/* Lookahead token kind. */
int yychar;
@@ -1807,7 +1808,7 @@ YYLTYPE yylloc = yyloc_default;
int yyn;
/* The return value of yyparse. */
int yyresult;
- /* Lookahead token as an internal (translated) token number. */
+ /* Lookahead symbol kind. */
yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
/* The variables used to return semantic value and location from the
action routines. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- style: update comments in the skeletons,
Akim Demaille <=