[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/10] c++: remove the yy prefix from some functions
From: |
Akim Demaille |
Subject: |
[PATCH 05/10] c++: remove the yy prefix from some functions |
Date: |
Sun, 12 Apr 2020 14:22:32 +0200 |
yy::parser features a parse() function, not a yyparse() one.
* data/skeletons/lalr1.cc (yyreport_syntax_error)
(context::yyexpected_tokens): Rename as...
(report_syntax_error, context::expected_tokens): these.
---
TODO | 11 +----------
data/skeletons/lalr1.cc | 10 +++++-----
tests/local.at | 4 ++--
3 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/TODO b/TODO
index 4da4100d..55e7c996 100644
--- a/TODO
+++ b/TODO
@@ -1,20 +1,11 @@
* Bison 3.6
-** C++
-yyreport_syntax_error should always be the name of the reporting, yyparse
-should not have to dispatch to several APIs.
-
** Documentation
-- yyexpected_tokens in all the languages.
+- yyexpected_tokens/expected_tokens/expectedTokens in all the languages.
- YYENOMEM
- YYERRCODE, YYUNDEF, YYEOF
- i18n in Java
- symbol.type_get should be kind_get, and it's not documented.
-** Naming conventions
-There's no good reason to use the "yy" prefix in parser::context, is there?
-See also the case of Java. We should keep the prefix for private
-implementation details, but maybe not for public APIs.
-
** User token number, internal symbol number, external token number, etc.
There is some confusion over these terms, which is even a problem for
translators. We need something clear, especially if we provide access to
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index 4387fbfc..13fab5bf 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -247,7 +247,7 @@ m4_define([b4_shared_declarations],
/// Put in YYARG at most YYARGN of the expected tokens, 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 yyexpected_tokens (symbol_kind_type yyarg[], int yyargn) const;
+ int expected_tokens (symbol_kind_type yyarg[], int yyargn) const;
private:
const ]b4_parser_class[& yyparser_;
@@ -276,7 +276,7 @@ m4_define([b4_shared_declarations],
[custom], [[
/// Report a syntax error
/// \param yyctx the context in which the error occurred.
- void yyreport_syntax_error (const context& yyctx) const;]],
+ void report_syntax_error (const context& yyctx) const;]],
[detailed\|verbose], [[
/// The arguments of the error message.
int yy_syntax_error_arguments_ (const context& yyctx,
@@ -1074,7 +1074,7 @@ b4_dollar_popdef])[]dnl
error (]b4_join(b4_locations_if([yyla.location]), [[YY_MOVE
(msg)]])[);]],
[custom], [[
context yyctx (*this, yyla);
- yyreport_syntax_error (yyctx);]],
+ report_syntax_error (yyctx);]],
[[
context yyctx (*this, yyla);
std::string msg = yysyntax_error_ (yyctx);
@@ -1230,7 +1230,7 @@ b4_dollar_popdef])[]dnl
{}
int
- ]b4_parser_class[::context::yyexpected_tokens (symbol_kind_type yyarg[], int
yyargn) const
+ ]b4_parser_class[::context::expected_tokens (symbol_kind_type yyarg[], int
yyargn) const
{
// Actual number of expected tokens
int yycount = 0;
@@ -1462,7 +1462,7 @@ b4_dollar_popdef])[]dnl
{
if (yyarg)
yyarg[0] = yyctx.token ();
- int yyn = yyctx.yyexpected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn -
1);
+ int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn -
1);
return yyn + 1;
}
return 0;
diff --git a/tests/local.at b/tests/local.at
index 3e1cc1a8..73319a18 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -746,7 +746,7 @@ void
std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << '\n';
}]AT_ERROR_CUSTOM_IF([[
void
-]AT_NAMESPACE[::parser::yyreport_syntax_error (const context& ctx) const
+]AT_NAMESPACE[::parser::report_syntax_error (const context& ctx) const
{]AT_PARAM_IF([m4_bpatsubst(m4_defn([AT_PARSE_PARAMS]),
[[^,]+[^A-Za-z_0-9]\([A-Za-z_][A-Za-z_0-9]*\),* *], [
YYUSE (\1);])])[]m4_bmatch(m4_defn([AT_PARSE_PARAMS]), [nerrs],[[
@@ -762,7 +762,7 @@ void
{
enum { TOKENMAX = 10 };
symbol_kind_type expected[TOKENMAX];
- int n = ctx.yyexpected_tokens (expected, TOKENMAX);
+ int n = ctx.expected_tokens (expected, TOKENMAX);
if (0 < n)
{
std::cerr << " (expected:";
--
2.26.0
- [PATCH 00/10] Clean up the handling of the tokens, Akim Demaille, 2020/04/12
- [PATCH 01/10] tokens: style: minor fixes, Akim Demaille, 2020/04/12
- [PATCH 02/10] tokens: properly define the "error" token kind, Akim Demaille, 2020/04/12
- [PATCH 03/10] tokens: define the "$undefined" token kind, Akim Demaille, 2020/04/12
- [PATCH 05/10] c++: remove the yy prefix from some functions,
Akim Demaille <=
- [PATCH 08/10] skeletons: make the eof token translatable if i18n is enabled, Akim Demaille, 2020/04/12
- [PATCH 04/10] tokens: properly define the YYEOF token kind, Akim Demaille, 2020/04/12
- [PATCH 06/10] diagnostics: replace "user token number" by "token code", Akim Demaille, 2020/04/12
- [PATCH 09/10] skeletons: use "invalid token" instead of "$undefined", Akim Demaille, 2020/04/12
- [PATCH 10/10] skeletons: clarify the tag of special tokens, Akim Demaille, 2020/04/12
- [PATCH 07/10] skeletons: use "end of file" instead of "$end", Akim Demaille, 2020/04/12