|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r61249 - in trunk/libs/spirit/example/scheme: . input test
From: joel_at_[hidden]
Date: 2010-04-13 12:07:17
Author: djowel
Date: 2010-04-13 12:07:16 EDT (Tue, 13 Apr 2010)
New Revision: 61249
URL: http://svn.boost.org/trac/boost/changeset/61249
Log:
+ lambda working
+ fix to sexpr symbol matching
+ workaround to iterator_range bug
Text files modified:
trunk/libs/spirit/example/scheme/input/sexpr.hpp | 2 +-
trunk/libs/spirit/example/scheme/scheme_compiler.hpp | 4 +++-
trunk/libs/spirit/example/scheme/scheme_interpreter.hpp | 19 ++++++++++++++++---
trunk/libs/spirit/example/scheme/scheme_intinsics.hpp | 7 ++++++-
trunk/libs/spirit/example/scheme/test/scheme_test.scm | 11 ++++++++++-
5 files changed, 36 insertions(+), 7 deletions(-)
Modified: trunk/libs/spirit/example/scheme/input/sexpr.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/input/sexpr.hpp (original)
+++ trunk/libs/spirit/example/scheme/input/sexpr.hpp 2010-04-13 12:07:16 EDT (Tue, 13 Apr 2010)
@@ -75,7 +75,7 @@
| symbol
;
- char const* exclude = " ();\"\0-\31\127";
+ std::string exclude = std::string(" ();\"\x01-\x1f\x7f") + '\0';
symbol = lexeme[+(~char_(exclude))];
integer = lexeme[no_case["0x"] >> hex]
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-13 12:07:16 EDT (Tue, 13 Apr 2010)
@@ -1,4 +1,4 @@
-/*=============================================================================
+/*=============================================================================
Copyright (c) 2001-2010 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -107,6 +107,7 @@
return (*mf)(flist);
}
// $$$ throw? $$$
+ BOOST_ASSERT(false);
return actor();
}
@@ -182,6 +183,7 @@
return (*mf)(flist);
}
+ BOOST_ASSERT(false);
return actor(); // $$$ implement me $$$
}
Modified: trunk/libs/spirit/example/scheme/scheme_interpreter.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/scheme_interpreter.hpp (original)
+++ trunk/libs/spirit/example/scheme/scheme_interpreter.hpp 2010-04-13 12:07:16 EDT (Tue, 13 Apr 2010)
@@ -212,7 +212,10 @@
typedef unary_function<Derived> base_type;
unary_function(actor const& a)
- : a(a) {}
+ : a(a)
+ {
+ BOOST_ASSERT(!a.empty());
+ }
typedef utree result_type;
utree operator()(args_type args) const
@@ -247,7 +250,11 @@
typedef binary_function<Derived> base_type;
binary_function(actor const& a, actor const& b)
- : a(a), b(b) {}
+ : a(a), b(b)
+ {
+ BOOST_ASSERT(!a.empty());
+ BOOST_ASSERT(!b.empty());
+ }
typedef utree result_type;
utree operator()(args_type args) const
@@ -283,7 +290,13 @@
typedef nary_function<Derived> base_type;
actor_list elements;
nary_function(actor_list const& elements)
- : elements(elements) {}
+ : elements(elements)
+ {
+ BOOST_FOREACH(actor const& element, elements)
+ {
+ BOOST_ASSERT(!element.empty());
+ }
+ }
using composite<Derived>::operator();
utree operator()(args_type args) const
Modified: trunk/libs/spirit/example/scheme/scheme_intinsics.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/scheme_intinsics.hpp (original)
+++ trunk/libs/spirit/example/scheme/scheme_intinsics.hpp 2010-04-13 12:07:16 EDT (Tue, 13 Apr 2010)
@@ -21,7 +21,12 @@
actor else_;
if_function(
actor const& cond, actor const& then, actor const& else_)
- : cond(cond), then(then), else_(else_) {}
+ : cond(cond), then(then), else_(else_)
+ {
+ BOOST_ASSERT(!cond.empty());
+ BOOST_ASSERT(!then.empty());
+ BOOST_ASSERT(!else_.empty());
+ }
typedef utree result_type;
utree operator()(args_type args) const
Modified: trunk/libs/spirit/example/scheme/test/scheme_test.scm
==============================================================================
--- trunk/libs/spirit/example/scheme/test/scheme_test.scm (original)
+++ trunk/libs/spirit/example/scheme/test/scheme_test.scm 2010-04-13 12:07:16 EDT (Tue, 13 Apr 2010)
@@ -9,4 +9,13 @@
(if (<= n 0) 1
(* n (factorial (- n 1)))))
-(factorial 10) ; 3628800
\ No newline at end of file
+(factorial 10) ; 3628800
+
+; Fibonacci using lambda
+(define fib
+ (lambda (n)
+ (if (< n 2)
+ n
+ (+ (fib (- n 1)) (fib (- n 2))))))
+
+(fib 10)
\ No newline at end of file
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