[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 8/9] java: add access to the number of errors
From: |
Akim Demaille |
Subject: |
[PATCH 8/9] java: add access to the number of errors |
Date: |
Sun, 2 Feb 2020 15:26:26 +0100 |
* data/skeletons/lalr1.java (yynewrrs, getNumberOfErrors): New.
Formatting changes.
---
data/skeletons/lalr1.java | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/data/skeletons/lalr1.java b/data/skeletons/lalr1.java
index ecdd70b0..de912383 100644
--- a/data/skeletons/lalr1.java
+++ b/data/skeletons/lalr1.java
@@ -64,8 +64,7 @@ m4_define([b4_define_state],[[
YYStack yystack = new YYStack ();
int label = YYNEWSTATE;
- /* Error handling. */
- int yynerrs_ = 0;]b4_locations_if([[
+]b4_locations_if([[
/* The location where the error started. */
]b4_location_type[ yyerrloc = null;
@@ -285,6 +284,13 @@ m4_define([b4_define_state],[[
public final void setDebugLevel (int level) { yydebug = level; }
]])[
+ private int yynerrs = 0;
+
+ /**
+ * The number of syntax errors so far.
+ */
+ public final int getNumberOfErrors () { return yynerrs; }
+
/**
* Print an error message via the lexer.
*]b4_locations_if([[ Use a <code>null</code> location.]])[
@@ -561,6 +567,7 @@ m4_define([b4_define_state],[[
]b4_define_state[]b4_parse_trace_if([[
yycdebug ("Starting parse\n");]])[
yyerrstatus_ = 0;
+ yynerrs = 0;
/* Initialize the stack. */
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
@@ -700,7 +707,7 @@ b4_dollar_popdef[]dnl
/* If not already recovering from an error, report this error. */
if (yyerrstatus_ == 0)
{
- ++yynerrs_;
+ ++yynerrs;
if (yychar == yyempty_)
yytoken = yyempty_;
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate,
yytoken));
@@ -825,7 +832,7 @@ b4_dollar_popdef[]dnl
this.label = YYNEWSTATE;
/* Error handling. */
- this.yynerrs_ = 0;]b4_locations_if([[
+ this.yynerrs = 0;]b4_locations_if([[
/* The location where the error started. */
this.yyerrloc = null;
this.yylloc = new ]b4_location_type[ (null, null);]])[
--
2.25.0
- [PATCH 0/9] Prepare Java for parse.error custom|detailed, Akim Demaille, 2020/02/02
- [PATCH 2/9] tests: comment changes, Akim Demaille, 2020/02/02
- [PATCH 4/9] java: example: improve, Akim Demaille, 2020/02/02
- [PATCH 1/9] skeletons: add support for %code epilogue, Akim Demaille, 2020/02/02
- [PATCH 3/9] java: example: rely on autoboxing, Akim Demaille, 2020/02/02
- [PATCH 5/9] java: example: properly track the locations, Akim Demaille, 2020/02/02
- [PATCH 7/9] java: formatting changes, Akim Demaille, 2020/02/02
- [PATCH 8/9] java: add access to the number of errors,
Akim Demaille <=
- [PATCH 6/9] java: avoid trailing white spaces, Akim Demaille, 2020/02/02
- [PATCH 9/9] java: use the same calc tests as the other skeletons, Akim Demaille, 2020/02/02