mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 08:43:03 +00:00
Don't impose std::string for filenames.
* data/lalr1.cc (b4_filename_type): New. (position::filename): Use it. (parser.hh): Move the inclusion of stack.hh and location.hh below the user code, so that needed headers for the filename type can be included first.
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
|||||||
|
2004-12-21 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
Don't impose std::string for filenames.
|
||||||
|
|
||||||
|
* data/lalr1.cc (b4_filename_type): New.
|
||||||
|
(position::filename): Use it.
|
||||||
|
(parser.hh): Move the inclusion of stack.hh and location.hh below
|
||||||
|
the user code, so that needed headers for the filename type can be
|
||||||
|
included first.
|
||||||
|
|
||||||
2004-12-20 Akim Demaille <akim@epita.fr>
|
2004-12-20 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
Use more STL like names: my_class instead of MyClass.
|
Use more STL like names: my_class instead of MyClass.
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ m4_define([b4_rhs_value],
|
|||||||
[(yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3]))])
|
[(yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3]))])
|
||||||
|
|
||||||
m4_define_default([b4_location_type], [location])
|
m4_define_default([b4_location_type], [location])
|
||||||
|
m4_define_default([b4_filename_type], [std::string])
|
||||||
|
|
||||||
# b4_lhs_location()
|
# b4_lhs_location()
|
||||||
# -----------------
|
# -----------------
|
||||||
@@ -118,9 +119,6 @@ b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
|
|||||||
#ifndef PARSER_HEADER_H
|
#ifndef PARSER_HEADER_H
|
||||||
# define PARSER_HEADER_H
|
# define PARSER_HEADER_H
|
||||||
|
|
||||||
#include "stack.hh"
|
|
||||||
#include "location.hh"
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -135,6 +133,9 @@ b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
|
|||||||
]/* Line __line__ of lalr1.cc. */
|
]/* Line __line__ of lalr1.cc. */
|
||||||
b4_syncline([@oline@], [@ofile@])[
|
b4_syncline([@oline@], [@ofile@])[
|
||||||
|
|
||||||
|
#include "stack.hh"
|
||||||
|
#include "location.hh"
|
||||||
|
|
||||||
/* Enabling traces. */
|
/* Enabling traces. */
|
||||||
#ifndef YYDEBUG
|
#ifndef YYDEBUG
|
||||||
# define YYDEBUG ]b4_debug[
|
# define YYDEBUG ]b4_debug[
|
||||||
@@ -1168,7 +1169,7 @@ namespace yy
|
|||||||
public:
|
public:
|
||||||
/// Construct a position.
|
/// Construct a position.
|
||||||
position () :
|
position () :
|
||||||
filename (),
|
filename (0),
|
||||||
line (initial_line),
|
line (initial_line),
|
||||||
column (initial_column)
|
column (initial_column)
|
||||||
{
|
{
|
||||||
@@ -1200,7 +1201,7 @@ namespace yy
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/// File name to which this position refers.
|
/// File name to which this position refers.
|
||||||
std::string filename;
|
]b4_filename_type[* filename;
|
||||||
/// Current line number.
|
/// Current line number.
|
||||||
unsigned int line;
|
unsigned int line;
|
||||||
/// Current column number.
|
/// Current column number.
|
||||||
@@ -1244,8 +1245,8 @@ namespace yy
|
|||||||
inline std::ostream&
|
inline std::ostream&
|
||||||
operator<< (std::ostream& ostr, const position& pos)
|
operator<< (std::ostream& ostr, const position& pos)
|
||||||
{
|
{
|
||||||
if (!pos.filename.empty ())
|
if (pos.filename)
|
||||||
ostr << pos.filename << ':';
|
ostr << *pos.filename << ':';
|
||||||
return ostr << pos.line << '.' << pos.column;
|
return ostr << pos.line << '.' << pos.column;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1347,7 +1348,9 @@ namespace yy
|
|||||||
{
|
{
|
||||||
position last = loc.end - 1;
|
position last = loc.end - 1;
|
||||||
ostr << loc.begin;
|
ostr << loc.begin;
|
||||||
if (loc.begin.filename != last.filename)
|
if (last.filename
|
||||||
|
&& (!loc.begin.filename
|
||||||
|
|| *loc.begin.filename != *last.filename))
|
||||||
ostr << '-' << last;
|
ostr << '-' << last;
|
||||||
else if (loc.begin.line != last.line)
|
else if (loc.begin.line != last.line)
|
||||||
ostr << '-' << last.line << '.' << last.column;
|
ostr << '-' << last.line << '.' << last.column;
|
||||||
|
|||||||
Reference in New Issue
Block a user