Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61192 - in trunk/libs/spirit/example/scheme: . test
From: joel_at_[hidden]
Date: 2010-04-11 01:02:45


Author: djowel
Date: 2010-04-11 01:02:45 EDT (Sun, 11 Apr 2010)
New Revision: 61192
URL: http://svn.boost.org/trac/boost/changeset/61192

Log:
incremental refinement
Text files modified:
   trunk/libs/spirit/example/scheme/scheme_compiler.hpp | 22 +++++++++++-----------
   trunk/libs/spirit/example/scheme/test/scheme.cpp | 9 +++++----
   2 files changed, 16 insertions(+), 15 deletions(-)

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-11 01:02:45 EDT (Sun, 11 Apr 2010)
@@ -25,11 +25,11 @@
 ///////////////////////////////////////////////////////////////////////////////
 // The compiler
 ///////////////////////////////////////////////////////////////////////////////
- class compiler_environment
+ class environment
     {
     public:
 
- compiler_environment(compiler_environment* parent = 0)
+ environment(environment* parent = 0)
           : outer(parent) {}
 
         void define(std::string const& name, function_composer const& def)
@@ -50,22 +50,22 @@
             return 0;
         }
 
- compiler_environment* parent() const { return outer; }
+ environment* parent() const { return outer; }
 
     private:
 
- compiler_environment* outer;
+ environment* outer;
         std::map<std::string, function_composer> definitions;
     };
 
- actor compile(utree const& ast, compiler_environment& env);
+ actor compile(utree const& ast, environment& env);
 
     struct compiler
     {
         typedef actor result_type;
 
- mutable compiler_environment& env;
- compiler(compiler_environment& env)
+ mutable environment& env;
+ compiler(environment& env)
           : env(env)
         {
         }
@@ -98,7 +98,7 @@
             std::vector<std::string> const& args,
             utree const& body) const
         {
- compiler_environment local_env(env);
+ environment local_env(env);
             for (std::size_t i = 0; i < args.size(); ++i)
             {
                 boost::function<actor(actor_list const&)>
@@ -158,14 +158,14 @@
         }
     };
 
- actor compile(utree const& ast, compiler_environment& env)
+ actor compile(utree const& ast, environment& env)
     {
         return utree::visit(ast, compiler(env));
     }
 
     void compile_all(
         utree const& ast,
- compiler_environment& env,
+ environment& env,
         actor_list& results)
     {
         BOOST_FOREACH(utree const& program, ast)
@@ -175,7 +175,7 @@
         }
     }
 
- void build_basic_environment(compiler_environment& env)
+ void build_basic_environment(environment& env)
     {
         env.define("+", plus);
     }

Modified: trunk/libs/spirit/example/scheme/test/scheme.cpp
==============================================================================
--- trunk/libs/spirit/example/scheme/test/scheme.cpp (original)
+++ trunk/libs/spirit/example/scheme/test/scheme.cpp 2010-04-11 01:02:45 EDT (Sun, 11 Apr 2010)
@@ -30,9 +30,10 @@
         using scheme::_1;
         using scheme::_2;
 
- std::cout << "result: " << plus(11, 22, 33)() << std::endl;
- std::cout << "result: " << plus(11, 22, _1)(33) << std::endl;
- std::cout << "result: " << plus(11, _1, _2)(22, 33) << std::endl;
+ std::cout << "result: " << plus(11, 22, 33) () << std::endl;
+ std::cout << "result: " << plus(11, 22, _1) (33) << std::endl;
+ std::cout << "result: " << plus(11, _1, _2) (22, 33) << std::endl;
+ std::cout << "result: " << plus(11, plus(_1, _2)) (22, 33) << std::endl;
     }
 
     char const* filename = NULL;
@@ -74,7 +75,7 @@
     if (scheme::input::parse_sexpr_list(in, program))
     {
         std::cout << "success: " << std::endl;
- scheme::compiler_environment env;
+ scheme::environment env;
         scheme::build_basic_environment(env);
         scheme::actor_list flist;
         compile_all(program, env, flist);


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