From 772ff99830d133b2e36ad1b09c66223ef1085c71 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 14 Nov 2017 23:57:15 -0400 Subject: - Modified the syntax for module definitions. - Fixed some bugs. --- new-luxc/source/luxc/lang/translation.lux | 42 ++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'new-luxc/source/luxc/lang/translation.lux') diff --git a/new-luxc/source/luxc/lang/translation.lux b/new-luxc/source/luxc/lang/translation.lux index 62b56783c..5b11a8e39 100644 --- a/new-luxc/source/luxc/lang/translation.lux +++ b/new-luxc/source/luxc/lang/translation.lux @@ -14,7 +14,8 @@ (world [file #+ File])) (luxc ["&" base] [";L" host] - (host [";H" macro]) + (host [";H" macro] + ["$" jvm]) ["&;" io] ["&;" module] ["&;" eval] @@ -73,20 +74,26 @@ ([#;UnivQ] [#;ExQ]) )) +(def: (process-annotations annsC) + (-> Code (Meta [$;Inst Code])) + (do meta;Monad + [[_ annsA] (&;with-scope + (&;with-expected-type Code + (analyse annsC))) + annsI (expressionT;translate (expressionS;synthesize annsA)) + annsV (evalT;eval annsI)] + (wrap [annsI (:! Code annsV)]))) + (def: (translate code) (-> Code (Meta Unit)) (case code - (^code ("lux def" (~ [_ (#;Symbol ["" def-name])]) (~ valueC) (~ metaC))) + (^code ("lux def" (~ [_ (#;Symbol ["" def-name])]) (~ valueC) (~ annsC))) (hostL;with-context def-name (&;with-fresh-type-env (do meta;Monad - [[_ metaA] (&;with-scope - (&;with-expected-type Code - (analyse metaC))) - metaI (expressionT;translate (expressionS;synthesize metaA)) - metaV (evalT;eval metaI) + [[annsI annsV] (process-annotations annsC) [_ valueT valueA] (&;with-scope - (if (meta;type? (:! Code metaV)) + (if (meta;type? (:! Code annsV)) (do @ [valueA (&;with-expected-type Type (analyse valueC))] @@ -97,7 +104,7 @@ (clean valueT)) valueI (expressionT;translate (expressionS;synthesize valueA)) _ (&;with-scope - (statementT;translate-def def-name valueT valueI metaI (:! Code metaV)))] + (statementT;translate-def def-name valueT valueI annsI annsV))] (wrap [])))) (^code ("lux program" (~ [_ (#;Symbol ["" program-args])]) (~ programC))) @@ -108,6 +115,11 @@ programI (expressionT;translate (expressionS;synthesize programA))] (statementT;translate-program program-args programI)) + (^code ("lux module" (~ annsC))) + (do meta;Monad + [[annsI annsV] (process-annotations annsC)] + (&;fail (%code annsV))) + (^code ((~ [_ (#;Symbol macro-name)]) (~@ args))) (do meta;Monad [macro-name (meta;normalize macro-name) @@ -130,9 +142,15 @@ (def: (exhaust action) (All [a] (-> (Meta a) (Meta Unit))) - (do meta;Monad - [result action] - (exhaust action))) + (function [compiler] + (case (action compiler) + (#e;Success [compiler' _]) + ((exhaust action) compiler') + + (#e;Error error) + (if (ex;match? &syntax;End-Of-File error) + (#e;Success [compiler []]) + (#e;Error error))))) (def: prelude Text "lux") -- cgit v1.2.3