Skip to content

Commit

Permalink
Spirit: More adjustments for new qi::grammar type
Browse files Browse the repository at this point in the history
[SVN r47375]
  • Loading branch information
hkaiser committed Jul 13, 2008
1 parent a19f63f commit 050cfd0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
9 changes: 4 additions & 5 deletions example/karma/calc2_ast_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ using namespace boost::spirit::arg_names;
// Our calculator parser grammar
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
struct calculator : qi::grammar_def<Iterator, expression_ast(), space_type>
struct calculator : qi::grammar<Iterator, expression_ast(), space_type>
{
calculator()
calculator() : calculator::base_type(expression)
{
expression =
term [_val = _1]
Expand Down Expand Up @@ -111,13 +111,12 @@ main()
typedef std::string::const_iterator iterator_type;
typedef calculator<iterator_type> calculator;

calculator def;
qi::grammar<calculator> calc(def, def.expression);
calculator calc;

// Our generator grammar definitions
typedef std::back_insert_iterator<std::string> output_iterator_type;
typedef dump_ast<output_iterator_type> dump_ast;

dump_ast dump_ast_def;
karma::grammar<dump_ast> ast_grammar(dump_ast_def, dump_ast_def.ast_node);

Expand Down
7 changes: 3 additions & 4 deletions example/karma/calc2_ast_rpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ using namespace boost::spirit::arg_names;
// Our calculator parser grammar
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
struct calculator : qi::grammar_def<Iterator, expression_ast(), space_type>
struct calculator : qi::grammar<Iterator, expression_ast(), space_type>
{
calculator()
calculator() : calculator::base_type(expression)
{
expression =
term [_val = _1]
Expand Down Expand Up @@ -114,8 +114,7 @@ main()
typedef std::string::const_iterator iterator_type;
typedef calculator<iterator_type> calculator;

calculator def;
qi::grammar<calculator> calc(def, def.expression);
calculator calc;

// Our generator grammar definitions
typedef std::back_insert_iterator<std::string> output_iterator_type;
Expand Down
7 changes: 3 additions & 4 deletions example/karma/calc2_ast_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ using namespace boost::spirit::arg_names;
// Our calculator parser grammar
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
struct calculator : qi::grammar_def<Iterator, expression_ast(), space_type>
struct calculator : qi::grammar<Iterator, expression_ast(), space_type>
{
calculator()
calculator() : calculator::base_type(expression)
{
expression =
term [_val = _1]
Expand Down Expand Up @@ -195,8 +195,7 @@ main()
typedef std::string::const_iterator iterator_type;
typedef calculator<iterator_type> calculator;

calculator def;
qi::grammar<calculator> calc(def, def.expression);
calculator calc;

std::string str;
while (std::getline(std::cin, str))
Expand Down
7 changes: 3 additions & 4 deletions example/karma/mini_xml_karma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ BOOST_FUSION_ADAPT_STRUCT(
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
struct mini_xml_parser :
qi::grammar_def<Iterator, mini_xml(), space_type>
qi::grammar<Iterator, mini_xml(), space_type>
{
mini_xml_parser()
mini_xml_parser() : mini_xml_parser::base_type(xml)
{
text = lexeme[+(char_ - '<') [_val += _1]];
node = (xml | text) [_val = _1];
Expand Down Expand Up @@ -180,8 +180,7 @@ int main(int argc, char **argv)
std::back_inserter(storage));

typedef mini_xml_parser<std::string::const_iterator> mini_xml_parser;
mini_xml_parser def; // Our grammar definition
qi::grammar<mini_xml_parser> xmlin(def, def.xml); // Our grammar
mini_xml_parser xmlin; // Our grammar definition
mini_xml ast; // our tree

std::string::const_iterator iter = storage.begin();
Expand Down
6 changes: 1 addition & 5 deletions example/lex/example6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,9 @@ template <typename Iterator, typename Lexer>
struct example6_grammar
: grammar<Iterator, in_state_skipper<typename Lexer::token_set> >
{
typedef
grammar<Iterator, in_state_skipper<typename Lexer::token_set> >
base_type;

template <typename TokenDef>
example6_grammar(TokenDef const& tok)
: base_type(program)
: example6_grammar::base_type(program)
{
program
= +block
Expand Down

0 comments on commit 050cfd0

Please sign in to comment.