Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61465 - in trunk/libs/spirit/example/scheme: example/scheme scheme utree utree/detail
From: joel_at_[hidden]
Date: 2010-04-21 12:19:57


Author: djowel
Date: 2010-04-21 12:19:54 EDT (Wed, 21 Apr 2010)
New Revision: 61465
URL: http://svn.boost.org/trac/boost/changeset/61465

Log:
more implementation details
Text files modified:
   trunk/libs/spirit/example/scheme/example/scheme/some_scheme.scm | 4 +---
   trunk/libs/spirit/example/scheme/scheme/compiler.hpp | 8 ++++++++
   trunk/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp | 7 +++++++
   trunk/libs/spirit/example/scheme/utree/operators.hpp | 18 +++++++++++++++++-
   4 files changed, 33 insertions(+), 4 deletions(-)

Modified: trunk/libs/spirit/example/scheme/example/scheme/some_scheme.scm
==============================================================================
--- trunk/libs/spirit/example/scheme/example/scheme/some_scheme.scm (original)
+++ trunk/libs/spirit/example/scheme/example/scheme/some_scheme.scm 2010-04-21 12:19:54 EDT (Wed, 21 Apr 2010)
@@ -1,3 +1 @@
-(define (apply x f) (display (f x)))
-
-(apply 123 (lambda (x) (+ x 1)))
\ No newline at end of file
+(display (xxx 2 3 4 5))
\ No newline at end of file

Modified: trunk/libs/spirit/example/scheme/scheme/compiler.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/scheme/compiler.hpp (original)
+++ trunk/libs/spirit/example/scheme/scheme/compiler.hpp 2010-04-21 12:19:54 EDT (Wed, 21 Apr 2010)
@@ -352,6 +352,14 @@
             return function();
         }
 
+ function operator()(polymorphic_function_base const& pf) const
+ {
+ // Can't reach here. Surely, at this point, we don't have
+ // utree functions yet. The utree AST should be pure data.
+ throw compilation_error();
+ return function();
+ }
+
         static std::string get_symbol(utree const& s)
         {
             if (s.which() != utree_type::symbol_type)

Modified: trunk/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp (original)
+++ trunk/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp 2010-04-21 12:19:54 EDT (Wed, 21 Apr 2010)
@@ -461,6 +461,9 @@
 
                 case type::reference_type:
                     return apply(*x.p, f);
+
+ case type::function_type:
+ return f(*x.pf);
             }
         }
 
@@ -514,6 +517,10 @@
 
                 case type::reference_type:
                     return apply(*x.p, y, f);
+
+ case type::function_type:
+ return visit_impl::apply(y, detail::bind(f, *x.pf));
+
             }
         }
     };

Modified: trunk/libs/spirit/example/scheme/utree/operators.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/utree/operators.hpp (original)
+++ trunk/libs/spirit/example/scheme/utree/operators.hpp 2010-04-21 12:19:54 EDT (Wed, 21 Apr 2010)
@@ -98,6 +98,11 @@
         {
             return true;
         }
+
+ bool operator()(polymorphic_function_base const& a, polymorphic_function_base const& b) const
+ {
+ return false; // just don't allow comparison of functions
+ }
     };
 
     struct utree_is_less_than
@@ -145,6 +150,12 @@
             BOOST_ASSERT(false);
             return false; // no less than comparison for nil
         }
+
+ bool operator()(polymorphic_function_base const& a, polymorphic_function_base const& b) const
+ {
+ BOOST_ASSERT(false);
+ return false; // no less than comparison of functions
+ }
     };
 
 #if !defined(SCHEME_USE_SPIRIT_IO)
@@ -213,6 +224,11 @@
             }
             (*this)(')');
         }
+
+ void operator()(polymorphic_function_base const& pf) const
+ {
+ return (*this)("<function>");
+ }
     };
 #endif
 
@@ -333,7 +349,7 @@
 
         // binary
         template <typename A, typename B>
- utree operator()(A const a, B const& b) const
+ utree operator()(A const& a, B const& b) const
         {
             return dispatch(a, b,
                 boost::mpl::and_<


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