lux/macro/syntax/common

Commons syntax parsers and generators.

The goal is to be able to reuse common syntax in macro definitions across libraries.

Types

Decl

(type: Decl
  {#decl-name lux;Text
   #decl-args (lux;List lux;Text)})

Def-Syntax

(type: Def-Syntax
  {#def-name lux;Text
   #def-type (lux;Maybe lux;AST)
   #def-value lux;AST
   #def-anns (lux;List [lux;Ident lux;AST])
   #def-args (lux;List lux;Text)})

Export-Level

(type: Export-Level
  (#Exported lux;Unit)
  (#Hidden lux;Unit))

Values

decl

## A parser for declaration syntax.
## Such as:
quux

(foo bar baz)

(lux/macro/syntax;Syntax Decl)

(def compiler)

A parser that first macro-expands and then analyses the input AST, to ensure it's a definition.

(-> lux;Compiler (lux/macro/syntax;Syntax Def-Syntax))

def-anns

Parser for the common annotations syntax used by def: statements.

(lux/macro/syntax;Syntax (lux;List [lux;Ident lux;AST]))

export-level

## A parser for export levels.
## Such as:
#export

#hidden

(lux/macro/syntax;Syntax (lux;Maybe Export-Level))

(gen-export-level ?el)

(-> (lux;Maybe Export-Level) (lux;List lux;AST))

type-params

Parser for the common type var/param used by many macros.

(lux/macro/syntax;Syntax (lux;List lux;Text))

typed-arg

Parser for the common typed-argument syntax used by many macros.

(lux/macro/syntax;Syntax [lux;Text lux;AST])

(typed-def compiler)

A parser for definitions that ensures the input syntax is typed.

(-> lux;Compiler (lux/macro/syntax;Syntax Def-Syntax))