* configure.ac (GXX): Rename as...

(CXX): this, to keep the original Autoconf semantics.
Require 2.57.
* data/lalr1.cc: Fix b4_copyright invocations.
If YYDEBUG is not defined, don't depend upon name_ being defined.
(location.hh): Include string and iostream.
(Position::filename): New member.
(Position::Position ()): New.
(operator<< (Position)): New.
(operator- (Position, int)): New.
(Location::first, Location::last): Rename as...
(Location::begin, Location::end): these, to mock the conventional
iterator names.
(operator<< (Location)): New.
* tests/atlocal.in (CXX): New.
* tests/testsuite.at (AT_COMPILE_CXX): New.
* tests/calc.at (_AT_DATA_CALC_Y): Adjust yyerror to report the
locations in a more synthetic way.
(AT_CHECK_PUSHDEFS): AT_YYERROR_SEES_LOC_IF is positive if
lalr1.cc is used.
Adjust the C locations to match those from Emacs: first column is
column 0.
Change all the expected results.
Conform to the GCS: simplify the locations when applicable.
(LOC, VAL, YYLLOC_FORMAL, YYLLOC_ARG, USE_YYLLOC, LEX_FORMALS)
(LEX_ARGS, USE_LEX_ARGS, LEX_PRE_FORMALS, LEX_PRE_ARGS): Replace
these CPP macros with the m4 macros new defined by...
(AT_CHECK_PUSHDEFS): this, i.e.:
(AT_LALR1_CC_IF, AT_PURE_LEX_IF, AT_LOC, AT_VAL, AT_LEX_FORMALS)
(AT_LEX_ARGS, AT_USE_LEX_ARGS, AT_LEX_PRE_FORMALSm AT_LEX_PRE_ARGS)
New macros.
(AT_CHECK_POPDEFS): Undefine them.
(AT_CHECK_CALC_LALR1_CC): New.
Use it for the first lalr1.cc test.
This commit is contained in:
Akim Demaille
2003-02-06 10:04:29 +00:00
parent d5a3fe37a9
commit 7548fed236
6 changed files with 288 additions and 102 deletions

View File

@@ -140,7 +140,7 @@ b4_syncline([@oline@], [@ofile@])],
b4_syncline([@oline@], [@ofile@])[
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
Current.last = Rhs[N].last;
Current.end = Rhs[N].end;
#endif
namespace yy
@@ -525,8 +525,10 @@ b4_syncline([@oline@], [@ofile@])[
/* Return failure if at end of input. */
if (looka_ == eof_)
goto yyabortlab;
#if YYDEBUG
YYCDEBUG << "Discarding token " << looka_
<< " (" << name_[ilooka_] << ")." << std::endl;
<< " (" << name_[ilooka_] << ")." << std::endl;
#endif
looka_ = empty_;
}
@@ -768,7 +770,7 @@ const yy::]b4_parser_class_name[::TokenNumberType yy::]b4_parser_class_name[::un
]b4_epilogue
dnl
@output stack.hh
b4_copyright([2002, 2003])[
b4_copyright([Stack handling for Bison C++ parsers], [2002, 2003])[
#ifndef BISON_STACK_HH
# define BISON_STACK_HH
@@ -865,24 +867,69 @@ namespace yy
#endif // not BISON_STACK_HH]
dnl
@output location.hh
b4_copyright([2002, 2003])[
b4_copyright([Location class for Bison C++ parsers], [2002, 2003])[
#ifndef BISON_LOCATION_HH
# define BISON_LOCATION_HH
# include <iostream>
# include <string>
namespace yy
{
struct Position
class Position
{
public:
Position ()
: filename (), line (1), column (0)
{}
std::string filename;
int line;
int column;
};
struct Location
inline std::ostream&
operator<< (std::ostream& ostr, const Position& pos)
{
Position first;
Position last;
if (pos.filename != "")
ostr << pos.filename << ':';
ostr << pos.line << '.' << pos.column;
return ostr;
}
inline Position
operator- (const Position& pos, int col)
{
Position res (pos);
res.column -= col;
return res;
}
class Location
{
public:
Position begin;
Position end;
};
/* Don't issue twice the line number when the location is on a single
line. */
inline std::ostream&
operator<< (std::ostream& ostr, const Location& pos)
{
ostr << pos.begin;
if (pos.begin.filename != pos.end.filename)
ostr << '-' << pos.end - 1;
else if (pos.begin.line != pos.end.line)
ostr << '-' << pos.end.line << '.' << pos.end.column - 1;
else if (pos.begin.column != pos.end.column - 1)
ostr << '-' << pos.end.column - 1;
return ostr;
}
}
#endif // not BISON_LOCATION_HH]