(.module: [library [lux #* [abstract ["." monad]] [control ["<>" parser ("#\." monad) ["" code (#+ Parser)] ["" analysis] ["" synthesis]]] [data ["." product] [collection ["." list ("#\." functor)]]] [macro (#+ with_gensyms) ["." code] [syntax (#+ syntax:)]] [tool [compiler ["." phase]]]]]) (type: Input {#variable Text #parser Code}) (def: (simple default) (-> Code (Parser Input)) ($_ <>.and .local_identifier (<>\in default))) (def: complex (Parser Input) (.record ($_ <>.and .local_identifier .any))) (def: (input default) (-> Code (Parser Input)) (<>.either (..simple default) ..complex)) (type: Declaration {#name Code #label Text #phase Text #archive Text #inputs (List Input)}) (def: (declaration default) (-> Code (Parser Declaration)) (.form ($_ <>.and .any .local_identifier .local_identifier .local_identifier (<>.some (..input default))))) (template [ ] [(syntax: .public ( {[name extension phase archive inputs] (..declaration (` ))} body) (let [g!parser (case (list\map product.right inputs) #.End (` ) parsers (` (.$_ (~+ parsers)))) g!name (code.local_identifier extension) g!phase (code.local_identifier phase) g!archive (code.local_identifier archive)] (with_gensyms [g!handler g!inputs g!error] (in (list (` ( (~ name) (.function ((~ g!handler) (~ g!name) (~ g!phase) (~ g!archive) (~ g!inputs)) (.case ((~! ) (~ g!parser) (~ g!inputs)) (#.Right [(~+ (list\map (|>> product.left code.local_identifier) inputs))]) (~ body) (#.Left (~ g!error)) ((~! phase.failure) (~ g!error))) ))))))))] [.any .end! .and .run "lux def analysis" analysis:] [.any .end! .and .run "lux def synthesis" synthesis:] [.any .end! .and .run "lux def generation" generation:] [.any .end! .and .run "lux def directive" directive:] )