Macro fungi_lang::fgi_decls

source ·
macro_rules! fgi_decls {
    { fromast $ast:expr } => { ... };
    { # [ doc = $doc:tt ] $($d:tt)* } => { ... };
    { open $path:path ; $($d:tt)* } => { ... };
    { idxtm $x:ident = ( $($i:tt)+ ) $($d:tt)* } => { ... };
    { nmtm $x:ident = ( $($N:tt)+ ) $($d:tt)* } => { ... };
    { type $t:ident = ( $($a:tt)+ ) $($d:tt)* } => { ... };
    { type $t:ident ; $($d:tt)* } => { ... };
    { val $x:ident : ( $($a:tt)+ ) = ( $($v:tt)+ ) $($d:tt)* } => { ... };
    { val $x:ident = ( $($v:tt)+ ) $($d:tt)* } => { ... };
    { fn $f:ident : ( $($a:tt)+ )   { $($e:tt)+ } $($d:tt)* } => { ... };
    { fn $f:ident : ( $($a:tt)+ ) = { $($e:tt)+ } $($d:tt)* } => { ... };
    { ; $($d:tt)* } => { ... };
    { } => { ... };
    { ^^ $e:expr } => { ... };
    { { $($d:tt)+ } } => { ... };
    { $($any:tt)* } => { ... };
}
Expand description

Parser for declaration lists

d ::=
    fromast ast              (inject ast nodes)
    open x ; d               (all decls in module x are made "local")
    nmtm  x = ( N ) d        (define x as a name term N)
    idxtm x = ( i ) d        (define x as an index term i)
    type  t = ( A ) d        (define a type alias `t` for value type `A`)
    type  t;        d        (declare an undefined, abstract type named `t`)
    val x : ( A ) = ( v ) d  (define a value v, of type A, bound to x)
    val x         = ( v ) d  (define a value v, bound to x; synthesizes type from v)
    fn  f : ( A ) = { e } d  (define a function f, of thunk type A, with recursive body e)
    fn  f : ( A )   { e } d  (alternate syntax: optional equal sign)
    ; d                      (alternate syntax: optional semi colons, anywhere)
    { d }                    (alternate syntax: optional braces, anywhere)
    (end)                    (no decls)