From dd47244b78e85fa74454b9a582d57e3764db3ded Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Mon, 14 Feb 2022 18:13:56 -0500 Subject: [PATCH] Fix bug in script & block --- src/ludus/parser.clj | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/ludus/parser.clj b/src/ludus/parser.clj index 751450c..90777bc 100644 --- a/src/ludus/parser.clj +++ b/src/ludus/parser.clj @@ -157,8 +157,12 @@ (::token/semicolon ::token/newline) (recur (advance parser) (add-member exprs current_expr) nil) - (let [parsed (parse-expr parser)] - (recur parsed exprs (::ast parsed))) + (if current_expr + (-> parser + (advance) + (assoc ::ast {::ast/type ::ast/poison :message "Expected end of expression"})) + (let [parsed (parse-expr parser)] + (recur parsed exprs (::ast parsed)))) ))) (defn- parse-script [parser] @@ -173,8 +177,12 @@ (::token/semicolon ::token/newline) (recur (advance parser) (add-member exprs current_expr) nil) - (let [parsed (parse-expr parser)] - (recur parsed exprs (::ast parsed))) + (if current_expr + (-> parser + (advance) + (assoc ::ast {::ast/type ::ast/poison :message "Expected end of expression"})) + (let [parsed (parse-expr parser)] + (recur parsed exprs (::ast parsed)))) ))) @@ -239,7 +247,7 @@ )))) -(def source ":foo (bar) (baz)") +(def source ":foo; :baz (foo, bar)") (def tokens (:tokens (scanner/scan source))) @@ -248,8 +256,7 @@ (pp/pprint p) (-> (parse-script p) - (::ast) - (:exprs)) + (::ast)) (comment " Just leaving this note here for myself. I'm too tired to write more code, but I want not to lose momentum. So: @@ -285,6 +292,7 @@ * Compound `loop` and `gen` forms must have LHS's (tuple patterns) of the same length * Recur is in tail position in `loop`s * Tail call optimization for simple recursion + * Check arities for statically known functions ")