[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Suggestions for C++ parser generator
From: |
Akim Demaille |
Subject: |
Re: Suggestions for C++ parser generator |
Date: |
Wed, 5 Dec 2012 11:37:24 +0100 |
Le 4 août 2011 à 23:00, Mark Boyall <address@hidden> a écrit :
> In addition: If you change the filename type to a wstring, then compilation
> fails because the stream operators are hardcoded to output to a narrow
> stream. Fix: template them on the stream type.
hi Mark,
I'm sorry I didn't work fast enough on all the good comments
you made. I finally plan to prepare a release of Bison in the next
couple of months with the C++ variants.
I don't have time right now to address your other concerns, but
this one is an easy one.
Cheers,
Akim
commit c3eee1c8d38b7e998c2774aedcf103d962aa858a
Author: Akim Demaille <address@hidden>
Date: Wed Dec 5 11:21:21 2012 +0100
c++: support wide strings for file names
Reported by Mark Boyall.
http://lists.gnu.org/archive/html/help-bison/2011-08/msg00002.html
* data/location.cc (operator<<): Be templated on the type of
output stream.
* tests/headers.at (Several parsers): Adjust.
diff --git a/THANKS b/THANKS
index 218eea7..9a64012 100644
--- a/THANKS
+++ b/THANKS
@@ -68,6 +68,7 @@ Lie Yan address@hidden
Magnus Fromreide address@hidden
Marc Autret address@hidden
Marc Mendiola address@hidden
+Mark Boyall address@hidden
Martin Jacobs address@hidden
Martin Mokrejs address@hidden
Martin Nylin address@hidden
diff --git a/data/location.cc b/data/location.cc
index 58182a3..4082e09 100644
--- a/data/location.cc
+++ b/data/location.cc
@@ -136,8 +136,9 @@ b4_copyright([Positions for Bison parsers in C++],
** \param ostr the destination output stream
** \param pos a reference to the position to redirect
*/
- inline std::ostream&
- operator<< (std::ostream& ostr, const position& pos)
+ template <typename YYChar>
+ inline std::basic_ostream<YYChar>&
+ operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
{
if (pos.filename)
ostr << *pos.filename << ':';
@@ -275,7 +276,9 @@ b4_copyright([Locations for Bison parsers in C++],
**
** Avoid duplicate information.
*/
- inline std::ostream& operator<< (std::ostream& ostr, const location& loc)
+ template <typename YYChar>
+ inline std::basic_ostream<YYChar>&
+ operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
{
position last = loc.end - 1;
ostr << loc.begin;
diff --git a/tests/headers.at b/tests/headers.at
index dcf09a7..351b8a7 100644
--- a/tests/headers.at
+++ b/tests/headers.at
@@ -229,14 +229,16 @@ AT_TEST([x8], [%define api.pure %define api.push-pull
both])
# C++ output relies on namespaces and still uses yy a lot.
#
# Check there is no 'YY' left.
-# Ignore comments, YYPARSE_PARAM (obsolete), YYPUSH_MORE(_DEFINED)?
-# (constant definition), YY_\w+_INCLUDED (header guards).
+# Ignore comments, YYChar (template parameter), YYPARSE_PARAM
+# (obsolete), YYPUSH_MORE(_DEFINED)? (constant definition),
+# YY_\w+_INCLUDED (header guards).
#
# YYDEBUG (not renamed) can be read, but not changed.
AT_CHECK([[$PERL -n -0777 -e '
s{/\*.*?\*/}{}gs;
s{//.*}{}g;
- s{\b(YYPARSE_PARAM
+ s{\b(YYChar
+ |YYPARSE_PARAM
|YYPUSH_MORE(_DEFINED)?
|YY_\w+_INCLUDED
|YY_NULL
@@ -244,13 +246,13 @@ AT_CHECK([[$PERL -n -0777 -e '
)\b}{}gx;
while (/^(.*YY.*)$/gm)
{
- print "$ARGV: $1\n";
+ print "$ARGV: invalid exported YY: $1\n";
}
if ($ARGV =~ /\.h$/)
{
while (/^(.*yy.*)$/gm)
{
- print "$ARGV: $1\n";
+ print "$ARGV: invalid exported yy: $1\n";
}
}
' -- *.hh *.h]])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Suggestions for C++ parser generator,
Akim Demaille <=