|
Boost-Commit : |
From: joel_at_[hidden]
Date: 2008-07-11 11:30:26
Author: djowel
Date: 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
New Revision: 47313
URL: http://svn.boost.org/trac/boost/changeset/47313
Log:
no more grammar_def
Text files modified:
trunk/libs/spirit/example/qi/Jamfile | 10 ++++--
trunk/libs/spirit/example/qi/calc1.cpp | 7 ++--
trunk/libs/spirit/example/qi/calc2.cpp | 7 ++--
trunk/libs/spirit/example/qi/calc2_ast.cpp | 7 ++--
trunk/libs/spirit/example/qi/calc3.cpp | 7 ++--
trunk/libs/spirit/example/qi/calc3_lexer.cpp | 7 ++--
trunk/libs/spirit/example/qi/calc4.cpp | 6 ++--
trunk/libs/spirit/example/qi/calc5.cpp | 9 ++---
trunk/libs/spirit/example/qi/calc6/calc6.cpp | 7 ++--
trunk/libs/spirit/example/qi/calc6/calc6.hpp | 7 ++--
trunk/libs/spirit/example/qi/calc6/calc6b.hpp | 3 +
trunk/libs/spirit/example/qi/calc6/calc6c.hpp | 6 ++--
trunk/libs/spirit/example/qi/calc7/calc7.cpp | 8 ++---
trunk/libs/spirit/example/qi/calc7/calc7.hpp | 7 ++--
trunk/libs/spirit/example/qi/calc7/calc7b.hpp | 3 +
trunk/libs/spirit/example/qi/calc7/calc7c.hpp | 6 ++--
trunk/libs/spirit/example/qi/employee.cpp | 7 ++--
trunk/libs/spirit/example/qi/mini_c/mini_c.cpp | 12 +++----
trunk/libs/spirit/example/qi/mini_c/mini_c.hpp | 22 ++++++--------
trunk/libs/spirit/example/qi/mini_c/mini_cb.hpp | 3 +
trunk/libs/spirit/example/qi/mini_c/mini_cc.hpp | 6 ++--
trunk/libs/spirit/example/qi/mini_c/mini_cd.hpp | 14 ++++----
trunk/libs/spirit/example/qi/mini_xml1.cpp | 9 ++---
trunk/libs/spirit/example/qi/mini_xml2.cpp | 12 ++++----
trunk/libs/spirit/example/qi/roman.cpp | 7 ++--
trunk/libs/spirit/test/Jamfile | 43 -----------------------------
trunk/libs/spirit/test/qi/grammar.cpp | 59 +++++++++++----------------------------
trunk/libs/spirit/test/qi/grammar_fail.cpp | 7 ++--
28 files changed, 115 insertions(+), 193 deletions(-)
Modified: trunk/libs/spirit/example/qi/Jamfile
==============================================================================
--- trunk/libs/spirit/example/qi/Jamfile (original)
+++ trunk/libs/spirit/example/qi/Jamfile 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -4,12 +4,16 @@
# 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)
#==============================================================================
-project spirit-qi-example ;
+project spirit-qi-example
+ : requirements <toolset>gcc:<cxxflags>-ftemplate-depth-300
+ :
+ :
+ ;
-exe actions : actions.cpp ;
+exe actions_ : actions.cpp ;
exe sum : sum.cpp ;
exe complex_number : complex_number.cpp ;
-exe employee : employee.cpp ;
+exe employee : employee.cpp ;
exe roman : roman.cpp ;
exe mini_xml1 : mini_xml1.cpp ;
exe mini_xml2 : mini_xml2.cpp ;
Modified: trunk/libs/spirit/example/qi/calc1.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc1.cpp (original)
+++ trunk/libs/spirit/example/qi/calc1.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -27,9 +27,9 @@
// Our calculator grammar
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct calculator : grammar_def<Iterator, space_type>
+struct calculator : grammar<Iterator, space_type>
{
- calculator()
+ calculator() : grammar<Iterator, space_type>(expression)
{
expression =
term
@@ -70,8 +70,7 @@
typedef std::string::const_iterator iterator_type;
typedef calculator<iterator_type> calculator;
- calculator def; // Our grammar definition
- grammar<calculator> calc(def, def.expression); // Our grammar
+ calculator calc; // Our grammar
std::string str;
while (std::getline(std::cin, str))
Modified: trunk/libs/spirit/example/qi/calc2.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc2.cpp (original)
+++ trunk/libs/spirit/example/qi/calc2.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -42,9 +42,9 @@
// Our calculator grammar
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct calculator : grammar_def<Iterator, space_type>
+struct calculator : grammar<Iterator, space_type>
{
- calculator()
+ calculator() : grammar<Iterator, space_type>(expression)
{
expression =
term
@@ -85,8 +85,7 @@
typedef std::string::const_iterator iterator_type;
typedef calculator<iterator_type> calculator;
- calculator def; // Our grammar definition
- grammar<calculator> calc(def, def.expression); // Our grammar
+ calculator calc; // Our grammar
std::string str;
while (std::getline(std::cin, str))
Modified: trunk/libs/spirit/example/qi/calc2_ast.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc2_ast.cpp (original)
+++ trunk/libs/spirit/example/qi/calc2_ast.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -130,9 +130,9 @@
// Our calculator grammar
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct calculator : grammar_def<Iterator, expression_ast(), space_type>
+struct calculator : grammar<Iterator, expression_ast(), space_type>
{
- calculator()
+ calculator() : grammar<Iterator, expression_ast(), space_type>(expression)
{
expression =
term [_val = _1]
@@ -173,8 +173,7 @@
typedef std::string::const_iterator iterator_type;
typedef calculator<iterator_type> calculator;
- calculator def; // Our grammar definition
- grammar<calculator> calc(def, def.expression); // Our grammar
+ calculator calc; // Our grammar
std::string str;
while (std::getline(std::cin, str))
Modified: trunk/libs/spirit/example/qi/calc3.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc3.cpp (original)
+++ trunk/libs/spirit/example/qi/calc3.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -31,9 +31,9 @@
// Our calculator grammar
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct calculator : grammar_def<Iterator, int(), space_type>
+struct calculator : grammar<Iterator, int(), space_type>
{
- calculator()
+ calculator() : grammar<Iterator, int(), space_type>(expression)
{
expression =
term [_val = _1]
@@ -74,8 +74,7 @@
typedef std::string::const_iterator iterator_type;
typedef calculator<iterator_type> calculator;
- calculator def; // Our grammar definition
- grammar<calculator> calc(def, def.expression); // Our grammar
+ calculator calc; // Our grammar
std::string str;
int result;
Modified: trunk/libs/spirit/example/qi/calc3_lexer.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc3_lexer.cpp (original)
+++ trunk/libs/spirit/example/qi/calc3_lexer.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -88,10 +88,11 @@
// use a defined tokenset from above as the skip parser.
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator, typename Lexer>
-struct calculator : grammar_def<Iterator, int(), typename Lexer::token_set>
+struct calculator : grammar<Iterator, int(), typename Lexer::token_set>
{
template <typename TokenDef>
- calculator(TokenDef const& tok)
+ calculator(TokenDef const& tok)
+ : grammar<Iterator, int(), typename Lexer::token_set>(expression)
{
// grammar
expression =
@@ -160,7 +161,7 @@
calculator def (tokens); // Our grammar definition
lexer<calculator_tokens> lex(tokens); // Our lexer
- grammar<calculator> calc(def, def.expression); // Our grammar
+ calculator calc; // Our grammar
// get input line by line and feed the parser to evaluate the expressions
// read in from the input
Modified: trunk/libs/spirit/example/qi/calc4.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc4.cpp (original)
+++ trunk/libs/spirit/example/qi/calc4.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -33,9 +33,9 @@
// Our calculator grammar
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct calculator : grammar_def<Iterator, int(), space_type>
+struct calculator : grammar<Iterator, int(), space_type>
{
- calculator()
+ calculator() : grammar<Iterator, int(), space_type>(expression)
{
expression =
term [_val = _1]
@@ -93,7 +93,7 @@
typedef calculator<iterator_type> calculator;
calculator def; // Our grammar definition
- grammar<calculator> calc(def, def.expression); // Our grammar
+ calculator calc; // Our grammar
std::string str;
int result;
Modified: trunk/libs/spirit/example/qi/calc5.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc5.cpp (original)
+++ trunk/libs/spirit/example/qi/calc5.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -114,10 +114,11 @@
// Our calculator grammar and compiler
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct calculator : grammar_def<Iterator, space_type>
+struct calculator : grammar<Iterator, space_type>
{
calculator(std::vector<int>& code)
- : code(code)
+ : grammar<Iterator, space_type>(expression)
+ , code(code)
{
expression =
term
@@ -203,9 +204,7 @@
vmachine mach; // Our virtual machine
std::vector<int> code; // Our VM code
- calculator def(code); // Our grammar definition
- grammar<calculator>
- calc(def, def.expression); // Our grammar
+ calculator calc(code); // Our grammar
std::string str;
while (std::getline(std::cin, str))
Modified: trunk/libs/spirit/example/qi/calc6/calc6.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc6/calc6.cpp (original)
+++ trunk/libs/spirit/example/qi/calc6/calc6.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -74,8 +74,7 @@
vmachine mach; // Our virtual machine
std::vector<int> code; // Our VM code
- statement def(code); // Our grammar definition
- grammar<statement> calc(def); // Our grammar
+ statement calc(code); // Our grammar
std::string str;
std::string program;
@@ -88,10 +87,10 @@
if (::compile(calc, program))
{
- mach.execute(code, def.nvars);
+ mach.execute(code, calc.nvars);
std::cout << "Results------------------\n\n";
- def.vars.for_each(var_printer(mach.get_stack()));
+ calc.vars.for_each(var_printer(mach.get_stack()));
std::cout << "-------------------------\n\n";
}
Modified: trunk/libs/spirit/example/qi/calc6/calc6.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc6/calc6.hpp (original)
+++ trunk/libs/spirit/example/qi/calc6/calc6.hpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -125,7 +125,7 @@
// Our expression grammar and compiler
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct expression : grammar_def<Iterator, space_type>
+struct expression : grammar<Iterator, space_type>
{
expression(std::vector<int>& code, symbols<char, int>& vars);
@@ -160,7 +160,7 @@
};
template <typename Iterator>
-struct statement : grammar_def<Iterator, space_type>
+struct statement : grammar<Iterator, space_type>
{
statement(std::vector<int>& code);
@@ -168,8 +168,7 @@
symbols<char, int> vars;
int nvars;
- expression<Iterator> expr_def;
- grammar<expression<Iterator> > expr;
+ expression<Iterator> expr;
rule<Iterator, space_type> start, var_decl;
rule<Iterator, std::string(), space_type> identifier;
rule<Iterator, int(), space_type> var_ref;
Modified: trunk/libs/spirit/example/qi/calc6/calc6b.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc6/calc6b.hpp (original)
+++ trunk/libs/spirit/example/qi/calc6/calc6b.hpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -14,7 +14,8 @@
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
expression<Iterator>::expression(std::vector<int>& code, symbols<char, int>& vars)
- : code(code)
+ : grammar<Iterator, space_type>(expr)
+ , code(code)
, vars(vars)
, op(code)
{
Modified: trunk/libs/spirit/example/qi/calc6/calc6c.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc6/calc6c.hpp (original)
+++ trunk/libs/spirit/example/qi/calc6/calc6c.hpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -14,10 +14,10 @@
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
statement<Iterator>::statement(std::vector<int>& code)
- : code(code)
+ : grammar<Iterator, space_type>(start)
+ , code(code)
, nvars(0)
- , expr_def(code, vars)
- , expr(expr_def, expr_def.expr)
+ , expr(code, vars)
, add_var(vars)
, op(code)
{
Modified: trunk/libs/spirit/example/qi/calc7/calc7.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc7/calc7.cpp (original)
+++ trunk/libs/spirit/example/qi/calc7/calc7.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -70,9 +70,7 @@
vmachine mach; // Our virtual machine
std::vector<int> code; // Our VM code
- statement def(code); // Our grammar definition
- grammar<statement>
- calc(def, def.statement_list); // Our grammar
+ statement calc(code); // Our grammar
std::string str;
std::string program;
@@ -85,10 +83,10 @@
if (::compile(calc, program))
{
- mach.execute(code, def.nvars);
+ mach.execute(code, calc.nvars);
std::cout << "Results------------------\n\n";
- def.vars.for_each(var_printer(mach.get_stack()));
+ calc.vars.for_each(var_printer(mach.get_stack()));
std::cout << "-------------------------\n\n";
}
Modified: trunk/libs/spirit/example/qi/calc7/calc7.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc7/calc7.hpp (original)
+++ trunk/libs/spirit/example/qi/calc7/calc7.hpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -144,7 +144,7 @@
// Our expression grammar and compiler
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct expression : grammar_def<Iterator, space_type>
+struct expression : grammar<Iterator, space_type>
{
expression(std::vector<int>& code, symbols<char, int>& vars);
@@ -181,7 +181,7 @@
};
template <typename Iterator>
-struct statement : grammar_def<Iterator, space_type>
+struct statement : grammar<Iterator, space_type>
{
statement(std::vector<int>& code);
@@ -189,8 +189,7 @@
symbols<char, int> vars;
int nvars;
- expression<Iterator> expr_def;
- grammar<expression<Iterator> > expr;
+ expression<Iterator> expr;
rule<Iterator, space_type>
statement_, statement_list, var_decl, compound_statement
;
Modified: trunk/libs/spirit/example/qi/calc7/calc7b.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc7/calc7b.hpp (original)
+++ trunk/libs/spirit/example/qi/calc7/calc7b.hpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -14,7 +14,8 @@
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
expression<Iterator>::expression(std::vector<int>& code, symbols<char, int>& vars)
- : code(code)
+ : grammar<Iterator, space_type>(expr)
+ , code(code)
, vars(vars)
, op(code)
{
Modified: trunk/libs/spirit/example/qi/calc7/calc7c.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/calc7/calc7c.hpp (original)
+++ trunk/libs/spirit/example/qi/calc7/calc7c.hpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -14,10 +14,10 @@
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
statement<Iterator>::statement(std::vector<int>& code)
- : code(code)
+ : grammar<Iterator, space_type>(statement_list)
+ , code(code)
, nvars(0)
- , expr_def(code, vars)
- , expr(expr_def, expr_def.expr)
+ , expr(code, vars)
, add_var(vars)
, op(code)
{
Modified: trunk/libs/spirit/example/qi/employee.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/employee.cpp (original)
+++ trunk/libs/spirit/example/qi/employee.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -56,9 +56,9 @@
// Our employee parser
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct employee_parser : grammar_def<Iterator, employee(), space_type>
+struct employee_parser : grammar<Iterator, employee(), space_type>
{
- employee_parser()
+ employee_parser() : grammar<Iterator, employee(), space_type>(start)
{
quoted_string %= lexeme['"' >> +(char_ - '"') >> '"'];
@@ -95,8 +95,7 @@
typedef std::string::const_iterator iterator_type;
typedef employee_parser<iterator_type> employee_parser;
- employee_parser def; // Our grammar definition
- grammar<employee_parser> g(def); // Our grammar
+ employee_parser g; // Our grammar
std::string str;
while (getline(std::cin, str))
{
Modified: trunk/libs/spirit/example/qi/mini_c/mini_c.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/mini_c/mini_c.cpp (original)
+++ trunk/libs/spirit/example/qi/mini_c/mini_c.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -19,13 +19,12 @@
template <typename Grammar>
bool compile(Grammar const& prog, std::string const& expr)
{
- typedef white_space_def<std::string::const_iterator> white_space_def;
- white_space_def white_; // Our skipper definition
- grammar<white_space_def> white_space(white_); // Our skipper
+ typedef white_space<std::string::const_iterator> white_space;
+ white_space ws; // Our skipper
std::string::const_iterator iter = expr.begin();
std::string::const_iterator end = expr.end();
- bool r = phrase_parse(iter, end, prog, white_space);
+ bool r = phrase_parse(iter, end, prog, ws);
if (r && iter == end)
{
@@ -80,14 +79,13 @@
vmachine mach; // Our virtual machine
std::vector<int> code; // Our VM code
- program def(code); // Our grammar definition
- grammar<program> prog(def); // Our grammar
+ program prog(code); // Our grammar definition
if (::compile(prog, source_code))
{
std::string fmain("main");
std::string::iterator fbegin = fmain.begin();
- function_info* f = def.functions.lookup()->find(fbegin, fmain.end());
+ function_info* f = prog.functions.lookup()->find(fbegin, fmain.end());
if (f == 0)
{
std::cerr << "Error: main function not defined" << std::endl;
Modified: trunk/libs/spirit/example/qi/mini_c/mini_c.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/mini_c/mini_c.hpp (original)
+++ trunk/libs/spirit/example/qi/mini_c/mini_c.hpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -246,9 +246,9 @@
// White-space and comments grammar definition
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct white_space_def : grammar_def<Iterator>
+struct white_space : grammar<Iterator>
{
- white_space_def()
+ white_space() : grammar<Iterator>(start)
{
start =
space // tab/space/cr/lf
@@ -263,14 +263,14 @@
// Our expression grammar and compiler
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct expression : grammar_def<Iterator, grammar<white_space_def<Iterator> > >
+struct expression : grammar<Iterator, white_space<Iterator> >
{
expression(
std::vector<int>& code
, symbols<char, int>& vars
, symbols<char, function_info>& functions);
- typedef grammar<white_space_def<Iterator> > white_space;
+ typedef white_space<Iterator> white_space;
rule<Iterator, white_space>
expr, equality_expr, relational_expr
@@ -290,11 +290,11 @@
// Our statement grammar and compiler
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct statement : grammar_def<Iterator, grammar<white_space_def<Iterator> > >
+struct statement : grammar<Iterator, white_space<Iterator> >
{
statement(std::vector<int>& code, symbols<char, function_info>& functions);
- typedef grammar<white_space_def<Iterator> > white_space;
+ typedef white_space<Iterator> white_space;
std::vector<int>& code;
symbols<char, int> vars;
@@ -302,8 +302,7 @@
int nvars;
bool has_return;
- expression<Iterator> expr_def;
- grammar<expression<Iterator> > expr;
+ expression<Iterator> expr;
rule<Iterator, white_space>
statement_, statement_list, var_decl, compound_statement
, return_statement;
@@ -323,11 +322,11 @@
// Our program grammar and compiler
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct program : grammar_def<Iterator, grammar<white_space_def<Iterator> > >
+struct program : grammar<Iterator, white_space<Iterator> >
{
program(std::vector<int>& code);
- typedef grammar<white_space_def<Iterator> > white_space;
+ typedef white_space<Iterator> white_space;
std::vector<int>& code;
rule<Iterator, std::string(), white_space> identifier;
@@ -341,8 +340,7 @@
function_locals;
symbols<char, function_info> functions;
- statement<Iterator> statement_def;
- grammar<statement<Iterator> > statement;
+ statement<Iterator> statement;
rule<Iterator, function_locals, white_space> function;
boost::phoenix::function<function_adder> add_function;
Modified: trunk/libs/spirit/example/qi/mini_c/mini_cb.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/mini_c/mini_cb.hpp (original)
+++ trunk/libs/spirit/example/qi/mini_c/mini_cb.hpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -17,7 +17,8 @@
std::vector<int>& code
, symbols<char, int>& vars
, symbols<char, function_info>& functions)
- : code(code)
+ : grammar<Iterator, white_space>(expr)
+ , code(code)
, vars(vars)
, functions(functions)
, op(code)
Modified: trunk/libs/spirit/example/qi/mini_c/mini_cc.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/mini_c/mini_cc.hpp (original)
+++ trunk/libs/spirit/example/qi/mini_c/mini_cc.hpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -15,11 +15,11 @@
template <typename Iterator>
statement<Iterator>::statement(
std::vector<int>& code, symbols<char, function_info>& functions)
- : code(code)
+ : grammar<Iterator, white_space>(statement_list)
+ , code(code)
, functions(functions)
, nvars(0)
- , expr_def(code, vars, functions)
- , expr(expr_def, expr_def.expr)
+ , expr(code, vars, functions)
, add_var(var_adder(vars, nvars))
, op(code)
{
Modified: trunk/libs/spirit/example/qi/mini_c/mini_cd.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/mini_c/mini_cd.hpp (original)
+++ trunk/libs/spirit/example/qi/mini_c/mini_cd.hpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -14,16 +14,16 @@
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
program<Iterator>::program(std::vector<int>& code)
- : code(code)
- , statement_def(code, functions)
- , statement(statement_def, statement_def.statement_list)
+ : grammar<Iterator, white_space>(start)
+ , code(code)
+ , statement(code, functions)
, add_function(function_adder(functions))
- , state_reset(function_state_reset(code, statement_def.vars, statement_def.nvars))
+ , state_reset(function_state_reset(code, statement.vars, statement.nvars))
, op(code)
{
- bool& has_return = statement_def.has_return;
- int& nvars = statement_def.nvars;
- boost::phoenix::function<var_adder>& add_var = statement_def.add_var;
+ bool& has_return = statement.has_return;
+ int& nvars = statement.nvars;
+ boost::phoenix::function<var_adder>& add_var = statement.add_var;
identifier %=
raw[lexeme[alpha >> *(alnum | '_')]]
Modified: trunk/libs/spirit/example/qi/mini_xml1.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/mini_xml1.cpp (original)
+++ trunk/libs/spirit/example/qi/mini_xml1.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -128,9 +128,9 @@
// Our mini XML grammar definition
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct mini_xml_def : grammar_def<Iterator, mini_xml(), space_type>
+struct mini_xml_grammar : grammar<Iterator, mini_xml(), space_type>
{
- mini_xml_def()
+ mini_xml_grammar() : grammar<Iterator, mini_xml(), space_type>(xml)
{
text = lexeme[+(char_ - '<') [_val += _1]];
node = (xml | text) [_val = _1];
@@ -193,9 +193,8 @@
std::istream_iterator<char>(),
std::back_inserter(storage));
- typedef mini_xml_def<std::string::const_iterator> mini_xml_def;
- mini_xml_def def; // Our grammar definition
- grammar<mini_xml_def> xml(def, def.xml); // Our grammar
+ typedef mini_xml_grammar<std::string::const_iterator> mini_xml_grammar;
+ mini_xml_grammar xml; // Our grammar
mini_xml ast; // our tree
std::string::const_iterator iter = storage.begin();
Modified: trunk/libs/spirit/example/qi/mini_xml2.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/mini_xml2.cpp (original)
+++ trunk/libs/spirit/example/qi/mini_xml2.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -128,10 +128,11 @@
// Our mini XML grammar definition
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct mini_xml_def
- : grammar_def<Iterator, mini_xml(), locals<std::string>, space_type>
+struct mini_xml_grammar
+ : grammar<Iterator, mini_xml(), locals<std::string>, space_type>
{
- mini_xml_def()
+ mini_xml_grammar()
+ : grammar<Iterator, mini_xml(), locals<std::string>, space_type>(xml)
{
text %= lexeme[+(char_ - '<')];
node %= xml | text;
@@ -194,9 +195,8 @@
std::istream_iterator<char>(),
std::back_inserter(storage));
- typedef mini_xml_def<std::string::const_iterator> mini_xml_def;
- mini_xml_def def; // Our grammar definition
- grammar<mini_xml_def> xml(def, def.xml); // Our grammar
+ typedef mini_xml_grammar<std::string::const_iterator> mini_xml_grammar;
+ mini_xml_grammar xml; // Our grammar
mini_xml ast; // our tree
std::string::const_iterator iter = storage.begin();
Modified: trunk/libs/spirit/example/qi/roman.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/roman.cpp (original)
+++ trunk/libs/spirit/example/qi/roman.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -105,9 +105,9 @@
// roman (numerals) grammar
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
-struct roman : grammar_def<Iterator, unsigned()>
+struct roman : grammar<Iterator, unsigned()>
{
- roman()
+ roman() : grammar<Iterator, unsigned()>(start)
{
start
= +char_('M') [_val += 1000]
@@ -138,8 +138,7 @@
typedef std::string::const_iterator iterator_type;
typedef roman<iterator_type> roman;
- roman def; // Our grammar definition
- grammar<roman> roman_parser(def); // Our grammar
+ roman roman_parser; // Our grammar
std::string str;
unsigned result;
Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -53,49 +53,6 @@
[ compile-fail qi/grammar_fail.cpp : : ]
[ compile-fail qi/rule_fail.cpp : : ]
- # run Karma tests
- [ run karma/actions.cpp : : : : karma_actions ]
- [ run karma/alternative.cpp : : : : karma_alternative ]
- [ run karma/binary.cpp : : : : karma_binary ]
- [ run karma/case_handling.cpp : : : : ]
- [ run karma/center_alignment.cpp : : : : ]
- [ run karma/char.cpp : : : : karma_char ]
- [ run karma/delimiter.cpp : : : : ]
- [ run karma/eol.cpp : : : : karma_eol ]
- [ run karma/eps.cpp : : : : karma_eps ]
- [ run karma/format_manip.cpp : : : : ]
- [ run karma/functor.cpp : : : : karma_functor ]
- [ run karma/grammar.cpp : : : : karma_grammar ]
- [ run karma/int_numerics.cpp : : : : ]
- [ run karma/kleene.cpp : : : : karma_kleene ]
- [ run karma/lazy.cpp : : : : karma_lazy ]
- [ run karma/left_alignment.cpp : : : : ]
- [ run karma/list.cpp : : : : karma_list ]
- [ run karma/lit.cpp : : : : karma_lit ]
- [ run karma/none.cpp : : : : karma_none ]
- [ run karma/optional.cpp : : : : karma_optional ]
- [ run karma/pattern.cpp : : : : ]
- [ run karma/real_numerics.cpp : : : : ]
- [ run karma/right_alignment.cpp : : : : ]
- [ run karma/sequence.cpp : : : : karma_sequence ]
-
- [ compile-fail karma/grammar_fail.cpp : : karma_grammar_fail ]
- [ compile-fail karma/rule_fail.cpp : : karma_rule_fail ]
-
- # run support tests
- [ run support/hold_any.cpp : : : : ]
-# the multi_pass tests are not completed yet
-# [ run support/multi_pass_compile.cpp : : : : ]
-# [ run support/multi_pass.cpp : : : : ]
-
- # run lexer tests
- [ run lex/lexertl1.cpp : : : : ]
- [ run lex/lexertl2.cpp : : : : ]
- [ run lex/lexertl3.cpp : : : : ]
- [ run lex/lexertl4.cpp : : : : ]
- [ run lex/lexertl5.cpp : : : : ]
- [ run lex/state_switcher_test.cpp : : : : ]
-
;
}
Modified: trunk/libs/spirit/test/qi/grammar.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/grammar.cpp (original)
+++ trunk/libs/spirit/test/qi/grammar.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -24,7 +24,7 @@
using namespace boost::spirit::ascii;
using namespace boost::spirit::arg_names;
-struct num_list : grammar_<char const*, space_type>
+struct num_list : grammar<char const*, space_type>
{
num_list() : base_type(start)
{
@@ -36,9 +36,9 @@
rule<char const*, space_type> start, num;
};
-struct inh_g : grammar_def<char const*, int(int), space_type>
+struct inh_g : grammar<char const*, int(int), space_type>
{
- inh_g()
+ inh_g() : base_type(start)
{
start = lit("inherited")[_val = _r1];
}
@@ -46,9 +46,9 @@
rule<char const*, int(int), space_type> start, num;
};
-struct my_skipper : grammar_def<char const*>
+struct my_skipper : grammar<char const*>
{
- my_skipper()
+ my_skipper() : base_type(start)
{
start = space;
}
@@ -56,23 +56,23 @@
rule<char const*> start, num;
};
-struct num_list2 : grammar_def<char const*, grammar<my_skipper> >
+struct num_list2 : grammar<char const*, my_skipper>
{
- num_list2()
+ num_list2() : base_type(start)
{
using boost::spirit::int_;
num = int_;
start = num >> *(',' >> num);
}
- rule<char const*, grammar<my_skipper> > start, num;
+ rule<char const*, my_skipper> start, num;
};
template <typename Iterator, typename Skipper>
-struct num_list3 : grammar_def<Iterator, Skipper>
+struct num_list3 : grammar<Iterator, Skipper>
{
template <typename Class>
- num_list3(Class& self)
+ num_list3(Class& self) : grammar<Iterator, Skipper>(start)
{
using boost::spirit::int_;
num = int_;
@@ -93,53 +93,28 @@
{ // simple grammar test with user-skipper
- num_list2 def;
- grammar<num_list2> nlist(def);
- my_skipper skipdef;
- grammar<my_skipper> skip(skipdef);
+ num_list2 nlist;
+ my_skipper skip;
BOOST_TEST(test("123, 456, 789", nlist, skip));
}
{ // direct access to the rules
- num_list def;
- BOOST_TEST(test("123", def.num));
- BOOST_TEST(test("123, 456, 789", def.start, space));
+ num_list g;
+ BOOST_TEST(test("123", g.num));
+ BOOST_TEST(test("123, 456, 789", g.start, space));
}
{ // grammar with inherited attributes
- inh_g def;
- grammar<inh_g> g(def);
+ inh_g g;
int n = -1;
- BOOST_TEST(test_attr("inherited", def.start(123), n, space)); // direct to the rule
+ BOOST_TEST(test_attr("inherited", g.start(123), n, space)); // direct to the rule
BOOST_TEST(n == 123);
BOOST_TEST(test_attr("inherited", g(123), n, space)); // using the grammar
BOOST_TEST(n == 123);
}
- { // grammar_class test (no skipper)
-
- grammar_class<num_list3> nlist;
-
- char const* first = "123,456,789";
- char const* last = first;
- while (*last)
- last++;
- BOOST_TEST(parse(first, last, nlist) && (first == last));
- }
-
- { // grammar_class test (w/skipper)
-
- grammar_class<num_list3> nlist;
-
- char const* first = "123, 456, 789";
- char const* last = first;
- while (*last)
- last++;
- BOOST_TEST(phrase_parse(first, last, nlist, space)
- && (first == last));
- }
return boost::report_errors();
}
Modified: trunk/libs/spirit/test/qi/grammar_fail.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/grammar_fail.cpp (original)
+++ trunk/libs/spirit/test/qi/grammar_fail.cpp 2008-07-11 11:30:24 EDT (Fri, 11 Jul 2008)
@@ -16,9 +16,9 @@
using namespace boost::spirit::qi;
using namespace boost::spirit::ascii;
-struct num_list : grammar_def<char const*, rule<char const*> >
+struct num_list : grammar<char const*, rule<char const*> >
{
- num_list()
+ num_list() : base_type(start)
{
using boost::spirit::int_;
num = int_;
@@ -34,8 +34,7 @@
char const* input = "some input, it doesn't matter";
char const* end = &input[strlen(input)+1];
- num_list def;
- grammar<num_list> g(def);
+ num_list g;
bool r = phrase_parse(input, end, g,
space | ('%' >> *~char_('\n') >> '\n'));
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk