/// (External) token type, as returned by yylex.
typedef token::yytokentype token_type;
- /// Internal symbol number.
+ /// Symbol type: an internal symbol number.
typedef int symbol_number_type;
+ /// The symbol type number to denote an empty symbol.
+ enum { empty_symbol = -2 };
+
/// Internal symbol number for tokens (subsumed by symbol_number_type).
typedef ]b4_int_type_for([b4_translate])[ token_number_type;
/// Destroy the symbol.
~basic_symbol ();
+ /// Whether empty.
+ bool empty () const;
+
/// Destructive move, \a s is emptied into this.
void move (basic_symbol& s);
/// The token.
token_type token () const;
- /// The type number used to denote an empty symbol.
- enum { empty = 0 };
-
/// The symbol type.
- /// \a empty when empty.
- token_number_type type;
+ /// \a empty_symbol when empty.
+ /// An int, not token_number_type, to be able to store empty_symbol.
+ int type;
};
/// "External" symbols: returned by the scanner.
]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
}
+ template <typename Base>
+ inline
+ bool
+ ]b4_parser_class_name[::basic_symbol<Base>::empty () const
+ {
+ return Base::type_get () == empty_symbol;
+ }
+
template <typename Base>
inline
void
// by_type.
inline
]b4_parser_class_name[::by_type::by_type ()
- : type (empty)
+ : type (empty_symbol)
{}
inline
]b4_parser_class_name[::by_type::move (by_type& that)
{
type = that.type;
- that.type = empty;
+ that.type = empty_symbol;
}
inline
/// Generate an error message.
/// \param yystate the state where the error occurred.
- /// \param yytoken the lookahead token type, or yyempty_.
+ /// \param yytoken the lookahead token type, or empty_symbol.
virtual std::string yysyntax_error_ (state_type yystate,
symbol_number_type yytoken) const;
void move (by_state& that);
/// The (internal) type number (corresponding to \a state).
- /// \a empty when empty.
+ /// \a empty_symbol when empty.
symbol_number_type type_get () const;
/// The state number used to denote an empty symbol.
- enum { empty = 0 };
+ enum { empty_state = -1 };
/// The state.
/// \a empty when empty.
yyeof_ = 0,
yylast_ = ]b4_last[, ///< Last index in yytable_.
yynnts_ = ]b4_nterms_number[, ///< Number of nonterminal symbols.
- yyempty_ = -2,
yyfinal_ = ]b4_final_state_number[, ///< Termination state number.
yyterror_ = 1,
yyerrcode_ = 256,
// by_state.
inline
]b4_parser_class_name[::by_state::by_state ()
- : state (empty)
+ : state (empty_state)
{}
inline
]b4_parser_class_name[::by_state::move (by_state& that)
{
state = that.state;
- that.state = empty;
+ that.state = empty_state;
}
inline
]b4_parser_class_name[::symbol_number_type
]b4_parser_class_name[::by_state::type_get () const
{
- return state == empty ? 0 : yystos_[state];
+ return state == empty_state ? empty_symbol : yystos_[state];
}
inline
[value], [move], [that.value])],
[[value = that.value;]])[
// that is emptied.
- that.type = empty;
+ that.type = empty_symbol;
}
inline
++yynerrs_;
error (]b4_join(b4_locations_if([yyla.location]),
[[yysyntax_error_ (yystack_[0].state,
- yyempty ? yyempty_ : yyla.type_get ())]])[);
+ yyempty ? empty_symbol : yyla.type_get ())]])[);
}
]b4_locations_if([[
token that will not be accepted due to an error action in a
later state.
*/
- if (yytoken != yyempty_)
+ if (yytoken != empty_symbol)
{
yyarg[yycount++] = yytname_[yytoken];
int yyn = yypact_[yystate];