mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
* data/c.m4 (b4_location_initial_column, b4_location_initial_line):
New, default to 1. * data/yacc.c, data/glr.c, data/location.cc: Use them. * NEWS, doc/bison.texinfo: The initial column and line are 1 by default. * tests/calc.at: Adjust.
This commit is contained in:
@@ -91,6 +91,11 @@ m4_define_default([b4_epilogue], [])
|
||||
# If the %union is not named, its name is YYSTYPE.
|
||||
m4_define_default([b4_union_name], [YYSTYPE])
|
||||
|
||||
# The initial column and line.
|
||||
m4_define_default([b4_location_initial_column], [1])
|
||||
m4_define_default([b4_location_initial_line], [1])
|
||||
|
||||
|
||||
## ------------------------ ##
|
||||
## Pure/impure interfaces. ##
|
||||
## ------------------------ ##
|
||||
|
||||
@@ -2303,8 +2303,8 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
yylval = yyval_default;
|
||||
]b4_locations_if([
|
||||
#if YYLTYPE_IS_TRIVIAL
|
||||
yylloc.first_line = yylloc.last_line = 1;
|
||||
yylloc.first_column = yylloc.last_column = 0;
|
||||
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
|
||||
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
|
||||
#endif
|
||||
])
|
||||
m4_ifdef([b4_initial_action], [
|
||||
|
||||
@@ -36,6 +36,7 @@ b4_copyright([Positions for Bison parsers in C++],
|
||||
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
# include <algorithm>
|
||||
|
||||
namespace ]b4_namespace[
|
||||
{
|
||||
@@ -46,7 +47,7 @@ namespace ]b4_namespace[
|
||||
]m4_ifdef([b4_location_constructors], [
|
||||
/// Construct a position.
|
||||
position ()
|
||||
: filename (0), line (1), column (0)
|
||||
: filename (0), line (]b4_location_initial_line[), column (]b4_location_initial_column[)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,8 +56,8 @@ namespace ]b4_namespace[
|
||||
inline void initialize (]b4_filename_type[* fn)
|
||||
{
|
||||
filename = fn;
|
||||
line = 1;
|
||||
column = 0;
|
||||
line = ]b4_location_initial_line[;
|
||||
column = ]b4_location_initial_column[;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
@@ -65,19 +66,14 @@ namespace ]b4_namespace[
|
||||
/// (line related) Advance to the COUNT next lines.
|
||||
inline void lines (int count = 1)
|
||||
{
|
||||
column = 0;
|
||||
column = ]b4_location_initial_column[;
|
||||
line += count;
|
||||
}
|
||||
|
||||
/// (column related) Advance to the COUNT next columns.
|
||||
inline void columns (int count = 1)
|
||||
{
|
||||
int leftmost = 0;
|
||||
int current = column;
|
||||
if (leftmost <= current + count)
|
||||
column += count;
|
||||
else
|
||||
column = 0;
|
||||
column = std::max (]b4_location_initial_column[u, column + count);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
|
||||
@@ -1064,8 +1064,8 @@ b4_c_function_def([yyparse], [int], b4_parse_param)
|
||||
]b4_locations_if([[ yylsp = yyls;
|
||||
#if YYLTYPE_IS_TRIVIAL
|
||||
/* Initialize the default location before parsing starts. */
|
||||
yylloc.first_line = yylloc.last_line = 1;
|
||||
yylloc.first_column = yylloc.last_column = 0;
|
||||
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
|
||||
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
|
||||
#endif
|
||||
]])
|
||||
m4_ifdef([b4_initial_action], [
|
||||
|
||||
Reference in New Issue
Block a user