From 195ffc9a9de68259a5fb54cdee065efeb703c388 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 16 Apr 2019 20:54:53 -0400 Subject: The "invalid-syntax" can now be parameterized with the formatter for the inputs. --- stdlib/source/lux/tool/compiler/phase/extension.lux | 20 ++++++++------------ .../compiler/phase/extension/analysis/common.lux | 2 +- .../lux/tool/compiler/phase/extension/statement.lux | 12 ++++++------ 3 files changed, 15 insertions(+), 19 deletions(-) (limited to 'stdlib/source') diff --git a/stdlib/source/lux/tool/compiler/phase/extension.lux b/stdlib/source/lux/tool/compiler/phase/extension.lux index 3b247eda9..d9cf0d701 100644 --- a/stdlib/source/lux/tool/compiler/phase/extension.lux +++ b/stdlib/source/lux/tool/compiler/phase/extension.lux @@ -42,11 +42,17 @@ (exception.report ["Extension" (%t name)])) -(exception: #export (invalid-syntax {name Name} {inputs (List Code)}) +(exception: #export (incorrect-arity {name Name} {arity Nat} {args Nat}) + (exception.report + ["Extension" (%t name)] + ["Expected" (%n arity)] + ["Actual" (%n args)])) + +(exception: #export [a] (invalid-syntax {name Name} {%format (Format a)} {inputs (List a)}) (exception.report ["Extension" (%t name)] ["Inputs" (|> inputs - (list@map %code) + (list@map %format) (text.join-with text.new-line))])) (exception: #export [s i o] (unknown {name Name} {bundle (Bundle s i o)}) @@ -58,16 +64,6 @@ (list@map %t) (text.join-with text.new-line))])) -(exception: #export (incorrect-arity {name Name} {arity Nat} {args Nat}) - (exception.report - ["Extension" (%t name)] - ["Expected" (%n arity)] - ["Actual" (%n args)])) - -(exception: #export (incorrect-syntax {name Name}) - (exception.report - ["Extension" (%t name)])) - (def: #export (install name handler) (All [s i o] (-> Text (Handler s i o) (Operation s i o Any))) diff --git a/stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux b/stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux index 4f11e47fb..20061db55 100644 --- a/stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux +++ b/stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux @@ -92,7 +92,7 @@ (analyse exprC)) _ - (/////analysis.throw ///.invalid-syntax [extension-name argsC+])))) + (/////analysis.throw ///.invalid-syntax [extension-name %code argsC+])))) (template [ ] [(def: ( eval) diff --git a/stdlib/source/lux/tool/compiler/phase/extension/statement.lux b/stdlib/source/lux/tool/compiler/phase/extension/statement.lux index 030bc5a2b..10a3b4985 100644 --- a/stdlib/source/lux/tool/compiler/phase/extension/statement.lux +++ b/stdlib/source/lux/tool/compiler/phase/extension/statement.lux @@ -146,7 +146,7 @@ (wrap ////statement.no-requirements)) _ - (///.throw //.invalid-syntax [extension-name inputsC+])))) + (///.throw //.invalid-syntax [extension-name %code inputsC+])))) (def: imports (Syntax (List Import)) @@ -170,7 +170,7 @@ (wrap imports) (#error.Failure error) - (///.throw //.invalid-syntax [extension-name (list annotationsV)])) + (///.throw //.invalid-syntax [extension-name %code (list annotationsV)])) _ (////statement.lift-analysis (do @ [_ (monad.map @ (function (_ [module alias]) @@ -185,7 +185,7 @@ #////statement.referrals (list)})) _ - (///.throw //.invalid-syntax [extension-name inputsC+])))) + (///.throw //.invalid-syntax [extension-name %code inputsC+])))) ## TODO: Reify aliasing as a feature of the compiler, instead of ## manifesting it implicitly through definition annotations. @@ -215,7 +215,7 @@ (wrap ////statement.no-requirements)) _ - (///.throw //.invalid-syntax [extension-name inputsC+])))) + (///.throw //.invalid-syntax [extension-name %code inputsC+])))) (template [ ] [(def: @@ -240,7 +240,7 @@ (wrap ////statement.no-requirements)) _ - (///.throw //.invalid-syntax [extension-name inputsC+]))))] + (///.throw //.invalid-syntax [extension-name %code inputsC+]))))] [def::analysis ////analysis.Handler ////statement.lift-analysis] [def::synthesis ////synthesis.Handler ////statement.lift-synthesis] @@ -293,7 +293,7 @@ (wrap ////statement.no-requirements)) _ - (///.throw //.invalid-syntax [extension-name inputsC+])))) + (///.throw //.invalid-syntax [extension-name %code inputsC+])))) (def: (bundle::def program) (All [anchor expression statement] -- cgit v1.2.3