|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r61502 - in trunk/libs/spirit/example/scheme/example: . scheme
From: joel_at_[hidden]
Date: 2010-04-23 00:03:14
Author: djowel
Date: 2010-04-23 00:03:13 EDT (Fri, 23 Apr 2010)
New Revision: 61502
URL: http://svn.boost.org/trac/boost/changeset/61502
Log:
examples cleanup
Added:
trunk/libs/spirit/example/scheme/example/scheme/call_factorial.scm (contents, props changed)
trunk/libs/spirit/example/scheme/example/scheme/try_scheme.cpp
- copied unchanged from r61501, /trunk/libs/spirit/example/scheme/example/scheme/scheme_test.cpp
Removed:
trunk/libs/spirit/example/scheme/example/scheme/scheme_test.cpp
Text files modified:
trunk/libs/spirit/example/scheme/example/Jamfile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
Modified: trunk/libs/spirit/example/scheme/example/Jamfile
==============================================================================
--- trunk/libs/spirit/example/scheme/example/Jamfile (original)
+++ trunk/libs/spirit/example/scheme/example/Jamfile 2010-04-23 00:03:13 EDT (Fri, 23 Apr 2010)
@@ -30,7 +30,7 @@
exe factorial1 : scheme/factorial1.cpp ;
exe factorial2 : scheme/factorial2.cpp ;
-exe scheme_test : scheme/scheme_test.cpp ;
+exe try_scheme : scheme/try_scheme.cpp ;
Added: trunk/libs/spirit/example/scheme/example/scheme/call_factorial.scm
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/example/scheme/example/scheme/call_factorial.scm 2010-04-23 00:03:13 EDT (Fri, 23 Apr 2010)
@@ -0,0 +1,7 @@
+; The hello-world for interpreters ;-)
+(define (factorial n)
+ (if (<= n 0) 1
+ (* n (factorial (- n 1)))))
+
+(define (main)
+ (display (factorial 10)))
\ No newline at end of file
Deleted: trunk/libs/spirit/example/scheme/example/scheme/scheme_test.cpp
==============================================================================
--- trunk/libs/spirit/example/scheme/example/scheme/scheme_test.cpp 2010-04-23 00:03:13 EDT (Fri, 23 Apr 2010)
+++ (empty file)
@@ -1,57 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#include <boost/config/warning_disable.hpp>
-
-#include <input/sexpr.hpp>
-#include <input/parse_sexpr_impl.hpp>
-#include <scheme/compiler.hpp>
-#include <utree/io.hpp>
-#include <fstream>
-
-int check_file(std::ifstream& in, char const* filename)
-{
- if (!in)
- {
- std::cerr << filename << " not found" << std::endl;
- return -1;
- }
-
- // Ignore the BOM marking the beginning of a UTF-8 file in Windows
- char c = in.peek();
- if (c == '\xef')
- {
- char s[3];
- in >> s[0] >> s[1] >> s[2];
- s[3] = '\0';
- if (s != std::string("\xef\xbb\xbf"))
- {
- std::cerr << "Error: Unexpected characters from input file: "
- << filename << std::endl;
- return -1;
- }
- }
- return 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Main program
-///////////////////////////////////////////////////////////////////////////////
-int main(int argc, char **argv)
-{
- char const* filename = filename = argv[1];
- std::ifstream in(filename, std::ios_base::in);
- if (check_file(in, filename) != 0)
- return -1;
-
- scheme::interpreter program(in, filename);
- scheme::function main_ = program["main"];
- if (!main_.empty())
- main_(); // call main
- return 0;
-}
-
-
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