]> git.mdlowis.com Git - archive/dlang-scm.git/commitdiff
Added tests for parsing infix operator application
authorMike D. Lowis <mike@mdlowis.com>
Tue, 17 Jul 2012 20:48:39 +0000 (16:48 -0400)
committerMike D. Lowis <mike@mdlowis.com>
Tue, 17 Jul 2012 20:48:39 +0000 (16:48 -0400)
source/parser.scm
tests/test_parser.scm

index 5c0bdff00bce5507174d61d46bb38bdcf9c61040..ab431fff74cd5d23e15ba5b0f9806a4c13c470ea 100644 (file)
         (op '()))
     (token-match in 'lpar)
     (set! parts (append (list (dlang/expression in)) parts))
-    ;(set! parts (cons parts (list (dlang/operator in))))
-    ;(set! parts (append parts (list (dlang/expression in))))
+    (set! parts (append (list (dlang/operator in)) parts))
+    (set! parts (append parts (list (dlang/expression in))))
     (token-match in 'rpar)
-    ;(syntree-children-set! tree parts)
+    (syntree-children-set! tree parts)
     tree))
 
 (define (dlang/operator in)
index 05727ac60bbb1916e48f25f574cc0a523137fcf0..92ad46f0164a172ab9e0160ffa919a8671c6d0ef 100644 (file)
       (define result (dlang/basic-expr lxr))
       (syntree=? result (syntree 'id "abc" '())))))
 
-;(def-test "dlang/basic-expr should parse an infix operator application"
-;  (call-with-input-string "(1.0) * 2.0)"
-;    (lambda (input)
-;      (define lxr (make-lexer input))
-;      (define result (dlang/basic-expr lxr))
-;      (syntree=? result (syntree 'id "abc" '())
-;      (define expect
-;        (syntree 'apply "" (list
-;        ;  (syntree 'id "+" '())
-;          (syntree 'number "1.0" '()))))
-;        ;  (syntree 'number "1.0" '()))))
-;      (equal? result expect))))
-;      ;(and (syntree? result)
-;      ;     (equal? 'apply (syntree-type result))
-;      ;     (equal? "" (syntree-text result))
-;      ;     (equal? '() (syntree-children result))))))
+(def-test "dlang/basic-expr should parse an infix operator application"
+  (call-with-input-string "(1.0 * 2.0)"
+    (lambda (input)
+      (define lxr (make-lexer input))
+      (define result (dlang/basic-expr lxr))
+      (syntree=? result
+        (syntree 'apply ""
+          (list
+            (syntree 'id "*" '())
+            (syntree 'number "1.0" '())
+            (syntree 'number "2.0" '())))))))
 
 ; dlang/operator-app
 ;------------------------------------------------------------------------------