Commits

Taegyoon Kim committed f5dc5c0

v0.3.2: function call bug fixed

  • Participants
  • Parent commits a4f4d71

Comments (0)

Files changed (1)

 ; (C) 2014 KIM Taegyoon
 (require compatibility/defmacro)
 
-(define version "0.3.1")
+(define version "0.3.2")
 (define (readline)
   (read-line (current-input-port) 'any))
 
                  ; (do/e EXPR ...) => (EXPR, ...)
                  [(do/e) (string-join (map compile-expr (rest e)) "," #:before-first "(" #:after-last ")")]
                  ; (at ARRAY POSITION) => ARRAY[POSITION]
-                 [(at) (format "~a[~a]" (second e) (compile-expr (third e)))]
+                 [(at) (format "~a[~a]" (compile-expr (second e)) (compile-expr (third e)))]
                  ; (break) => break
                  [(break continue) (~a f)]
                  ; (main BODY ...) => int main(int argc, char **argv) {BODY; ...; return 0;}
                  ; (goto ID) => goto ID
                  [(goto) (format "goto ~a" (second e))]
                  ; (switch EXPR BODY ...) => switch (EXPR) {BODY; ...;}
-                 [(switch) (format "switch (~a) {\n~a;}" (second e) (string-join (map compile-expr (drop e 2)) ";\n"))]
+                 [(switch) (format "switch (~a) {\n~a;}" (compile-expr (second e)) (string-join (map compile-expr (drop e 2)) ";\n"))]
                  ; (case EXPR ...) => case EXPR: case ...:
                  [(case) (string-join (for/list ([x (rest e)]) (format "case ~a:" x)))]
                  ; (default) => default:
                  ; (format form ...) ; compile-time formatting
                  [(format) (apply format (second e) (map compile-expr (drop e 2)))]
                  ; (F ARG ...) => F(ARG, ...)
-                 [else (format "~a(~a)" f (string-join (map compile-expr (drop e 1)) ","))])))]
+                 [else (format "~a(~a)" (compile-expr f) (string-join (map compile-expr (drop e 1)) ","))])))]
         [else (~s e)]))
 
 (define prolog "#include <iostream>\n")