// Copyright (c) 2001-2007 Joel de Guzman // Copyright (c) 2001-2008 Hartmut Kaiser // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if !defined(BOOST_SPIRIT_LEX_LEXER_META_GRAMMAR_MAR_22_2007_0548PM) #define BOOST_SPIRIT_LEX_LEXER_META_GRAMMAR_MAR_22_2007_0548PM #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once // MS compatible compilers support #pragma once #endif #include #include #include #include #include #include #include namespace boost { namespace spirit { namespace lex { /////////////////////////////////////////////////////////////////////////// // forward declarations /////////////////////////////////////////////////////////////////////////// struct terminal_director; struct sequence; struct action; struct string_token_def; struct char_token_def; struct lexer_meta_grammar; template struct is_valid_expr; template struct expr_transform; /////////////////////////////////////////////////////////////////////////// // main lexer_meta_grammar in the lex namespace /////////////////////////////////////////////////////////////////////////// struct token_def_meta_grammar : proto::or_< // token_def<> meta_grammar::terminal_rule< lex::domain, terminal_holder >, terminal_director >, // token_set meta_grammar::terminal_rule< lex::domain, terminal_holder >, terminal_director > > { }; // 'x', L'x', "x", L"x", std::string, std::wstring struct literal_token_def_meta_grammar : proto::or_< meta_grammar::terminal_rule< lex::domain, char, char_token_def >, meta_grammar::terminal_rule< lex::domain, wchar_t, char_token_def >, meta_grammar::terminal_rule< lex::domain, char const*, string_token_def >, meta_grammar::terminal_rule< lex::domain, wchar_t const*, string_token_def >, meta_grammar::terminal_rule< lex::domain, std::basic_string, string_token_def >, meta_grammar::terminal_rule< lex::domain, std::basic_string, string_token_def > > { }; struct action_lexer_meta_grammar : proto::or_< // semantic actions for tokens meta_grammar::binary_rule< lex::domain, proto::tag::subscript, action, token_def_meta_grammar, proto::when >, meta_grammar::binary_rule< lex::domain, proto::tag::subscript, action, action_lexer_meta_grammar, proto::when > > { }; struct lexer_meta_grammar : proto::or_< // token_def<>, ' ', L' ', "...", L"...", std::string, std::wstring token_def_meta_grammar, literal_token_def_meta_grammar, // token_def[...] action_lexer_meta_grammar, // sequence delimited by '|' meta_grammar::binary_rule_flat< lex::domain, proto::tag::bitwise_or, sequence, lexer_meta_grammar > > { }; /////////////////////////////////////////////////////////////////////////// // These specializations non-intrusively hook into the Lex meta-grammar. // (see lex/meta_grammar.hpp) /////////////////////////////////////////////////////////////////////////// template struct is_valid_expr< Expr, typename enable_if< proto::matches >::type > : mpl::true_ { }; template struct expr_transform< Expr, typename enable_if< proto::matches >::type > : mpl::identity { }; }}} #endif