successfully flag tail calls
This commit is contained in:
parent
5fbafbac94
commit
bc17fe5006
|
@ -13,7 +13,7 @@ Tracking here, before I start writing this code, the kinds of validation we're h
|
||||||
* [x] recur not called outside of `loop` forms
|
* [x] recur not called outside of `loop` forms
|
||||||
* [x] `loop` form arity checking
|
* [x] `loop` form arity checking
|
||||||
* [x] arity checking of explicit named function calls
|
* [x] arity checking of explicit named function calls
|
||||||
* [ ] flag tail calls
|
* [x] flag tail calls
|
||||||
|
|
||||||
Imports are for a later iteration of Ludus:
|
Imports are for a later iteration of Ludus:
|
||||||
* [ ] no circular imports DEFERRED
|
* [ ] no circular imports DEFERRED
|
||||||
|
@ -290,7 +290,14 @@ Imports are for a later iteration of Ludus:
|
||||||
(defn- pkg-root [validator])
|
(defn- pkg-root [validator])
|
||||||
|
|
||||||
# * [ ] flag tail calls (where last term is not-partial args)
|
# * [ ] flag tail calls (where last term is not-partial args)
|
||||||
(defn- tail-call [validator])
|
(defn- tail-call [validator]
|
||||||
|
(def ast (validator :ast))
|
||||||
|
(when (ast :partial) (break validator))
|
||||||
|
(def status (validator :status))
|
||||||
|
(when (not (status :tail)) (break validator))
|
||||||
|
(def data (ast :data))
|
||||||
|
(def args (last data))
|
||||||
|
(set (args :tail-call) true))
|
||||||
|
|
||||||
# * [ ] arity checking if first term is name that resolves to a function and args aren't partial
|
# * [ ] arity checking if first term is name that resolves to a function and args aren't partial
|
||||||
# XXX: now just check number of args against arity map
|
# XXX: now just check number of args against arity map
|
||||||
|
@ -579,16 +586,16 @@ Imports are for a later iteration of Ludus:
|
||||||
(do
|
(do
|
||||||
#(comment
|
#(comment
|
||||||
(def source `
|
(def source `
|
||||||
fn foo {
|
fn bar () -> :bar
|
||||||
() -> :bar
|
fn foo () -> match :foo with {
|
||||||
(x) -> :foo
|
a -> bar ()
|
||||||
(x, y, ...z) -> :baz
|
b -> :baz
|
||||||
}
|
}
|
||||||
foo (4)
|
|
||||||
`)
|
`)
|
||||||
(def scanned (s/scan source))
|
(def scanned (s/scan source))
|
||||||
(def parsed (p/parse scanned))
|
(def parsed (p/parse scanned))
|
||||||
(def validator (new-validator parsed))
|
(def validator (new-validator parsed))
|
||||||
(pp validator)
|
(pp validator)
|
||||||
((validate validator) :errors)
|
(validate validator)
|
||||||
|
(pp parsed)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user