aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/lux.lux425
-rw-r--r--src/lux/analyser.clj371
-rw-r--r--src/lux/analyser/case.clj24
-rw-r--r--src/lux/analyser/host.clj20
-rw-r--r--src/lux/analyser/lux.clj2
-rw-r--r--src/lux/base.clj51
-rw-r--r--src/lux/compiler/case.clj22
-rw-r--r--src/lux/host.clj6
-rw-r--r--src/lux/lexer.clj65
-rw-r--r--src/lux/macro.clj32
-rw-r--r--src/lux/parser.clj63
11 files changed, 577 insertions, 504 deletions
diff --git a/source/lux.lux b/source/lux.lux
index d3ed0c3a3..9a0bab625 100644
--- a/source/lux.lux
+++ b/source/lux.lux
@@ -23,17 +23,21 @@
## this [arg1 arg2]) [arg3]))]))
## Base functions & macros
+(def' _meta
+ (lambda' _ data
+ (#Meta [["" -1 -1] data])))
+
(def' let'
(lambda' _ tokens
(lambda' _ state
(case' tokens
(#Cons [lhs (#Cons [rhs (#Cons [body #Nil])])])
(#Right [state
- (#Cons [(#Form (#Cons [(#Symbol ["" "case'"])
- (#Cons [rhs
- (#Cons [lhs
- (#Cons [body
- #Nil])])])]))
+ (#Cons [(_meta (#Form (#Cons [(_meta (#Symbol ["" "case'"]))
+ (#Cons [rhs
+ (#Cons [lhs
+ (#Cons [body
+ #Nil])])])])))
#Nil])]))
)))
(declare-macro let')
@@ -42,33 +46,33 @@
(lambda' _ tokens
(lambda' _ state
(let' output (case' tokens
- (#Cons [(#Tuple (#Cons [arg args'])) (#Cons [body #Nil])])
- (#Form (#Cons [(#Symbol ["" "lambda'"])
- (#Cons [(#Symbol ["" ""])
- (#Cons [arg
- (#Cons [(case' args'
- #Nil
- body
-
- _
- (#Form (#Cons [(#Symbol ["lux" "lambda"])
- (#Cons [(#Tuple args')
- (#Cons [body #Nil])])])))
- #Nil])])])]))
-
- (#Cons [(#Symbol self) (#Cons [(#Tuple (#Cons [arg args'])) (#Cons [body #Nil])])])
- (#Form (#Cons [(#Symbol ["" "lambda'"])
- (#Cons [(#Symbol self)
- (#Cons [arg
- (#Cons [(case' args'
- #Nil
- body
-
- _
- (#Form (#Cons [(#Symbol ["lux" "lambda"])
- (#Cons [(#Tuple args')
- (#Cons [body #Nil])])])))
- #Nil])])])])))
+ (#Cons [(#Meta [_ (#Tuple (#Cons [arg args']))]) (#Cons [body #Nil])])
+ (_meta (#Form (#Cons [(_meta (#Symbol ["" "lambda'"]))
+ (#Cons [(_meta (#Symbol ["" ""]))
+ (#Cons [arg
+ (#Cons [(case' args'
+ #Nil
+ body
+
+ _
+ (_meta (#Form (#Cons [(_meta (#Symbol ["lux" "lambda"]))
+ (#Cons [(_meta (#Tuple args'))
+ (#Cons [body #Nil])])]))))
+ #Nil])])])])))
+
+ (#Cons [(#Meta [_ (#Symbol self)]) (#Cons [(#Meta [_ (#Tuple (#Cons [arg args']))]) (#Cons [body #Nil])])])
+ (_meta (#Form (#Cons [(_meta (#Symbol ["" "lambda'"]))
+ (#Cons [(_meta (#Symbol self))
+ (#Cons [arg
+ (#Cons [(case' args'
+ #Nil
+ body
+
+ _
+ (_meta (#Form (#Cons [(_meta (#Symbol ["lux" "lambda"]))
+ (#Cons [(_meta (#Tuple args'))
+ (#Cons [body #Nil])])]))))
+ #Nil])])])]))))
(#Right [state (#Cons [output #Nil])]))
)))
(declare-macro lambda)
@@ -76,31 +80,31 @@
(def' def
(lambda [tokens state]
(let' output (case' tokens
- (#Cons [(#Symbol name) (#Cons [body #Nil])])
- (#Form (#Cons [(#Symbol ["" "def'"]) tokens]))
+ (#Cons [(#Meta [_ (#Symbol name)]) (#Cons [body #Nil])])
+ (_meta (#Form (#Cons [(_meta (#Symbol ["" "def'"])) tokens])))
- (#Cons [(#Form (#Cons [(#Symbol name) args]))
+ (#Cons [(#Meta [_ (#Form (#Cons [(#Meta [_ (#Symbol name)]) args]))])
(#Cons [body #Nil])])
- (#Form (#Cons [(#Symbol ["" "def'"])
- (#Cons [(#Symbol name)
- (#Cons [(#Form (#Cons [(#Symbol ["lux" "lambda"])
- (#Cons [(#Symbol name)
- (#Cons [(#Tuple args)
- (#Cons [body #Nil])])])]))
- #Nil])])])))
+ (_meta (#Form (#Cons [(_meta (#Symbol ["" "def'"]))
+ (#Cons [(_meta (#Symbol name))
+ (#Cons [(_meta (#Form (#Cons [(_meta (#Symbol ["lux" "lambda"]))
+ (#Cons [(_meta (#Symbol name))
+ (#Cons [(_meta (#Tuple args))
+ (#Cons [body #Nil])])])])))
+ #Nil])])]))))
(#Right [state (#Cons [output #Nil])]))))
(declare-macro def)
(def (defmacro tokens state)
(let' [fn-name fn-def] (case' tokens
- (#Cons [(#Form (#Cons [(#Symbol fn-name) args]))
+ (#Cons [(#Meta [_ (#Form (#Cons [(#Meta [_ (#Symbol fn-name)]) args]))])
(#Cons [body #Nil])])
[fn-name
- (#Form (#Cons [(#Symbol ["lux" "def"])
- (#Cons [(#Form (#Cons [(#Symbol fn-name) args]))
- (#Cons [body
- #Nil])])]))])
- (let' declaration (#Form (#Cons [(#Symbol ["" "declare-macro"]) (#Cons [(#Symbol fn-name) #Nil])]))
+ (_meta (#Form (#Cons [(_meta (#Symbol ["lux" "def"]))
+ (#Cons [(_meta (#Form (#Cons [(_meta (#Symbol fn-name)) args])))
+ (#Cons [body
+ #Nil])])])))])
+ (let' declaration (_meta (#Form (#Cons [(_meta (#Symbol ["" "declare-macro"])) (#Cons [(_meta (#Symbol fn-name)) #Nil])])))
(#Right [state (#Cons [fn-def (#Cons [declaration #Nil])])]))))
(declare-macro defmacro)
@@ -138,10 +142,10 @@
(defmacro (list xs state)
(let' xs' (reverse xs)
(let' output (fold (lambda [tail head]
- (#Form (#Cons [(#Tag ["lux" "Cons"])
- (#Cons [(#Tuple (#Cons [head (#Cons [tail #Nil])]))
- #Nil])])))
- (#Tag ["lux" "Nil"])
+ (_meta (#Form (#Cons [(_meta (#Tag ["lux" "Cons"]))
+ (#Cons [(_meta (#Tuple (#Cons [head (#Cons [tail #Nil])])))
+ #Nil])]))))
+ (_meta (#Tag ["lux" "Nil"]))
xs')
(#Right [state (#Cons [output #Nil])]))))
@@ -152,7 +156,7 @@
(#Cons [last init'])
(let' output (fold (lambda [tail head]
- (#Form (list (#Tag ["lux" "Cons"]) (#Tuple (list head tail)))))
+ (_meta (#Form (list (_meta (#Tag ["lux" "Cons"])) (_meta (#Tuple (list head tail)))))))
last
init')
(#Right [state (#Cons [output #Nil])]))))
@@ -167,11 +171,11 @@
(defmacro (let tokens state)
(case' tokens
- (#Cons [(#Tuple bindings) (#Cons [body #Nil])])
+ (#Cons [(#Meta [_ (#Tuple bindings)]) (#Cons [body #Nil])])
(let' output (fold (lambda [body binding]
(case' binding
[label value]
- (#Form (list (#Symbol ["lux" "let'"]) label value body))))
+ (_meta (#Form (list (_meta (#Symbol ["lux" "let'"])) label value body)))))
body
(reverse (as-pairs bindings)))
(#Right [state (list output)]))))
@@ -184,8 +188,8 @@
#Nil
ys
- (#Cons [x xs*])
- (#Cons [x (++ xs* ys)])))
+ (#Cons [x xs'])
+ (#Cons [x (++ xs' ys)])))
(def concat
(fold ++ #Nil))
@@ -200,47 +204,53 @@
(def flat-map (. concat map))
+(def (wrap-meta content)
+ (_meta (#Form (list (_meta (#Tag ["lux" "Meta"]))
+ (_meta (#Tuple (list (_meta (#Tuple (list (_meta (#Form (list (_meta (#Tag ["lux" "Text"])) (_meta (#Text "")))))
+ (_meta (#Form (list (_meta (#Tag ["lux" "Int"])) (_meta (#Int -1)))))
+ (_meta (#Form (list (_meta (#Tag ["lux" "Int"])) (_meta (#Int -1))))))))
+ (_meta content))))))))
+
(def (untemplate-list tokens)
(case' tokens
#Nil
- (#Tag ["lux" "Nil"])
+ (_meta (#Tag ["lux" "Nil"]))
(#Cons [token tokens'])
- (#Form (#Cons [(#Tag ["lux" "Cons"])
- (#Cons [(#Tuple (#Cons [token (#Cons [(untemplate-list tokens') #Nil])]))
- #Nil])]))))
+ (_meta (#Form (list (_meta (#Tag ["lux" "Cons"]))
+ (_meta (#Tuple (list token (untemplate-list tokens')))))))))
(def (untemplate token)
(case' token
- (#Bool value)
- (#Form (list (#Tag ["lux" "Bool"]) (#Bool value)))
-
- (#Int value)
- (#Form (list (#Tag ["lux" "Int"]) (#Int value)))
+ (#Meta [_ (#Bool value)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Bool"])) (_meta (#Bool value)))))
+
+ (#Meta [_ (#Int value)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Int"])) (_meta (#Int value)))))
- (#Real value)
- (#Form (list (#Tag ["lux" "Real"]) (#Real value)))
+ (#Meta [_ (#Real value)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Real"])) (_meta (#Real value)))))
- (#Char value)
- (#Form (list (#Tag ["lux" "Char"]) (#Char value)))
+ (#Meta [_ (#Char value)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Char"])) (_meta (#Char value)))))
- (#Text value)
- (#Form (list (#Tag ["lux" "Text"]) (#Text value)))
+ (#Meta [_ (#Text value)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Text"])) (_meta (#Text value)))))
- (#Tag [module name])
- (#Form (list (#Tag ["lux" "Tag"]) (#Tuple (list (#Text module) (#Text name)))))
+ (#Meta [_ (#Tag [module name])])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Tag"])) (_meta (#Tuple (list (_meta (#Text module)) (_meta (#Text name))))))))
- (#Symbol [module name])
- (#Form (list (#Tag ["lux" "Symbol"]) (#Tuple (list (#Text module) (#Text name)))))
+ (#Meta [_ (#Symbol [module name])])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Symbol"])) (_meta (#Tuple (list (_meta (#Text module)) (_meta (#Text name))))))))
- (#Tuple elems)
- (#Form (list (#Tag ["lux" "Tuple"]) (untemplate-list (map untemplate elems))))
+ (#Meta [_ (#Tuple elems)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Tuple"])) (untemplate-list (map untemplate elems)))))
- (#Form (#Cons [(#Symbol [_ "~"]) (#Cons [unquoted #Nil])]))
- unquoted
+ (#Meta [_ (#Form (#Cons [(#Meta [_ (#Symbol [_ "~"])]) (#Cons [(#Meta [_ unquoted]) #Nil])]))])
+ (_meta unquoted)
- (#Form elems)
- (#Form (list (#Tag ["lux" "Form"]) (untemplate-list (map untemplate elems))))
+ (#Meta [_ (#Form elems)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Form"])) (untemplate-list (map untemplate elems)))))
))
(defmacro (` tokens state)
@@ -261,10 +271,10 @@
#Nil
#Nil
- (#Cons [x xs*])
+ (#Cons [x xs'])
(if (p x)
- (filter p xs*)
- (#Cons [x (filter p xs*)]))))
+ (#Cons [x (filter p xs')])
+ (filter p xs'))))
(def (return val)
(lambda [state]
@@ -279,7 +289,7 @@
(case' (v state)
(#Right [state' x])
(f x state')
-
+
(#Left msg)
(#Left msg))))
@@ -416,7 +426,7 @@
(case' xs
#Nil
xs
-
+
(#Cons [x #Nil])
xs
@@ -428,14 +438,14 @@
#Nil true
_ false))
-## ## (do-template [<name> <op>]
-## ## (def (<name> p xs)
-## ## (case xs
-## ## #Nil true
-## ## (#Cons [x xs']) (<op> (p x) (<name> p xs'))))
+## ## ## (do-template [<name> <op>]
+## ## ## (def (<name> p xs)
+## ## ## (case xs
+## ## ## #Nil true
+## ## ## (#Cons [x xs']) (<op> (p x) (<name> p xs'))))
-## ## [every? and]
-## ## [any? or])
+## ## ## [every? and]
+## ## ## [any? or])
(def (range from to)
(if (int< from to)
@@ -444,7 +454,7 @@
(def (tuple->list tuple)
(case' tuple
- (#Tuple list)
+ (#Meta [_ (#Tuple list)])
list))
(def (zip2 xs ys)
@@ -468,7 +478,7 @@
(def (get-ident x)
(case' x
- (#Symbol [_ ident])
+ (#Meta [_ (#Symbol [_ ident])])
ident))
(def (text-++ x y)
@@ -480,26 +490,26 @@
(def (apply-template env template)
(case' template
- (#Symbol [_ ident])
+ (#Meta [_ (#Symbol [_ ident])])
(case' (get ident env)
(#Some subst)
subst
_
template)
-
- (#Tuple elems)
- (#Tuple (map (apply-template env) elems))
- (#Form elems)
- (#Form (map (apply-template env) elems))
+ (#Meta [_ (#Tuple elems)])
+ (_meta (#Tuple (map (apply-template env) elems)))
+
+ (#Meta [_ (#Form elems)])
+ (_meta (#Form (map (apply-template env) elems)))
- (#Record members)
- (#Record (map (lambda [kv]
- (case' kv
- [slot value]
- [(apply-template env slot) (apply-template env value)]))
- members))
+ (#Meta [_ (#Record members)])
+ (_meta (#Record (map (lambda [kv]
+ (case' kv
+ [slot value]
+ [(apply-template env slot) (apply-template env value)]))
+ members)))
_
template))
@@ -514,11 +524,11 @@
(map (. apply (zip2 bindings-list)))
return))))
-## ## (do-template [<name> <offset>]
-## ## (def <name> (int+ <offset>))
+## ## ## (do-template [<name> <offset>]
+## ## ## (def <name> (int+ <offset>))
-## ## [inc 1]
-## ## [dec -1])
+## ## ## [inc 1]
+## ## ## [dec -1])
(def (int= x y)
(jvm-leq x y))
@@ -611,58 +621,58 @@
(jvm-invokevirtual java.lang.Object "toString" []
int []))
-## ## (def gensym
-## ## (lambda [state]
-## ## [(update@ #gen-seed inc state)
-## ## (#Symbol ($ text-++ "__" (show-int (get@ #gen-seed state)) "__"))]))
+## (def gensym
+## (lambda [state]
+## [(update@ #gen-seed inc state)
+## (#Symbol ($ text-++ "__" (show-int (get@ #gen-seed state)) "__"))]))
-## ## ## (do-template [<name> <member>]
-## ## ## (def (<name> pair)
-## ## ## (case' pair
-## ## ## [f s]
-## ## ## <member>))
+## (do-template [<name> <member>]
+## (def (<name> pair)
+## (case' pair
+## [f s]
+## <member>))
-## ## ## [first f]
-## ## ## [second s])
+## [first f]
+## [second s])
(def (show-syntax syntax)
(case' syntax
- (#Bool value)
+ (#Meta [_ (#Bool value)])
(jvm-invokevirtual java.lang.Object "toString" []
value [])
-
- (#Int value)
+
+ (#Meta [_ (#Int value)])
(jvm-invokevirtual java.lang.Object "toString" []
value [])
-
- (#Real value)
+
+ (#Meta [_ (#Real value)])
(jvm-invokevirtual java.lang.Object "toString" []
value [])
-
- (#Char value)
+
+ (#Meta [_ (#Char value)])
(jvm-invokevirtual java.lang.Object "toString" []
value [])
-
- (#Text value)
+
+ (#Meta [_ (#Text value)])
(jvm-invokevirtual java.lang.Object "toString" []
value [])
- (#Symbol [module name])
+ (#Meta [_ (#Symbol [module name])])
($ text-++ module ";" name)
- (#Tag [module name])
+ (#Meta [_ (#Tag [module name])])
($ text-++ "#" module ";" name)
- (#Tuple members)
+ (#Meta [_ (#Tuple members)])
($ text-++ "[" (fold text-++ "" (interpose " " (map show-syntax members))) "]")
-
- (#Form members)
+
+ (#Meta [_ (#Form members)])
($ text-++ "(" (fold text-++ "" (interpose " " (map show-syntax members))) ")")
))
(defmacro (do tokens)
(case' tokens
- (#Cons [(#Tuple bindings) (#Cons [body #Nil])])
+ (#Cons [(#Meta [_ (#Tuple bindings)]) (#Cons [body #Nil])])
(let [output (fold (lambda [body binding]
(case' binding
[lhs rhs]
@@ -684,16 +694,16 @@
(defmacro ($keys tokens)
(case' tokens
- (#Cons [(#Tuple fields) #Nil])
- (return (list (#Record (map (lambda [slot]
- (case' slot
- (#Tag [module name])
- [($ text-++ module ";" name) (#Symbol [module name])]))
- fields))))))
+ (#Cons [(#Meta [_ (#Tuple fields)]) #Nil])
+ (return (list (_meta (#Record (map (lambda [slot]
+ (case' slot
+ (#Meta [_ (#Tag [module name])])
+ [($ text-++ module ";" name) (_meta (#Symbol [module name]))]))
+ fields)))))))
(defmacro ($or tokens)
(case' tokens
- (#Cons [(#Tuple patterns) (#Cons [body #Nil])])
+ (#Cons [(#Meta [_ (#Tuple patterns)]) (#Cons [body #Nil])])
(return (flat-map (lambda [pattern] (list pattern body))
patterns))))
@@ -701,40 +711,41 @@
(defmacro (^ tokens)
(case' tokens
- (#Cons [(#Symbol [_ class-name]) #Nil])
- (return (list (` (#Data [(~ (#Text class-name)) (list)]))))
-
- (#Cons [(#Symbol [_ class-name]) (#Cons [(#Tuple params) #Nil])])
- (return (list (` (#Data [(~ (#Text class-name)) (~ (untemplate-list params))]))))))
+ (#Cons [(#Meta [_ (#Symbol [_ class-name])]) #Nil])
+ (return (list (` (#TData [(~ (_meta (#Text class-name))) (list)]))))
+
+ (#Cons [(#Meta [_ (#Symbol [_ class-name])]) (#Cons [(#Meta [_ (#Tuple params)]) #Nil])])
+ (return (list (` (#TData [(~ (_meta (#Text class-name))) (~ (untemplate-list params))]))))))
(defmacro (, members)
- (return (list (#Form (list+ (#Tag ["lux" "TTuple"]) (untemplate-list members))))))
+ (return (list (_meta (#Form (list+ (_meta (#Tag ["lux" "TTuple"])) (untemplate-list members)))))))
(defmacro (| members)
(let [members' (map (lambda [m]
(case' m
- (#Tag [module name])
+ (#Meta [_ (#Tag [module name])])
[($ text-++ module ";" name) (` (#Tuple (list)))]
-
- (#Form (#Cons [(#Tag [module name]) (#Cons [value #Nil])]))
+
+ (#Meta [_ (#Form (#Cons [(#Meta [_ (#Tag [module name])]) (#Cons [value #Nil])]))])
[($ text-++ module ";" name) (` (#Tuple (~ value)))]))
members)]
- (return (list (#Form (list+ (#Tag ["lux" "TVariant"]) (untemplate-list members)))))))
+ (return (list (_meta (#Form (list+ (_meta (#Tag ["lux" "TVariant"])) (untemplate-list members))))))))
(defmacro (& members)
(let [members' (map (lambda [m]
(case' m
- (#Form (#Cons [(#Tag [module name]) (#Cons [value #Nil])]))
+ (#Meta [_ (#Form (#Cons [(#Meta [_ (#Tag [module name])]) (#Cons [value #Nil])]))])
[($ text-++ module ";" name) (` (#Tuple (~ value)))]))
members)]
- (return (list (#Form (list+ (#Tag ["lux" "TRecord"]) (untemplate-list members)))))))
+ (return (list (_meta (#Form (list+ (_meta (#Tag ["lux" "TRecord"])) (untemplate-list members))))))))
(defmacro (-> tokens)
(case' (reverse tokens)
(#Cons [f-return f-args])
(fold (lambda [f-return f-arg]
- (#Lambda [f-arg f-return]))
- f-return f-args)))
+ (` (#TLambda [(~ f-arg) (~ f-return)])))
+ f-return
+ f-args)))
(def (text= x y)
(jvm-invokevirtual java.lang.Object "equals" [java.lang.Object]
@@ -743,56 +754,56 @@
(def (replace-ident ident value syntax)
(let [[module name] ident]
(case' syntax
- (#Symbol [?module ?name])
+ (#Meta [_ (#Symbol [?module ?name])])
(if (and (text= module ?module)
(text= name ?name))
value
syntax)
- (#Form members)
- (#Form (map (replace-ident ident value) members))
+ (#Meta [_ (#Form members)])
+ (_meta (#Form (map (replace-ident ident value) members)))
- (#Tuple members)
- (#Tuple (map (replace-ident ident value) members))
+ (#Meta [_ (#Tuple members)])
+ (_meta (#Tuple (map (replace-ident ident value) members)))
- (#Record members)
- (#Record (map (lambda [kv]
- (case' kv
- [k v]
- [k (replace-ident ident value v)]))
- members))
+ (#Meta [_ (#Record members)])
+ (_meta (#Record (map (lambda [kv]
+ (case' kv
+ [k v]
+ [k (replace-ident ident value v)]))
+ members)))
_
syntax)))
(defmacro (All tokens)
(let [[name args body] (case' tokens
- (#Cons [(#Symbol [_ name]) (#Cons [(#Tuple args) (#Cons [body #Nil])])])
+ (#Cons [(#Meta [_ (#Symbol [_ name])]) (#Cons [(#Meta [_ (#Tuple args)]) (#Cons [body #Nil])])])
[name args body]
-
- (#Cons [(#Tuple args) (#Cons [body #Nil])])
+
+ (#Cons [(#Meta [_ (#Tuple args)]) (#Cons [body #Nil])])
["" args body])
rolled (fold (lambda [body arg]
(case' arg
- (#Symbol [arg-module arg-name])
- (` (#All (list) (~ (#Text "")) (~ (#Text arg-name)) (~ (replace-ident [arg-module arg-name]
- (` (#Bound (~ (#Text arg-name))))
- body))))))
+ (#Meta [_ (#Symbol [arg-module arg-name])])
+ (` (#TAll (list) "" (~ (_meta (#Text arg-name))) (~ (replace-ident [arg-module arg-name]
+ (` (#TBound (~ (#Text arg-name))))
+ body))))))
body
args)]
(case' rolled
- (#Form (#Cons [(#Tag ["lux" "TAll"]) (#Cons [env (#Cons [(#Test "") (#Cons [(#Text arg-name) (#Cons [body #Nil])])])])]))
- (return (list (` (#All (~ env) (~ (#Text name)) (~ (#Text arg-name))
- (~ (replace-ident arg-name (` (#Bound (~ (#Text name))))
- body)))))))))
+ (#Meta [_ (#Form (#Cons [(#Meta [_ (#Tag ["lux" "TAll"])]) (#Cons [env (#Cons [(#Meta [_ (#Text "")]) (#Cons [(#Meta [_ (#Text arg-name)]) (#Cons [body #Nil])])])])]))])
+ (return (list (` (#TAll (~ env) (~ (#Text name)) (~ (#Text arg-name))
+ (~ (replace-ident arg-name (` (#TBound (~ (#Text name))))
+ body)))))))))
(defmacro (Exists tokens)
(case' tokens
(#Cons [args (#Cons [body #Nil])])
(return (list (` (All (~ args) (~ body)))))))
-(def Any #Any)
-(def Nothing #Nothing)
+(def Any #TAny)
+(def Nothing #TNothing)
(def Bool (^ java.lang.Boolean))
(def Int (^ java.lang.Long))
(def Real (^ java.lang.Double))
@@ -804,17 +815,17 @@
## (#Cons (, a (List a)))))
## (deftype #rec Type
-## (| #Any
-## #Nothing
-## (#Data Text)
-## (#Tuple (List Type))
-## (#Variant (List (, Text Type)))
-## (#Record (List (, Text Type)))
-## (#Lambda (, Type Type))
-## (#Bound Text)
-## (#Var Int)
-## (#All (, (List (, Text Type)) Text Text Type))
-## (#App (, Type Type))))
+## (| #TAny
+## #TNothing
+## (#TData Text)
+## (#TTuple (List Type))
+## (#TVariant (List (, Text Type)))
+## (#TRecord (List (, Text Type)))
+## (#TLambda (, Type Type))
+## (#TBound Text)
+## (#TVar Int)
+## (#TAll (, (List (, Text Type)) Text Text Type))
+## (#TApp (, Type Type))))
## (deftype (Either l r)
## (| (#Left l)
@@ -929,20 +940,20 @@
## (= x y)))
## (zip2 xs ys)))))
-## ## (def (with tokens)
-## ## ...)
+## (def (with tokens)
+## ...)
-## ## TODO: Full pattern-matching
-## ## TODO: Type-related macros
-## ## TODO: (Im|Ex)ports-related macros
-## ## TODO: Macro-related macros
+## TODO: Full pattern-matching
+## TODO: Type-related macros
+## TODO: (Im|Ex)ports-related macros
+## TODO: Macro-related macros
-## ## (import "lux")
-## ## (module-alias "lux" "l")
-## ## (def-alias "lux;map" "map")
+## (import "lux")
+## (module-alias "lux" "l")
+## (def-alias "lux;map" "map")
-## ## (def (require tokens)
-## ## (case tokens
-## ## ...))
+## (def (require tokens)
+## (case tokens
+## ...))
-## ## (require lux #as l #refer [map])
+## (require lux #as l #refer [map])
diff --git a/src/lux/analyser.clj b/src/lux/analyser.clj
index 30f829ee7..751e41923 100644
--- a/src/lux/analyser.clj
+++ b/src/lux/analyser.clj
@@ -14,378 +14,423 @@
;; [Utils]
(defn ^:private parse-handler [[catch+ finally+] token]
(matchv ::M/objects [token]
- [["Form" ["Cons" [["Symbol" [_ "jvm-catch"]]
- ["Cons" [["Symbol" [_ ?ex-class]]
- ["Cons" [["Symbol" [_ ?ex-arg]]
- ["Cons" [?catch-body
- ["Nil" _]]]]]]]]]]]
+ [["lux;Meta" [meta ["Form" ["Cons" [["lux;Meta" [_ ["Symbol" [_ "jvm-catch"]]]]
+ ["Cons" [["lux;Meta" [_ ["Symbol" [_ ?ex-class]]]]
+ ["Cons" [["lux;Meta" [_ ["Symbol" [_ ?ex-arg]]]]
+ ["Cons" [?catch-body
+ ["Nil" _]]]]]]]]]]]]]
[(concat catch+ (list [?ex-class ?ex-arg ?catch-body])) finally+]
- [["Form" ["Cons" [["Symbol" [_ "jvm-finally"]]
- ["Cons" [?finally-body
- ["Nil" _]]]]]]]
+ [["lux;Meta" [meta ["Form" ["Cons" [["lux;Meta" [_ ["Symbol" [_ "jvm-finally"]]]]
+ ["Cons" [?finally-body
+ ["Nil" _]]]]]]]]]
[catch+ ?finally-body]))
(defn ^:private analyse-basic-ast [analyse eval! token]
;; (prn 'analyse-basic-ast (aget token 0))
+ ;; (when (= "lux;Tag" (aget token 0))
+ ;; (prn 'analyse-basic-ast/tag (aget token 1)))
;; (prn 'analyse-basic-ast token (&/show-ast token))
(matchv ::M/objects [token]
;; Standard special forms
- [["lux;Bool" ?value]]
+ [["lux;Meta" [meta ["lux;Bool" ?value]]]]
(return (&/|list (&/V "Expression" (&/T (&/V "bool" ?value) (&/V "lux;TData" (&/T "java.lang.Boolean" (&/V "lux;Nil" nil)))))))
- [["lux;Int" ?value]]
+ [["lux;Meta" [meta ["lux;Int" ?value]]]]
(return (&/|list (&/V "Expression" (&/T (&/V "int" ?value) (&/V "lux;TData" (&/T "java.lang.Long" (&/V "lux;Nil" nil)))))))
- [["lux;Real" ?value]]
+ [["lux;Meta" [meta ["lux;Real" ?value]]]]
(return (&/|list (&/V "Expression" (&/T (&/V "real" ?value) (&/V "lux;TData" (&/T "java.lang.Double" (&/V "lux;Nil" nil)))))))
- [["lux;Char" ?value]]
+ [["lux;Meta" [meta ["lux;Char" ?value]]]]
(return (&/|list (&/V "Expression" (&/T (&/V "char" ?value) (&/V "lux;TData" (&/T "java.lang.Character" (&/V "lux;Nil" nil)))))))
- [["lux;Text" ?value]]
+ [["lux;Meta" [meta ["lux;Text" ?value]]]]
(return (&/|list (&/V "Expression" (&/T (&/V "text" ?value) (&/V "lux;TData" (&/T "java.lang.String" (&/V "lux;Nil" nil)))))))
- [["lux;Tuple" ?elems]]
+ [["lux;Meta" [meta ["lux;Tuple" ?elems]]]]
(&&lux/analyse-tuple analyse ?elems)
- [["lux;Record" ?elems]]
+ [["lux;Meta" [meta ["lux;Record" ?elems]]]]
(&&lux/analyse-record analyse ?elems)
- [["lux;Tag" [?module ?name]]]
+ [["lux;Meta" [meta ["lux;Tag" [?module ?name]]]]]
(let [tuple-type (&/V "lux;Tuple" (&/V "lux;Nil" nil))
?tag (str ?module ";" ?name)]
(return (&/|list (&/V "Expression" (&/T (&/V "variant" (&/T ?tag (&/V "Expression" (&/T (&/V "tuple" (&/|list)) tuple-type))))
(&/V "lux;TVariant" (&/V "lux;Cons" (&/T (&/T ?tag tuple-type) (&/V "lux;Nil" nil)))))))))
- [["lux;Symbol" [_ "jvm-null"]]]
+ [["lux;Meta" [meta ["lux;Symbol" [_ "jvm-null"]]]]]
(return (&/|list (&/V "Expression" (&/T (&/V "jvm-null" nil) (&/V "lux;TData" (&/T "null" (&/V "lux;Nil" nil)))))))
- [["lux;Symbol" ?ident]]
+ [["lux;Meta" [meta ["lux;Symbol" ?ident]]]]
(&&lux/analyse-ident analyse ?ident)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "case'"]]
- ["lux;Cons" [?variant ?branches]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "case'"]]]]
+ ["lux;Cons" [?variant ?branches]]]]]]]]
(&&lux/analyse-case analyse ?variant ?branches)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "lambda'"]]
- ["lux;Cons" [["lux;Symbol" [_ ?self]]
- ["lux;Cons" [["lux;Symbol" [_ ?arg]]
- ["lux;Cons" [?body
- ["lux;Nil" _]]]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "lambda'"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?self]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?arg]]]]
+ ["lux;Cons" [?body
+ ["lux;Nil" _]]]]]]]]]]]]]
(&&lux/analyse-lambda analyse ?self ?arg ?body)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "get@'"]] ["lux;Cons" [["lux;Tag" ?slot] ["lux;Cons" [?record ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "get@'"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tag" ?slot]]]
+ ["lux;Cons" [?record ["lux;Nil" _]]]]]]]]]]]
(&&lux/analyse-get analyse ?slot ?record)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "set@'"]] ["lux;Cons" [["lux;Tag" ?slot] ["lux;Cons" [?value ["lux;Cons" [?record ["lux;Nil" _]]]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "set@'"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tag" ?slot]]]
+ ["lux;Cons" [?value
+ ["lux;Cons" [?record
+ ["lux;Nil" _]]]]]]]]]]]]]
(&&lux/analyse-set analyse ?slot ?value ?record)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "def'"]] ["lux;Cons" [["lux;Symbol" [_ ?name]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
- (&&lux/analyse-def analyse ?name ?value)
-
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "declare-macro"]] ["lux;Cons" [["lux;Symbol" ?ident] ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "def'"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?name]]]]
+ ["lux;Cons" [?value
+ ["lux;Nil" _]]]]]]]]]]]
+ (do ;; (when (= "if" ?name)
+ ;; (prn "if" (&/show-ast ?value)))
+ (&&lux/analyse-def analyse ?name ?value))
+
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "declare-macro"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ?ident]]]
+ ["lux;Nil" _]]]]]]]]]
(&&lux/analyse-declare-macro ?ident)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "import'"]] ["lux;Cons" [["lux;Text" ?path] ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "import'"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?path]]]
+ ["lux;Nil" _]]]]]]]]]
(&&lux/analyse-import analyse ?path)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ ":"]] ["lux;Cons" [?value ["lux;Cons" [?type ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ":"]]]]
+ ["lux;Cons" [?value
+ ["lux;Cons" [?type
+ ["lux;Nil" _]]]]]]]]]]]
(&&lux/analyse-check analyse eval! ?type ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "coerce"]] ["lux;Cons" [?type ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "coerce"]]]]
+ ["lux;Cons" [?type
+ ["lux;Cons" [?value
+ ["lux;Nil" _]]]]]]]]]]]
(&&lux/analyse-coerce analyse eval! ?type ?value)
;; Host special forms
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "exec"]] ?exprs]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "exec"]]]]
+ ?exprs]]]]]]
(&&host/analyse-exec analyse ?exprs)
;; Integer arithmetic
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-iadd"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-iadd"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-iadd analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-isub"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-isub"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-isub analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-imul"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-imul"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-imul analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-idiv"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-idiv"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-idiv analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-irem"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-irem"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-irem analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-ieq"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-ieq"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-ieq analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-ilt"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-ilt"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-ilt analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-igt"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-igt"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-igt analyse ?x ?y)
;; Long arithmetic
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-ladd"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-ladd"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-ladd analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-lsub"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-lsub"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-lsub analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-lmul"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-lmul"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-lmul analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-ldiv"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-ldiv"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-ldiv analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-lrem"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-lrem"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-lrem analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-leq"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-leq"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-leq analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-llt"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-llt"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-llt analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-lgt"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-lgt"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-lgt analyse ?x ?y)
;; Float arithmetic
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-fadd"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-fadd"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-fadd analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-fsub"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-fsub"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-fsub analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-fmul"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-fmul"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-fmul analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-fdiv"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-fdiv"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-fdiv analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-frem"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-frem"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-frem analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-feq"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-feq"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-feq analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-flt"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-flt"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-flt analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-fgt"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-fgt"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-fgt analyse ?x ?y)
;; Double arithmetic
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-dadd"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-dadd"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-dadd analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-dsub"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-dsub"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-dsub analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-dmul"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-dmul"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-dmul analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-ddiv"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-ddiv"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-ddiv analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-drem"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-drem"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-drem analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-deq"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-deq"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-deq analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-dlt"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-dlt"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-dlt analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-dgt"]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-dgt"]]]] ["lux;Cons" [?y ["lux;Cons" [?x ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-dgt analyse ?x ?y)
;; Objects
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-null?"]] ["lux;Cons" [?object ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-null?"]]]]
+ ["lux;Cons" [?object
+ ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-null? analyse ?object)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-new"]]
- ["lux;Cons" [["lux;Symbol" [_ ?class]]
- ["lux;Cons" [["lux;Tuple" ?classes]
- ["lux;Cons" [["lux;Tuple" ?args]
- ["lux;Nil" _]]]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-new"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?classes]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?args]]]
+ ["lux;Nil" _]]]]]]]]]]]]]
(&&host/analyse-jvm-new analyse ?class ?classes ?args)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-getstatic"]]
- ["lux;Cons" [["lux;Symbol" [_ ?class]]
- ["lux;Cons" [["lux;Text" ?field]
- ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-getstatic"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?field]]]
+ ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-getstatic analyse ?class ?field)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-getfield"]]
- ["lux;Cons" [["lux;Symbol" [_ ?class]]
- ["lux;Cons" [["lux;Text" ?field]
- ["lux;Cons" [?object
- ["lux;Nil" _]]]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-getfield"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?field]]]
+ ["lux;Cons" [?object
+ ["lux;Nil" _]]]]]]]]]]]]]
(&&host/analyse-jvm-getfield analyse ?class ?field ?object)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-putstatic"]]
- ["lux;Cons" [["lux;Symbol" [_ ?class]]
- ["lux;Cons" [["lux;Text" ?field]
- ["lux;Cons" [?value
- ["lux;Nil" _]]]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-putstatic"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?field]]]
+ ["lux;Cons" [?value
+ ["lux;Nil" _]]]]]]]]]]]]]
(&&host/analyse-jvm-putstatic analyse ?class ?field ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-putfield"]]
- ["lux;Cons" [["lux;Symbol" [_ ?class]]
- ["lux;Cons" [["lux;Text" ?field]
- ["lux;Cons" [?object
- ["lux;Cons" [?value
- ["lux;Nil" _]]]]]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-putfield"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?field]]]
+ ["lux;Cons" [?object
+ ["lux;Cons" [?value
+ ["lux;Nil" _]]]]]]]]]]]]]]]
(&&host/analyse-jvm-putfield analyse ?class ?field ?object ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-invokestatic"]]
- ["lux;Cons" [["lux;Symbol" [_ ?class]]
- ["lux;Cons" [["lux;Text" ?method]
- ["lux;Cons" [["lux;Tuple" ?classes]
- ["lux;Cons" [["lux;Tuple" ?args]
- ["lux;Nil" _]]]]]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-invokestatic"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?method]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?classes]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?args]]]
+ ["lux;Nil" _]]]]]]]]]]]]]]]
(&&host/analyse-jvm-invokestatic analyse ?class ?method ?classes ?args)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-invokevirtual"]]
- ["lux;Cons" [["lux;Symbol" [_ ?class]]
- ["lux;Cons" [["lux;Text" ?method]
- ["lux;Cons" [["lux;Tuple" ?classes]
- ["lux;Cons" [?object
- ["lux;Cons" [["lux;Tuple" ?args]
- ["lux;Nil" _]]]]]]]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-invokevirtual"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?method]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?classes]]]
+ ["lux;Cons" [?object
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?args]]]
+ ["lux;Nil" _]]]]]]]]]]]]]]]]]
(&&host/analyse-jvm-invokevirtual analyse ?class ?method ?classes ?object ?args)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-invokeinterface"]]
- ["lux;Cons" [["lux;Symbol" [_ ?class]]
- ["lux;Cons" [["lux;Text" ?method]
- ["lux;Cons" [["lux;Tuple" ?classes]
- ["lux;Cons" [?object
- ["lux;Cons" [["lux;Tuple" ?args]
- ["lux;Nil" _]]]]]]]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-invokeinterface"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?method]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?classes]]]
+ ["lux;Cons" [?object
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?args]]]
+ ["lux;Nil" _]]]]]]]]]]]]]]]]]
(&&host/analyse-jvm-invokeinterface analyse ?class ?method ?classes ?object ?args)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-invokespecial"]]
- ["lux;Cons" [["lux;Symbol" [_ ?class]]
- ["lux;Cons" [["lux;Text" ?method]
- ["lux;Cons" [["lux;Tuple" ?classes]
- ["lux;Cons" [?object
- ["lux;Cons" [["lux;Tuple" ?args]
- ["lux;Nil" _]]]]]]]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-invokespecial"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?method]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?classes]]]
+ ["lux;Cons" [?object
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?args]]]
+ ["lux;Nil" _]]]]]]]]]]]]]]]]]
(&&host/analyse-jvm-invokespecial analyse ?class ?method ?classes ?object ?args)
;; Exceptions
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-try"]]
- ["lux;Cons" [?body
- ?handlers]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-try"]]]]
+ ["lux;Cons" [?body
+ ?handlers]]]]]]]]
(&&host/analyse-jvm-try analyse ?body (&/fold parse-handler [(list) nil] ?handlers))
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-throw"]]
- ["lux;Cons" [?ex
- ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-throw"]]]]
+ ["lux;Cons" [?ex
+ ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-throw analyse ?ex)
;; Syncronization/monitos
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-monitorenter"]]
- ["lux;Cons" [?monitor
- ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-monitorenter"]]]]
+ ["lux;Cons" [?monitor
+ ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-monitorenter analyse ?monitor)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-monitorexit"]]
- ["lux;Cons" [?monitor
- ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-monitorexit"]]]]
+ ["lux;Cons" [?monitor
+ ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-monitorexit analyse ?monitor)
;; Primitive conversions
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-d2f"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-d2f"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-d2f analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-d2i"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-d2i"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-d2i analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-d2l"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-d2l"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-d2l analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-f2d"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-f2d"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-f2d analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-f2i"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-f2i"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-f2i analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-f2l"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-f2l"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-f2l analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-i2b"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-i2b"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-i2b analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-i2c"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-i2c"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-i2c analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-i2d"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-i2d"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-i2d analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-i2f"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-i2f"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-i2f analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-i2l"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-i2l"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-i2l analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-i2s"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-i2s"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-i2s analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-l2d"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-l2d"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-l2d analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-l2f"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-l2f"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-l2f analyse ?value)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-l2i"]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-l2i"]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]
(&&host/analyse-jvm-l2i analyse ?value)
;; Bitwise operators
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-iand"]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-iand"]]]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-iand analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-ior"]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-ior"]]]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-ior analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-land"]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-land"]]]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-land analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-lor"]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-lor"]]]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-lor analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-lxor"]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-lxor"]]]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-lxor analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-lshl"]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-lshl"]]]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-lshl analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-lshr"]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-lshr"]]]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-lshr analyse ?x ?y)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-lushr"]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-lushr"]]]] ["lux;Cons" [?x ["lux;Cons" [?y ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-lushr analyse ?x ?y)
;; Arrays
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-new-array"]] ["lux;Cons" [["lux;Symbol" [_ ?class]] ["lux;Cons" [["lux;Int" ?length] ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-new-array"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Int" ?length]]]
+ ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-new-array analyse ?class ?length)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-aastore"]] ["lux;Cons" [?array ["lux;Cons" [["lux;Int" ?idx] ["lux;Cons" [?elem ["lux;Nil" _]]]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-aastore"]]]]
+ ["lux;Cons" [?array
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Int" ?idx]]]
+ ["lux;Cons" [?elem
+ ["lux;Nil" _]]]]]]]]]]]]]
(&&host/analyse-jvm-aastore analyse ?array ?idx ?elem)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-aaload"]] ["lux;Cons" [?array ["lux;Cons" [["lux;Int" ?idx] ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-aaload"]]]]
+ ["lux;Cons" [?array
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Int" ?idx]]]
+ ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-aaload analyse ?array ?idx)
;; Classes & interfaces
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-class"]] ["lux;Cons" [["lux;Symbol" [_ ?name]] ["lux;Cons" [["lux;Symbol" [_ ?super-class]] ["lux;Cons" [["lux;Tuple" ?fields] ["lux;Nil" _]]]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-class"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?name]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?super-class]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?fields]]]
+ ["lux;Nil" _]]]]]]]]]]]]]
(&&host/analyse-jvm-class analyse ?name ?super-class ?fields)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-interface"]] ["lux;Cons" [["lux;Symbol" [_ ?name]] ?members]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-interface"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?name]]]]
+ ?members]]]]]]]]
(&&host/analyse-jvm-interface analyse ?name ?members)
;; Programs
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "jvm-program"]] ["lux;Cons" [["lux;Symbol" [_ ?args]] ["lux;Cons" [?body ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "jvm-program"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?args]]]]
+ ["lux;Cons" [?body
+ ["lux;Nil" _]]]]]]]]]]]
(&&host/analyse-jvm-program analyse ?args ?body)
[_]
@@ -395,7 +440,7 @@
(fn [token]
;; (prn 'analyse-ast token)
(matchv ::M/objects [token]
- [["lux;Form" ["lux;Cons" [["lux;Tag" [?module ?name]] ?values]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Tag" [?module ?name]]]] ?values]]]]]]
(exec [;; :let [_ (prn 'PRE-ASSERT)]
:let [?tag (str ?module ";" ?name)]
:let [_ (assert (= 1 (&/|length ?values)) (str "[Analyser Error] Can only tag 1 value: " (pr-str token)))]
@@ -404,7 +449,7 @@
=value-type (&&/expr-type =value)]
(return (&/|list (&/V "Expression" (&/T (&/V "variant" (&/T ?tag =value)) (&/V "lux;TVariant" (&/V "lux;Cons" (&/T (&/T ?tag =value-type) (&/V "lux;Nil" nil)))))))))
- [["lux;Form" ["lux;Cons" [?fn ?args]]]]
+ [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [?fn ?args]]]]]]
(fn [state]
;; (prn '(&/show-ast ?fn) (&/show-ast ?fn))
(matchv ::M/objects [((&&/analyse-1 (analyse-ast eval!) ?fn) state)]
diff --git a/src/lux/analyser/case.clj b/src/lux/analyser/case.clj
index 38ec41e64..f6a0b2cc8 100644
--- a/src/lux/analyser/case.clj
+++ b/src/lux/analyser/case.clj
@@ -10,13 +10,13 @@
;; [Resources]
(defn locals [member]
(matchv ::M/objects [member]
- [["lux;Symbol" [_ ?name]]]
+ [["lux;Meta" [_ ["lux;Symbol" [_ ?name]]]]]
(&/|list ?name)
- [["lux;Tuple" ?submembers]]
+ [["lux;Meta" [_ ["lux;Tuple" ?submembers]]]]
(&/flat-map locals ?submembers)
- [["lux;Form" ["lux;Cons" [["lux;Tag" _] ?submembers]]]]
+ [["lux;Meta" [_ ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Tag" _]]] ?submembers]]]]]]
(&/flat-map locals ?submembers)
[_]
@@ -25,12 +25,12 @@
(defn analyse-branch [analyse max-registers bindings+body]
(|let [[bindings body] bindings+body]
(do ;; (prn 'analyse-branch max-registers (&/->seq bindings) body)
- (&/fold (fn [body* name]
- (&&/with-var
- (fn [=var]
- (&env/with-local name =var body*))))
- (&/fold (fn [body* _]
- (&env/with-local "" &type/+dont-care+ body*))
- (&&/analyse-1 analyse body)
- (&/|range (- max-registers (&/|length bindings))))
- (&/|reverse bindings)))))
+ (&/fold (fn [body* name]
+ (&&/with-var
+ (fn [=var]
+ (&env/with-local name =var body*))))
+ (&/fold (fn [body* _]
+ (&env/with-local "" &type/+dont-care+ body*))
+ (&&/analyse-1 analyse body)
+ (&/|range (- max-registers (&/|length bindings))))
+ (&/|reverse bindings)))))
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj
index 999c5df8a..b8963f73f 100644
--- a/src/lux/analyser/host.clj
+++ b/src/lux/analyser/host.clj
@@ -12,7 +12,7 @@
;; [Utils]
(defn ^:private extract-ident [ident]
(matchv ::M/objects [ident]
- [["lux;Symbol" [_ ?ident]]]
+ [["lux;Meta" [_ ["lux;Symbol" [_ ?ident]]]]]
(return ?ident)
[_]
@@ -155,7 +155,9 @@
(defn analyse-jvm-class [analyse ?name ?super-class ?fields]
(exec [?fields (&/map% (fn [?field]
(matchv ::M/objects [?field]
- [["lux;Tuple" ["lux;Cons" [["lux;Symbol" ?class] ["lux;Cons" [["lux;Symbol" ?field-name] ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [_ ["lux;Tuple" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ?class]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ?field-name]]]
+ ["lux;Nil" _]]]]]]]]]
(return [?class ?field-name])
[_]
@@ -172,13 +174,13 @@
(exec [=members (&/map% (fn [member]
;; (prn 'analyse-jvm-interface (&/show-ast member))
(matchv ::M/objects [member]
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ ":"]]
- ["lux;Cons" [["lux;Symbol" [_ ?member-name]]
- ["lux;Cons" [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "->"]]
- ["lux;Cons" [["lux;Tuple" ?inputs]
- ["lux;Cons" [["lux;Symbol" [_ ?output]]
- ["lux;Nil" _]]]]]]]]
- ["lux;Nil" _]]]]]]]]]
+ [["lux;Meta" [_ ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ":"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?member-name]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "->"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?inputs]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?output]]]]
+ ["lux;Nil" _]]]]]]]]]]
+ ["lux;Nil" _]]]]]]]]]]]
(do ;; (prn 'analyse-jvm-interface ?member-name ?inputs ?output)
(exec [?inputs (&/map% extract-ident ?inputs)]
(return [?member-name [?inputs ?output]])))
diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj
index f8555f9d1..e6dd0d1d0 100644
--- a/src/lux/analyser/lux.clj
+++ b/src/lux/analyser/lux.clj
@@ -46,7 +46,6 @@
(fail* (str "[Analyser Error] Unresolved identifier: " ident*)))))
(defn analyse-ident [analyse ident]
- ;; (prn 'analyse-ident ident)
(|let [[?module ?name] ident]
(do ;; (prn 'analyse-ident ?module ?name)
(exec [module-name &/get-module-name]
@@ -167,6 +166,7 @@
=case-type))))))
(defn analyse-lambda [analyse ?self ?arg ?body]
+ ;; (prn 'analyse-lambda ?self ?arg ?body)
(exec [=lambda-type* &type/fresh-lambda]
(matchv ::M/objects [=lambda-type*]
[["lux;TLambda" [=arg =return]]]
diff --git a/src/lux/base.clj b/src/lux/base.clj
index 80340ec30..7d0c03c86 100644
--- a/src/lux/base.clj
+++ b/src/lux/base.clj
@@ -177,6 +177,7 @@
(V "lux;Cons" (T x (|++ xs* ys)))))
(defn |map [f xs]
+ ;; (prn '|map (aget xs 0))
(matchv ::M/objects [xs]
[["lux;Nil" _]]
xs
@@ -322,7 +323,7 @@
xs))
(defn show-table [table]
- (prn 'show-table (aget table 0))
+ ;; (prn 'show-table (aget table 0))
(str "{{"
(->> table
(|map (fn [kv] (|let [[k v] kv] (str k " = ???"))))
@@ -424,11 +425,12 @@
(try-all% (|list (exec [output-h step
output-t (exhaust% step)]
(return (|cons output-h output-t)))
- (return (|list))
- (exec [? source-consumed?]
- (if ?
- (return (|list))
- (exhaust% step))))))
+ ;; (return (|list))
+ ;; (exec [? source-consumed?]
+ ;; (if ?
+ ;; (return (|list))
+ ;; (exhaust% step)))
+ )))
(defn ^:private normalize-char [char]
(case char
@@ -601,14 +603,14 @@
body)]
(body* (if local?
(update$ "lux;local-envs" #(|cons (update$ "lux;inner-closures" inc (|head %))
- (|tail %))
+ (|tail %))
state)
(update$ "lux;global-env" #(matchv ::M/objects [%]
- [["lux;Some" global-env]]
- (V "lux;Some" (update$ "lux;inner-closures" inc global-env))
+ [["lux;Some" global-env]]
+ (V "lux;Some" (update$ "lux;inner-closures" inc global-env))
- [_]
- %)
+ [_]
+ %)
state)))))
)))
@@ -632,31 +634,40 @@
(defn show-ast [ast]
;; (prn 'show-ast (aget ast 0))
+ ;; (prn 'show-ast (aget ast 1 1 0))
+ ;; (cond (= "lux;Meta" (aget ast 1 1 0))
+ ;; (prn 'EXTRA 'show-ast (aget ast 1 1 1 1 0))
+
+ ;; (= "lux;Symbol" (aget ast 1 1 0))
+ ;; (prn 'EXTRA 'show-ast (aget ast 1 1 1 1))
+
+ ;; :else
+ ;; nil)
(matchv ::M/objects [ast]
- [["lux;Bool" ?value]]
+ [["lux;Meta" [_ ["lux;Bool" ?value]]]]
(pr-str ?value)
- [["lux;Int" ?value]]
+ [["lux;Meta" [_ ["lux;Int" ?value]]]]
(pr-str ?value)
- [["lux;Real" ?value]]
+ [["lux;Meta" [_ ["lux;Real" ?value]]]]
(pr-str ?value)
- [["lux;Char" ?value]]
+ [["lux;Meta" [_ ["lux;Char" ?value]]]]
(pr-str ?value)
- [["lux;Text" ?value]]
+ [["lux;Meta" [_ ["lux;Text" ?value]]]]
(str "\"" ?value "\"")
- [["lux;Tag" [?module ?tag]]]
+ [["lux;Meta" [_ ["lux;Tag" [?module ?tag]]]]]
(str "#" ?module ";" ?tag)
- [["lux;Symbol" [?module ?ident]]]
+ [["lux;Meta" [_ ["lux;Symbol" [?module ?ident]]]]]
(str ?module ";" ?ident)
- [["lux;Tuple" ?elems]]
+ [["lux;Meta" [_ ["lux;Tuple" ?elems]]]]
(str "[" (->> ?elems (|map show-ast) (|interpose " ") (fold str "")) "]")
- [["lux;Form" ?elems]]
+ [["lux;Meta" [_ ["lux;Form" ?elems]]]]
(str "(" (->> ?elems (|map show-ast) (|interpose " ") (fold str "")) ")")
))
diff --git a/src/lux/compiler/case.clj b/src/lux/compiler/case.clj
index 10f451587..afa446df0 100644
--- a/src/lux/compiler/case.clj
+++ b/src/lux/compiler/case.clj
@@ -20,25 +20,25 @@
;; (prn '->match token)
;; (prn '->match (aget token 0))
(matchv ::M/objects [token]
- [["lux;Symbol" [_ ?name]]]
+ [["lux;Meta" [_ ["lux;Symbol" [_ ?name]]]]]
(&/T (inc register) (&/V "Pattern" (&/T $body (&/V "StoreMatch" register))))
- [["lux;Bool" ?value]]
+ [["lux;Meta" [_ ["lux;Bool" ?value]]]]
(&/T register (&/V "Pattern" (&/T $body (&/V "BoolMatch" ?value))))
- [["lux;Int" ?value]]
+ [["lux;Meta" [_ ["lux;Int" ?value]]]]
(&/T register (&/V "Pattern" (&/T $body (&/V "IntMatch" ?value))))
- [["lux;Real" ?value]]
+ [["lux;Meta" [_ ["lux;Real" ?value]]]]
(&/T register (&/V "Pattern" (&/T $body (&/V "RealMatch" ?value))))
- [["lux;Char" ?value]]
+ [["lux;Meta" [_ ["lux;Char" ?value]]]]
(&/T register (&/V "Pattern" (&/T $body (&/V "CharMatch" ?value))))
- [["lux;Text" ?value]]
+ [["lux;Meta" [_ ["lux;Text" ?value]]]]
(&/T register (&/V "Pattern" (&/T $body (&/V "TextMatch" ?value))))
- [["lux;Tuple" ?members]]
+ [["lux;Meta" [_ ["lux;Tuple" ?members]]]]
(|let [[register* =members] (&/fold (fn [register+=members member]
;; (prn 'register+=members (alength register+=members))
(|let [[_register =members] register+=members
@@ -50,13 +50,13 @@
?members)]
(&/T register* (&/V "Pattern" (&/T $body (&/V "TupleMatch" (&/|reverse =members))))))
- [["lux;Tag" [?module ?name]]]
+ [["lux;Meta" [_ ["lux;Tag" [?module ?name]]]]]
(|let [?tag (str ?module ";" ?name)]
(&/T register (&/V "Pattern" (&/T $body (&/V "VariantMatch" (&/T ?tag (&/V "Pattern" (&/T $body (&/V "TupleMatch" (&/|list))))))))))
- [["lux;Form" ["lux;Cons" [["lux;Tag" [?module ?name]]
- ["lux;Cons" [?value
- ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [_ ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Tag" [?module ?name]]]]
+ ["lux;Cons" [?value
+ ["lux;Nil" _]]]]]]]]]
(|let [?tag (str ?module ";" ?name)
[register* =value] (->match $body register ?value)]
(&/T register* (&/V "Pattern" (&/T $body (&/V "VariantMatch" (&/T ?tag =value))))))
diff --git a/src/lux/host.clj b/src/lux/host.clj
index 8954792d3..6432a6d5f 100644
--- a/src/lux/host.clj
+++ b/src/lux/host.clj
@@ -98,10 +98,12 @@
(defn extract-jvm-param [token]
(matchv ::M/objects [token]
- [["lux;Symbol" [_ ?ident]]]
+ [["lux;Meta" [_ ["lux;Symbol" [_ ?ident]]]]]
(full-class-name ?ident)
- [["lux;Form" ["lux;Cons" [["lux;Symbol" [_ "Array"]] ["lux;Cons" [["lux;Symbol" [_ ?inner]] ["lux;Nil" _]]]]]]]
+ [["lux;Meta" [_ ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ "Array"]]]]
+ ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?inner]]]]
+ ["lux;Nil" _]]]]]]]]]
(exec [=inner (full-class-name ?inner)]
(return (str "[L" (->class =inner) ";")))
diff --git a/src/lux/lexer.clj b/src/lux/lexer.clj
index 38a6a40d7..f53a01665 100644
--- a/src/lux/lexer.clj
+++ b/src/lux/lexer.clj
@@ -29,35 +29,35 @@
;; [Lexers]
(def ^:private lex-white-space
- (exec [[_ [_ white-space]] (&reader/read-regex #"^(\s+)")]
- (return (&/V "White_Space" white-space))))
+ (exec [[_ [meta white-space]] (&reader/read-regex #"^(\s+)")]
+ (return (&/V "lux;Meta" (&/T meta (&/V "White_Space" white-space))))))
(def ^:private lex-single-line-comment
- (exec [_ (&reader/read-text "##")
+ (exec [[_ [meta _]] (&reader/read-text "##")
[_ [_ comment]] (&reader/read-regex #"^([^\n]*)")
_ (&reader/read-regex #"^(\n?)")]
- (return (&/V "Comment" comment))))
+ (return (&/V "lux;Meta" (&/T meta (&/V "Comment" comment))))))
-(def ^:private lex-multi-line-comment
+(defn ^:private lex-multi-line-comment [___]
(exec [_ (&reader/read-text "#(")
- comment (&/try-all% (&/|list (exec [[_ [_ comment]] (&reader/read-regex #"(?is)^((?!#\().)*?(?=\)#)")]
- (return comment))
- (exec [[_ [_ pre]] (&reader/read-regex #"(?is)^(.+?(?=#\())")
- [_ inner] lex-multi-line-comment
- [_ [_ post]] (&reader/read-regex #"(?is)^(.+?(?=\)#))")]
- (return (str pre "#(" inner ")#" post)))))
+ [meta comment] (&/try-all% (&/|list (exec [[_ [meta comment]] (&reader/read-regex #"(?is)^((?!#\().)*?(?=\)#)")]
+ (return comment))
+ (exec [[_ [meta pre]] (&reader/read-regex #"(?is)^(.+?(?=#\())")
+ [_ inner] (lex-multi-line-comment nil)
+ [_ [_ post]] (&reader/read-regex #"(?is)^(.+?(?=\)#))")]
+ (return (str pre "#(" inner ")#" post)))))
_ (&reader/read-text ")#")]
- (return (&/V "Comment" comment))))
+ (return (&/V "lux;Meta" (&/T meta (&/V "Comment" comment))))))
(def ^:private lex-comment
(&/try-all% (&/|list lex-single-line-comment
- ;; lex-multi-line-comment
+ ;; (lex-multi-line-comment nil)
)))
(do-template [<name> <tag> <regex>]
(def <name>
- (exec [[_ [_ token]] (&reader/read-regex <regex>)]
- (return (&/V <tag> token))))
+ (exec [[_ [meta token]] (&reader/read-regex <regex>)]
+ (return (&/V "lux;Meta" (&/T meta (&/V <tag> token))))))
^:private lex-bool "Bool" #"^(true|false)"
^:private lex-int "Int" #"^-?(0|[1-9][0-9]*)"
@@ -65,52 +65,53 @@
)
(def ^:private lex-char
- (exec [_ (&reader/read-text "#\"")
+ (exec [[_ [meta _]] (&reader/read-text "#\"")
token (&/try-all% (&/|list (exec [escaped (&reader/read-regex #"^(\\.)")]
(escape-char escaped))
(exec [[_ [_ char]] (&reader/read-regex #"^(.)")]
(return char))))
_ (&reader/read-text "\"")]
- (return (&/V "Char" token))))
+ (return (&/V "lux;Meta" (&/T meta (&/V "Char" token))))))
(def ^:private lex-text
- (exec [_ (&reader/read-text "\"")
+ (exec [[_ [meta _]] (&reader/read-text "\"")
token (lex-text-body nil)
_ (&reader/read-text "\"")]
- (return (&/V "Text" token))))
+ (return (&/V "lux;Meta" (&/T meta (&/V "Text" token))))))
(def ^:private lex-ident
- (&/try-all% (&/|list (exec [_ (&reader/read-text ";")
+ (&/try-all% (&/|list (exec [[_ [meta _]] (&reader/read-text ";")
[_ [_ token]] (&reader/read-regex +ident-re+)
module-name &/get-module-name]
- (return (&/T module-name token)))
- (exec [[_ [_ token]] (&reader/read-regex +ident-re+)]
+ (return (&/V "lux;Meta" (&/T meta (&/T module-name token)))))
+ (exec [[_ [metma token]] (&reader/read-regex +ident-re+)]
(&/try-all% (&/|list (exec [_ (&reader/read-text ";")
[_ [_ local-token]] (&reader/read-regex +ident-re+)]
(&/try-all% (&/|list (exec [unaliased (&def/unalias-module token)]
- (return (&/T unaliased local-token)))
+ (return (&/V "lux;Meta" (&/T meta (&/T unaliased local-token)))))
(exec [? (&def/module-exists? token)]
(if ?
- (return (&/T token local-token))
+ (return (&/V "lux;Meta" (&/T meta (&/T token local-token))))
(fail (str "[Lexer Error] Unknown module: " token))))
)))
(exec [module-name &/get-module-name]
- (return (&/T module-name token))))))
+ (return (&/V "lux;Meta" (&/T meta (&/T module-name token)))))
+ )))
)))
(def ^:private lex-symbol
- (exec [ident lex-ident]
- (return (&/V "Symbol" ident))))
+ (exec [[_ [meta ident]] lex-ident]
+ (return (&/V "lux;Meta" (&/T meta (&/V "Symbol" ident))))))
(def ^:private lex-tag
- (exec [_ (&reader/read-text "#")
- ident lex-ident]
- (return (&/V "Tag" ident))))
+ (exec [[_ [meta _]] (&reader/read-text "#")
+ [_ [_ ident]] lex-ident]
+ (return (&/V "lux;Meta" (&/T meta (&/V "Tag" ident))))))
(do-template [<name> <text> <tag>]
(def <name>
- (exec [_ (&reader/read-text <text>)]
- (return (&/V <tag> nil))))
+ (exec [[_ [meta _]] (&reader/read-text <text>)]
+ (return (&/V "lux;Meta" (&/T meta (&/V <tag> nil))))))
^:private lex-open-paren "(" "Open_Paren"
^:private lex-close-paren ")" "Close_Paren"
diff --git a/src/lux/macro.clj b/src/lux/macro.clj
index 7b612cbbb..d5fee9eab 100644
--- a/src/lux/macro.clj
+++ b/src/lux/macro.clj
@@ -7,21 +7,19 @@
(defn expand [loader macro-class tokens]
(fn [state]
;; (prn 'expand macro-class tokens state)
- ;; (let [expansion (-> (.loadClass loader macro-class)
- ;; (.getField "_datum")
- ;; (.get nil)
- ;; (.apply tokens)
- ;; (.apply state))]
- ;; (matchv ::M/objects [expansion]
- ;; [["lux;Right" [state* nodes]]]
- ;; (doseq [node (&/->seq nodes)]
- ;; (prn 'expansion macro-class (&/show-ast node)))
+ (let [expansion (-> (.loadClass loader macro-class)
+ (.getField "_datum")
+ (.get nil)
+ (.apply tokens)
+ (.apply state))]
+ ;; (if (or (= "lux$_BQUOTE_" macro-class)
+ ;; (= "lux$if" macro-class))
+ ;; (matchv ::M/objects [expansion]
+ ;; [["lux;Right" [state* nodes]]]
+ ;; (doseq [node (&/->seq nodes)]
+ ;; (prn 'expansion macro-class (&/show-ast node)))
- ;; [_]
- ;; nil)
- ;; expansion)
- (-> (.loadClass loader macro-class)
- (.getField "_datum")
- (.get nil)
- (.apply tokens)
- (.apply state))))
+ ;; [_]
+ ;; nil))
+ expansion)
+ ))
diff --git a/src/lux/parser.clj b/src/lux/parser.clj
index 1b0a44f91..71fca764a 100644
--- a/src/lux/parser.clj
+++ b/src/lux/parser.clj
@@ -11,8 +11,8 @@
(exec [elems (&/repeat% parse)
token &lexer/lex]
(matchv ::M/objects [token]
- [[<close-token> _]]
- (return (&/|list (&/V <tag> (&/fold &/|++ (&/|list) elems))))
+ [["lux;Meta" [meta [<close-token> _]]]]
+ (return (&/V <tag> (&/fold &/|++ (&/|list) elems)))
[_]
(fail (str "[Parser Error] Unbalanced " <description> ".")))))
@@ -26,13 +26,13 @@
token &lexer/lex
:let [elems (&/fold &/|++ (&/|list) elems*)]]
(matchv ::M/objects [token]
- [["Close_Brace" _]]
- (fail (str "[Parser Error] Unbalanced braces."))
-
- [_]
+ [["lux;Meta" [meta ["Close_Brace" _]]]]
(if (even? (&/|length elems))
- (return (&/|list (&/V "lux;Record" (&/|as-pairs elems))))
- (fail (str "[Parser Error] Records must have an even number of elements."))))))
+ (return (&/V "lux;Record" (&/|as-pairs elems)))
+ (fail (str "[Parser Error] Records must have an even number of elements.")))
+
+ [_]
+ (fail (str "[Parser Error] Unbalanced braces.")))))
;; [Interface]
(def parse
@@ -41,41 +41,44 @@
;; :let [_ (prn 'parse (aget token 0))]
]
(matchv ::M/objects [token]
- [["White_Space" _]]
+ [["lux;Meta" [meta ["White_Space" _]]]]
(return (&/|list))
- [["Comment" _]]
+ [["lux;Meta" [meta ["Comment" _]]]]
(return (&/|list))
- [["Bool" ?value]]
- (return (&/|list (&/V "lux;Bool" (Boolean/parseBoolean ?value))))
+ [["lux;Meta" [meta ["Bool" ?value]]]]
+ (return (&/|list (&/V "lux;Meta" (&/T meta (&/V "lux;Bool" (Boolean/parseBoolean ?value))))))
- [["Int" ?value]]
- (return (&/|list (&/V "lux;Int" (Integer/parseInt ?value))))
+ [["lux;Meta" [meta ["Int" ?value]]]]
+ (return (&/|list (&/V "lux;Meta" (&/T meta (&/V "lux;Int" (Integer/parseInt ?value))))))
- [["Real" ?value]]
- (return (&/|list (&/V "lux;Real" (Float/parseFloat ?value))))
+ [["lux;Meta" [meta ["Real" ?value]]]]
+ (return (&/|list (&/V "lux;Meta" (&/T meta (&/V "lux;Real" (Float/parseFloat ?value))))))
- [["Char" ?value]]
- (return (&/|list (&/V "lux;Char" (.charAt ?value 0))))
+ [["lux;Meta" [meta ["Char" ?value]]]]
+ (return (&/|list (&/V "lux;Meta" (&/T meta (&/V "lux;Char" (.charAt ?value 0))))))
- [["Text" ?value]]
- (return (&/|list (&/V "lux;Text" ?value)))
+ [["lux;Meta" [meta ["Text" ?value]]]]
+ (return (&/|list (&/V "lux;Meta" (&/T meta (&/V "lux;Text" ?value)))))
- [["Symbol" ?ident]]
- (return (&/|list (&/V "lux;Symbol" ?ident)))
+ [["lux;Meta" [meta ["Symbol" ?ident]]]]
+ (return (&/|list (&/V "lux;Meta" (&/T meta (&/V "lux;Symbol" ?ident)))))
- [["Tag" ?ident]]
- (return (&/|list (&/V "lux;Tag" ?ident)))
+ [["lux;Meta" [meta ["Tag" ?ident]]]]
+ (return (&/|list (&/V "lux;Meta" (&/T meta (&/V "lux;Tag" ?ident)))))
- [["Open_Paren" _]]
- (parse-form parse)
+ [["lux;Meta" [meta ["Open_Paren" _]]]]
+ (exec [syntax (parse-form parse)]
+ (return (&/|list (&/V "lux;Meta" (&/T meta syntax)))))
- [["Open_Bracket" _]]
- (parse-tuple parse)
+ [["lux;Meta" [meta ["Open_Bracket" _]]]]
+ (exec [syntax (parse-tuple parse)]
+ (return (&/|list (&/V "lux;Meta" (&/T meta syntax)))))
- [["Open_Brace" _]]
- (parse-record parse)
+ [["lux;Meta" [meta ["Open_Brace" _]]]]
+ (exec [syntax (parse-record parse)]
+ (return (&/|list (&/V "lux;Meta" (&/T meta syntax)))))
[_]
(fail "[Parser Error] Unknown lexer token.")