diff options
-rw-r--r-- | TODO.rst | 4 | ||||
-rw-r--r-- | parser.cpp | 10 | ||||
-rw-r--r-- | robust_test.scm | 46 |
3 files changed, 51 insertions, 9 deletions
@@ -1,4 +1,4 @@ -- non-recursive equal? predicate -- ext_repr optimization +- Testing - Garbage Collection? +- ext_repr optimization - Add macro support @@ -43,7 +43,7 @@ void Tokenizor::set_stream(FILE *_stream) { } while (0) #define TOP (*(buff_ptr - 1)) -void str_to_lower(string &str) { +string str_to_lower(string str) { size_t len = str.length(); for (size_t i = 0; i < len; i++) if ('A' <= str[i] && str[i] <= 'Z') @@ -112,11 +112,7 @@ bool Tokenizor::get_token(string &ret) { else *buff_ptr++ = ch; } - if (flag) - { - str_to_lower(ret); - return true; - } + if (flag) return true; } } if (buff_ptr != buff) POP; @@ -135,7 +131,7 @@ EvalObj *ASTGenerator::to_obj(const string &str) { if ((res = RealNumObj::from_string(str))) return res; if ((res = CompNumObj::from_string(str))) return res; if ((res = StrObj::from_string(str))) return res; - return new SymObj(str); // otherwise we assume it a symbol + return new SymObj(str_to_lower(str)); // otherwise we assume it a symbol } #define TO_EVAL(ptr) \ diff --git a/robust_test.scm b/robust_test.scm index 0e989b8..7b7bfd4 100644 --- a/robust_test.scm +++ b/robust_test.scm @@ -172,3 +172,49 @@ t src (eval src) (eval '(g 0)) + +(define f (lambda (x) (+ x x))) ;; test comments +((lambda (x y) (f 3)) 1 2) ;; first-class procedure +; this is a single line comment +; another line +(define f (lambda (x) (lambda (y) (+ x y)))) + +(f 1) ; #<procedure> + +((f 1) 2) ; 3 + +(define g (lambda (x) (define y 2) (+ x y))) +(g 3) + +((lambda () (display 2) (display 1) (+ 1 2))) +(define g (lambda (x) (if (= x 5) 0 ((lambda () (display x) (g (+ x 1))))))) +(g 0) + +(define g (lambda (x) + (if (= x 5) + 0 + ((lambda () + (display x) + (g (+ x 1))))))) +(g 0) + +(define square (lambda (x) (* x x))) + +(square 2) + +(define (f x y) + ((lambda (a b) + (+ (* x (square a)) + (* y b) + (* a b))) + (+ 1 (* x y )) + (- 1 y))) + +(f 1 2) + +((lambda (x + y) (+ x y)) 4 / 2) ; a classic trick + +(if #t 1 ()) +(if #f 1 ()) ; Error +; "Test double quotes in comments" +(display " Test double quotes outside the comments ; ;; ; ; ") |