[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
c++: make operator() an alias to the parse function
From: |
Akim Demaille |
Subject: |
c++: make operator() an alias to the parse function |
Date: |
Wed, 24 Oct 2018 06:19:35 +0200 |
commit f9bba892bdf4b69ab4d4d20ad11f4c2427f97dec
Author: Akim Demaille <address@hidden>
Date: Tue Oct 23 18:42:37 2018 +0200
c++: make operator() an alias to the parse function
* data/glr.cc, data/lalr1.cc (operator()): New.
* doc/bison.texi: Update.
diff --git a/NEWS b/NEWS
index 7ffe90ff..6aa017cd 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,8 @@ GNU Bison NEWS
Variant-based symbols in C++ should use emplace() rather than build().
+ In C++ parsers, parser::operator() is now a synonym for the parser::parse.
+
* Noteworthy changes in release 3.1.91 (2018-10-18) [beta]
** Bug fixes
diff --git a/data/glr.cc b/data/glr.cc
index cc228995..0401b849 100644
--- a/data/glr.cc
+++ b/data/glr.cc
@@ -166,6 +166,12 @@ m4_pushdef([b4_parse_param],
m4_defn([b4_parse_param_orig]))dnl
{
}
+ int
+ ]b4_parser_class_name[::operator() ()
+ {
+ return parse ();
+ }
+
int
]b4_parser_class_name[::parse ()
{
@@ -267,6 +273,10 @@ b4_percent_code_get([[requires]])[
]b4_parser_class_name[ (]b4_parse_param_decl[);
virtual ~]b4_parser_class_name[ ();
+ /// Parse. An alias for parse ().
+ /// \returns 0 iff parsing succeeded.
+ int operator() ();
+
/// Parse.
/// \returns 0 iff parsing succeeded.
virtual int parse ();
diff --git a/data/lalr1.cc b/data/lalr1.cc
index 984be33a..f38015ba 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -190,6 +190,10 @@ m4_define([b4_shared_declarations],
]b4_parser_class_name[ (]b4_parse_param_decl[);
virtual ~]b4_parser_class_name[ ();
+ /// Parse. An alias for parse ().
+ /// \returns 0 iff parsing succeeded.
+ int operator() ();
+
/// Parse.
/// \returns 0 iff parsing succeeded.
virtual int parse ();
@@ -743,6 +747,12 @@ m4_if(b4_prefix, [yy], [],
return yyvalue == yytable_ninf_;
}
+ int
+ ]b4_parser_class_name[::operator() ()
+ {
+ return parse ();
+ }
+
int
]b4_parser_class_name[::parse ()
{
diff --git a/doc/bison.texi b/doc/bison.texi
index 89e2673a..ac2165ed 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -10714,8 +10714,10 @@ Build a new parser object. There are no arguments,
unless
Instantiate a syntax-error exception.
@end deftypeop
address@hidden {parser} {int} parse ()
-Run the syntactic analysis, and return 0 on success, 1 otherwise.
address@hidden {parser} {int} operator() ()
address@hidden {parser} {int} parse ()
+Run the syntactic analysis, and return 0 on success, 1 otherwise. Both
+routines are equivalent, @code{operator()} being more C++ish.
@cindex exceptions
The whole function is wrapped in a @code{try}/@code{catch} block, so that
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- c++: make operator() an alias to the parse function,
Akim Demaille <=