Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73588 - trunk/libs/spirit/example/qi/compiler_tutorial/conjure3
From: joel_at_[hidden]
Date: 2011-08-06 20:39:41


Author: djowel
Date: 2011-08-06 20:39:40 EDT (Sat, 06 Aug 2011)
New Revision: 73588
URL: http://svn.boost.org/trac/boost/changeset/73588

Log:
make operand an extended_variant so we can tag it (among other things).
Text files modified:
   trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/annotation.hpp | 1 +
   trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ast.hpp | 18 +++++++++++++++---
   2 files changed, 16 insertions(+), 3 deletions(-)

Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/annotation.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/annotation.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/annotation.hpp 2011-08-06 20:39:40 EDT (Sat, 06 Aug 2011)
@@ -96,6 +96,7 @@
             int id = iters.size();
             iters.push_back(pos);
             boost::apply_visitor(set_annotation_id(id), ast);
+ ast.id = id;
         }
 
         void operator()(ast::variable_declaration& ast, Iterator pos) const

Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ast.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ast.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ast.hpp 2011-08-06 20:39:40 EDT (Sat, 06 Aug 2011)
@@ -47,7 +47,8 @@
         boost::spirit::extended_variant<
             nil
           , bool
- , unsigned int>
+ , unsigned int
+ >
     {
         literal() : base_type() {}
         literal(bool val) : base_type(val) {}
@@ -56,7 +57,9 @@
             : base_type(rhs.get()) {}
     };
 
- typedef boost::variant<
+ struct operand :
+ tagged,
+ boost::spirit::extended_variant<
             nil
           , literal
           , identifier
@@ -64,7 +67,16 @@
           , boost::recursive_wrapper<function_call>
           , boost::recursive_wrapper<expression>
>
- operand;
+ {
+ operand() : base_type() {}
+ operand(literal const& val) : base_type(val) {}
+ operand(identifier const& val) : base_type(val) {}
+ operand(unary const& val) : base_type(val) {}
+ operand(function_call const& val) : base_type(val) {}
+ operand(expression const& val) : base_type(val) {}
+ operand(operand const& rhs)
+ : base_type(rhs.get()) {}
+ };
 
     struct unary : tagged
     {


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