projects
/
bison.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
xml: beware of user strings used to give a %prec to rules.
[bison.git]
/
examples
/
variant.yy
diff --git
a/examples/variant.yy
b/examples/variant.yy
index fe5dce0fa9219b7b85ee1a4997c38fcf7f6a3c22..8471e6e8adc6ba033fd9ce6cbf0c6e8584f1c436 100644
(file)
--- a/
examples/variant.yy
+++ b/
examples/variant.yy
@@
-1,8
+1,10
@@
%debug
%skeleton "lalr1.cc"
%defines
%debug
%skeleton "lalr1.cc"
%defines
+%define assert
%define variant
%define lex_symbol
%define variant
%define lex_symbol
+%locations
%code requires // *.hh
{
%code requires // *.hh
{
@@
-85,26
+87,28
@@
yy::parser::symbol_type
yylex ()
{
static int stage = -1;
yylex ()
{
static int stage = -1;
- switch (++stage)
+ ++stage;
+ yy::parser::location_type loc(0, stage + 1, stage + 1);
+ switch (stage)
{
case 0:
{
case 0:
- return yy::parser::make_TEXT ("I have three numbers for you.");
+ return yy::parser::make_TEXT ("I have three numbers for you."
, loc
);
case 1:
case 2:
case 3:
case 1:
case 2:
case 3:
- return yy::parser::make_NUMBER (stage);
+ return yy::parser::make_NUMBER (stage
, loc
);
case 4:
case 4:
- return yy::parser::make_TEXT ("And that's all!");
+ return yy::parser::make_TEXT ("And that's all!"
, loc
);
default:
default:
- return yy::parser::make_END_OF_FILE ();
+ return yy::parser::make_END_OF_FILE (
loc
);
}
}
// Mandatory error function
void
}
}
// Mandatory error function
void
-yy::parser::error (const
std::string& message
)
+yy::parser::error (const
yy::parser::location_type& loc, const std::string& msg
)
{
{
- std::cerr <<
message
<< std::endl;
+ std::cerr <<
loc << ": " << msg
<< std::endl;
}
int
}
int