diff options
Diffstat (limited to 'stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux')
-rw-r--r-- | stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux index 7d7ce2fbf..e619e76f8 100644 --- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux +++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux @@ -3,24 +3,49 @@ [abstract ["." monad (#+ do)]] [control - ["." function]] + ["." function] + ["." try] + ["<>" parser + ["<s>" synthesis (#+ Parser)]]] [data ["." product] + ["." text + ["%" format (#+ format)]] [collection - ["." dictionary]]] + ["." dictionary] + ["." list ("#\." functor fold)]]] [math [number ["f" frac]]] [target - ["_" lua (#+ Expression Literal)]]] - [//// + ["_" lua (#+ Expression)]]] + ["." //// #_ ["/" bundle] - [// + ["/#" // #_ + ["." extension] [generation [extension (#+ Nullary Unary Binary Trinary nullary unary binary trinary)] ["//" lua #_ - ["#." runtime (#+ Operation Phase Handler Bundle)]]]]]) + ["#." runtime (#+ Operation Phase Handler Bundle Generator)]]] + [// + [synthesis (#+ %synthesis)] + ["." generation] + [/// + ["#" phase]]]]]) + +(def: #export (custom [parser handler]) + (All [s] + (-> [(Parser s) + (-> Text (Generator s))] + Handler)) + (function (_ extension_name phase archive input) + (case (<s>.run parser input) + (#try.Success input') + (handler extension_name phase archive input') + + (#try.Failure error) + (/////.throw extension.invalid_syntax [extension_name %synthesis input])))) (template: (!unary function) (|>> list _.apply/* (|> (_.var function)))) @@ -70,9 +95,9 @@ (/.install "encode" (unary (!unary "tostring"))) (/.install "decode" (unary ..f64//decode))))) -(def: (text//char [subjectO paramO]) +(def: (text//char [paramO subjectO]) (Binary Expression) - (//runtime.text//char subjectO paramO)) + (//runtime.text//char (_.+ (_.int +1) paramO) subjectO)) (def: (text//clip [paramO extraO subjectO]) (Trinary Expression) @@ -80,7 +105,7 @@ (def: (text//index [startO partO textO]) (Trinary Expression) - (//runtime.text//index textO partO startO)) + (//runtime.text//index textO partO (_.+ (_.int +1) startO))) (def: text_procs Bundle @@ -89,10 +114,10 @@ (/.install "=" (binary (product.uncurry _.=))) (/.install "<" (binary (product.uncurry _.<))) (/.install "concat" (binary (product.uncurry (function.flip _.concat)))) - (/.install "index" (trinary text//index)) + (/.install "index" (trinary ..text//index)) (/.install "size" (unary (|>> list _.apply/* (|> (_.var "string.len"))))) - (/.install "char" (binary (product.uncurry //runtime.text//char))) - (/.install "clip" (trinary text//clip)) + (/.install "char" (binary ..text//char)) + (/.install "clip" (trinary ..text//clip)) ))) (def: (io//log! messageO) |