# C++ skeleton for Bison
-# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-# Free Software Foundation, Inc.
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
## ---------------- ##
b4_percent_define_default([[parser_class_name]], [[parser]])
-b4_percent_define_default([[location_type]], [[location]])
+
+# Don't do that so that we remember whether we're using a user
+# request, or the default value.
+#
+# b4_percent_define_default([[location_type]], [[location]])
+
b4_percent_define_default([[filename_type]], [[std::string]])
b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix]))
])
+
+
## ----------------- ##
## Semantic Values. ##
## ----------------- ##
typedef YYSTYPE semantic_type;
#endif]b4_locations_if([
/// Symbol locations.
- typedef b4_percent_define_get([[location_type]]) location_type;])[
+ typedef b4_percent_define_get([[location_type]],
+ [[location]]) location_type;])[
+
+ /// Syntax errors thrown from user actions.
+ struct syntax_error : std::runtime_error
+ {
+ syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m);]b4_locations_if([
+ location_type location;])[
+ };
/// Tokens.
struct token
/// Default constructor.
inline symbol_type ();
- /// Constructor.
- inline symbol_type (]b4_args([int t],
+ /// Constructor for tokens with semantic value.
+ inline symbol_type (]b4_args([token_type t],
[const semantic_type& v],
b4_locations_if([const location_type& l]))[);
- inline symbol_type (]b4_args([int t],
+ /// Constructor for valueless tokens.
+ inline symbol_type (]b4_args([token_type t],
b4_locations_if([const location_type& l]))[);
/// The symbol type.
int type;
- /// Return the type corresponding to this state.
+ /// The symbol type.
inline int type_get_ () const;
- /// Its token.
+ /// The token.
inline token_type token () const;
};
]b4_symbol_constructor_declare])
# ----------------------
# Provide the implementation needed by the public types.
m4_define([b4_public_types_define],
-[[ // symbol_base_type.
+[[ inline
+ ]b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m)
+ : std::runtime_error (m)]b4_locations_if([
+ , location (l)])[
+ {}
+
+ // symbol_base_type.
template <typename Exact>
+ inline
]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type ()
: value()]b4_locations_if([
, location()])[
inline
]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
- [int t],
+ [token_type t],
b4_locations_if([const location_type& l]))[)
: super_type (]b4_locations_if([l])[)
- , type (t)
+ , type (yytranslate_ (t))
{
}
inline
]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
- [int t],
+ [token_type t],
[const semantic_type& v],
b4_locations_if([const location_type& l]))[)
: super_type (v]b4_locations_if([, l])[)
- , type (t)
+ , type (yytranslate_ (t))
{
}
# Extra initialisations of the constructor.
m4_define([b4_parse_param_cons],
[m4_ifset([b4_parse_param],
- [
+ [
b4_cc_constructor_calls(b4_parse_param)])])
m4_define([b4_cc_constructor_calls],
- [m4_map_sep([b4_cc_constructor_call], [,
+ [m4_map_sep([b4_cc_constructor_call], [,
], [$@])])
m4_define([b4_cc_constructor_call],
- [$2 ($2_yyarg)])
+ [$2 ($2_yyarg)])
# b4_parse_param_vars
# -------------------
# Extra instance variables.
m4_define([b4_parse_param_vars],
[m4_ifset([b4_parse_param],
- [
+ [
/* User arguments. */
b4_cc_var_decls(b4_parse_param)])])
m4_define([b4_cc_var_decls],
- [m4_map_sep([b4_cc_var_decl], [
+ [m4_map_sep([b4_cc_var_decl], [
], [$@])])
m4_define([b4_cc_var_decl],
- [ $1;])
+ [ $1;])