diff options
Diffstat (limited to 'stdlib/source/lux/ffi.py.lux')
-rw-r--r-- | stdlib/source/lux/ffi.py.lux | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/stdlib/source/lux/ffi.py.lux b/stdlib/source/lux/ffi.py.lux index ed67b3705..865683dc6 100644 --- a/stdlib/source/lux/ffi.py.lux +++ b/stdlib/source/lux/ffi.py.lux @@ -7,12 +7,12 @@ [control ["." io] ["<>" parser - ["<c>" code (#+ Parser)]]] + ["<code>" code (#+ Parser)]]] [data ["." product] ["." maybe] ["." text - ["%" format (#+ format)]] + ["%" format]] [collection ["." list ("#\." functor fold)]]] [type @@ -51,31 +51,31 @@ (def: noneable (Parser Noneable) (let [token (' #?)] - (<| (<>.and (<>.parses? (<c>.this! token))) - (<>.after (<>.not (<c>.this! token))) - <c>.any))) + (<| (<>.and (<>.parses? (<code>.this! token))) + (<>.after (<>.not (<code>.this! token))) + <code>.any))) (type: Constructor (List Noneable)) (def: constructor (Parser Constructor) - (<c>.form (<>.after (<c>.this! (' new)) - (<c>.tuple (<>.some ..noneable))))) + (<code>.form (<>.after (<code>.this! (' new)) + (<code>.tuple (<>.some ..noneable))))) (type: Field [Bit Text Noneable]) (def: static! (Parser Any) - (<c>.this! (' #static))) + (<code>.this! (' #static))) (def: field (Parser Field) - (<c>.form ($_ <>.and - (<>.parses? ..static!) - <c>.local_identifier - ..noneable))) + (<code>.form ($_ <>.and + (<>.parses? ..static!) + <code>.local_identifier + ..noneable))) (type: Common_Method {#name Text @@ -95,11 +95,11 @@ (def: common_method (Parser Common_Method) ($_ <>.and - <c>.local_identifier - (<>.maybe (<>.after (<c>.this! (' #as)) <c>.local_identifier)) - (<c>.tuple (<>.some ..noneable)) - (<>.parses? (<c>.this! (' #io))) - (<>.parses? (<c>.this! (' #try))) + <code>.local_identifier + (<>.maybe (<>.after (<code>.this! (' #as)) <code>.local_identifier)) + (<code>.tuple (<>.some ..noneable)) + (<>.parses? (<code>.this! (' #io))) + (<>.parses? (<code>.this! (' #try))) ..noneable)) (def: static_method @@ -107,8 +107,8 @@ (def: method (Parser Method) - (<c>.form (<>.or ..static_method - ..common_method))) + (<code>.form (<>.or ..static_method + ..common_method))) (type: Member (#Constructor Constructor) @@ -159,16 +159,16 @@ (.error! "None is an invalid value!")))))) (type: Import - (#Class [Text (List Member)]) + (#Class [Text Text (List Member)]) (#Function Static_Method)) (def: import - ($_ <>.or - ($_ <>.and - <c>.local_identifier - (<>.some member)) - (<c>.form ..common_method) - )) + (Parser Import) + (<>.or (<>.and <code>.local_identifier + (<>.default ["" (list)] + (<code>.tuple (<>.and <code>.text + (<>.some member))))) + (<code>.form ..common_method))) (syntax: #export (try expression) {#.doc (doc (case (try (risky_computation input)) @@ -223,10 +223,14 @@ (syntax: #export (import: {import ..import}) (with_gensyms [g!temp] (case import - (#Class [class members]) + (#Class [class format members]) (with_gensyms [g!object] (let [qualify (: (-> Text Code) - (|>> (format class "::") code.local_identifier)) + (function (_ member_name) + (|> format + (text.replace_all "#" class) + (text.replace_all "." member_name) + code.local_identifier))) g!type (code.local_identifier class) real_class (text.replace_all "/" "." class) imported (case (text.split_all_with "/" class) |