[(yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3]))])
m4_define_default([b4_location_type], [location])
+m4_define_default([b4_filename_type], [std::string])
# b4_lhs_location()
# -----------------
#ifndef PARSER_HEADER_H
# define PARSER_HEADER_H
-#include "stack.hh"
-#include "location.hh"
-
#include <string>
#include <iostream>
]/* Line __line__ of lalr1.cc. */
b4_syncline([@oline@], [@ofile@])[
+#include "stack.hh"
+#include "location.hh"
+
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG ]b4_debug[
public:
/// Construct a position.
position () :
- filename (),
+ filename (0),
line (initial_line),
column (initial_column)
{
public:
/// File name to which this position refers.
- std::string filename;
+ ]b4_filename_type[* filename;
/// Current line number.
unsigned int line;
/// Current column number.
inline std::ostream&
operator<< (std::ostream& ostr, const position& pos)
{
- if (!pos.filename.empty ())
- ostr << pos.filename << ':';
+ if (pos.filename)
+ ostr << *pos.filename << ':';
return ostr << pos.line << '.' << pos.column;
}
{
position last = loc.end - 1;
ostr << loc.begin;
- if (loc.begin.filename != last.filename)
+ if (last.filename
+ && (!loc.begin.filename
+ || *loc.begin.filename != *last.filename))
ostr << '-' << last;
else if (loc.begin.line != last.line)
ostr << '-' << last.line << '.' << last.column;