diff options
author | The Lux Programming Language | 2017-12-02 14:33:40 -0400 |
---|---|---|
committer | GitHub | 2017-12-02 14:33:40 -0400 |
commit | a3687e36a71ebbc3069260e904e47272933a48a1 (patch) | |
tree | 0783fac3f94ea4765dfc91b0fe85b9b1a37cb5d8 /new-luxc/source/luxc/lang/synthesis | |
parent | 0ea9403e482b7f01df9e634ae2533b20ef56a9ab (diff) | |
parent | c72e120e8c2c300411c0cb07ecb3b6bc32e0cb24 (diff) |
Merge pull request #42 from LuxLang/context_sensitive_macro_expansion
Context sensitive macro expansion
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/synthesis/case.lux | 2 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/synthesis/expression.lux | 20 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/synthesis/loop.lux | 18 |
3 files changed, 20 insertions, 20 deletions
diff --git a/new-luxc/source/luxc/lang/synthesis/case.lux b/new-luxc/source/luxc/lang/synthesis/case.lux index ab4820b30..3e57de337 100644 --- a/new-luxc/source/luxc/lang/synthesis/case.lux +++ b/new-luxc/source/luxc/lang/synthesis/case.lux @@ -16,7 +16,7 @@ (def: (path' arity num-locals pattern) (-> ls.Arity Nat la.Pattern [Nat (List ls.Path)]) (case pattern - (^code ("lux case tuple" [(~@ membersP)])) + (^code ("lux case tuple" [(~+ membersP)])) (case membersP #.Nil [num-locals diff --git a/new-luxc/source/luxc/lang/synthesis/expression.lux b/new-luxc/source/luxc/lang/synthesis/expression.lux index d3fbfcb58..b31a146a1 100644 --- a/new-luxc/source/luxc/lang/synthesis/expression.lux +++ b/new-luxc/source/luxc/lang/synthesis/expression.lux @@ -40,7 +40,7 @@ (def: (function$ arity environment body) (-> ls.Arity (List Variable) ls.Synthesis ls.Synthesis) (` ("lux function" (~ (code.nat arity)) - [(~@ (list/map code.int environment))] + [(~+ (list/map code.int environment))] (~ body)))) (def: (variant$ tag last? valueS) @@ -53,11 +53,11 @@ (def: (procedure$ name argsS) (-> Text (List ls.Synthesis) ls.Synthesis) - (` ((~ (code.text name)) (~@ argsS)))) + (` ((~ (code.text name)) (~+ argsS)))) (def: (call$ funcS argsS) (-> ls.Synthesis (List ls.Synthesis) ls.Synthesis) - (` ("lux call" (~ funcS) (~@ argsS)))) + (` ("lux call" (~ funcS) (~+ argsS)))) (def: (synthesize-case arity num-locals synthesize inputA branchesA) (-> ls.Arity Nat (-> Nat la.Analysis ls.Synthesis) @@ -100,14 +100,14 @@ funcS (synthesize funcA) argsS (list/map synthesize argsA)] (case funcS - (^multi (^code ("lux function" (~ [_ (#.Nat _arity)]) [(~@ _env)] (~ _bodyS))) + (^multi (^code ("lux function" (~ [_ (#.Nat _arity)]) [(~+ _env)] (~ _bodyS))) (and (n/= _arity (list.size argsS)) (not (loopS.contains-self-reference? _bodyS))) [(s.run _env (p.some s.int)) (#e.Success _env)]) - (` ("lux loop" (~ (code.nat (n/inc num-locals))) [(~@ argsS)] + (` ("lux loop" (~ (code.nat (n/inc num-locals))) [(~+ argsS)] (~ (loopS.adjust _env num-locals _bodyS)))) - (^code ("lux call" (~ funcS') (~@ argsS'))) + (^code ("lux call" (~ funcS') (~+ argsS'))) (call$ funcS' (list/compose argsS' argsS)) _ @@ -122,7 +122,7 @@ expressionA expressionA] (case expressionA (^code [(~ _left) (~ _right)]) - (` [(~@ (list/map (recur arity resolver false num-locals) + (` [(~+ (list/map (recur arity resolver false num-locals) (la.unfold-tuple expressionA)))]) (^or (^code ("lux sum left" (~ _))) @@ -143,7 +143,7 @@ (^code ("lux case" (~ inputA) (~ [_ (#.Record branchesA)]))) (synthesize-case arity num-locals (recur arity resolver false) inputA branchesA) - (^multi (^code ("lux function" [(~@ scope)] (~ bodyA))) + (^multi (^code ("lux function" [(~+ scope)] (~ bodyA))) [(s.run scope (p.some s.int)) (#e.Success raw-env)]) (let [function-arity (if direct? (n/inc arity) @@ -186,10 +186,10 @@ bodyS (function$ +1 env (prepare-body function-arity +1 bodyS)))) - (^code ("lux apply" (~@ _))) + (^code ("lux apply" (~+ _))) (synthesize-apply (recur arity resolver false num-locals) num-locals expressionA) - (^code ((~ [_ (#.Text name)]) (~@ args))) + (^code ((~ [_ (#.Text name)]) (~+ args))) (procedure$ name (list/map (recur arity resolver false num-locals) args)) _ diff --git a/new-luxc/source/luxc/lang/synthesis/loop.lux b/new-luxc/source/luxc/lang/synthesis/loop.lux index 0510e2377..762032a59 100644 --- a/new-luxc/source/luxc/lang/synthesis/loop.lux +++ b/new-luxc/source/luxc/lang/synthesis/loop.lux @@ -96,7 +96,7 @@ [_ (#.Form (list [_ (#.Int 0)]))] argsS))]) (n/= arity (list.size argsS))) - (` ("lux recur" (~@ argsS))) + (` ("lux recur" (~+ argsS))) (^ [_ (#.Form (list [_ (#.Text "lux let")] register inputS bodyS))]) (` ("lux let" (~ register) (~ inputS) (~ (recur bodyS)))) @@ -119,8 +119,8 @@ (^code ((~ [_ (#.Nat tag)]) (~ last?) (~ valueS))) (` ((~ (code.nat tag)) (~ last?) (~ (recur valueS)))) - (^code [(~@ members)]) - (` [(~@ (list/map recur members))]) + (^code [(~+ members)]) + (` [(~+ (list/map recur members))]) (^code ("lux case" (~ inputS) (~ pathS))) (` ("lux case" (~ (recur inputS)) @@ -142,9 +142,9 @@ _ pathS)))))) - (^code ("lux function" (~ arity) [(~@ environment)] (~ bodyS))) + (^code ("lux function" (~ arity) [(~+ environment)] (~ bodyS))) (` ("lux function" (~ arity) - [(~@ (list/map (function [_var] + [(~+ (list/map (function [_var] (case _var (^ [_ (#.Form (list [_ (#.Int var)]))]) (` ((~ (code.int (resolve-captured var))))) @@ -155,10 +155,10 @@ (~ bodyS))) (^ [_ (#.Form (list& [_ (#.Text "lux call")] funcS argsS))]) - (` ("lux call" (~ (recur funcS)) (~@ (list/map recur argsS)))) + (` ("lux call" (~ (recur funcS)) (~+ (list/map recur argsS)))) (^ [_ (#.Form (list& [_ (#.Text "lux recur")] argsS))]) - (` ("lux recur" (~@ (list/map recur argsS)))) + (` ("lux recur" (~+ (list/map recur argsS)))) (^code ("lux let" (~ [_ (#.Nat register)]) (~ inputS) (~ bodyS))) (` ("lux let" (~ (code.nat (n/+ offset register))) @@ -172,7 +172,7 @@ (^ [_ (#.Form (list [_ (#.Text "lux loop")] [_ (#.Nat loop-offset)] [_ (#.Tuple initsS)] bodyS))]) (` ("lux loop" (~ (code.nat (n/+ offset loop-offset))) - [(~@ (list/map recur initsS))] + [(~+ (list/map recur initsS))] (~ (recur bodyS)))) (^ [_ (#.Form (list [_ (#.Int var)]))]) @@ -181,7 +181,7 @@ (` ((~ (code.int (|> offset nat-to-int (i/+ var))))))) (^ [_ (#.Form (list& [_ (#.Text procedure)] argsS))]) - (` ((~ (code.text procedure)) (~@ (list/map recur argsS)))) + (` ((~ (code.text procedure)) (~+ (list/map recur argsS)))) _ exprS |