Macro fungi_lang::fgi_exp

source ·
macro_rules! fgi_exp {
    { fromast $ast:expr } => { ... };
    { ^       $ast:expr } => { ... };
    { unsafe ($arity:expr) $rustfn:path } => { ... };
    { hostfn ($arity:expr) $($host_e:tt)+ } => { ... };
    { # [ doc = $doc:tt ] $($d:tt)* } => { ... };
    { open $path:path ; $($e:tt)* } => { ... };
    { decls $d:tt ; $($e:tt)+ } => { ... };
    { decls $d:tt $($e:tt)+ } => { ... };
    { $e:tt : $($c:tt)+ } => { ... };
    { $e:tt : $($c:tt)+ } => { ... };
    { {$($e:tt)+} } => { ... };
    { ws $v:tt $($e:tt)+ } => { ... };
    { ret $($v:tt)+ } => { ... };
    { #$x:ident.$($e:tt)+ } => { ... };
    { fix $x:ident.$($e:tt)+ } => { ... };
    { fix ^ $x:ident.$($e:tt)+ } => { ... };
    { unroll match $v:tt $($more:tt)+ } => { ... };
    { unroll $v:tt $x:ident.$($e:tt)+ } => { ... };
    { unpack ($idx:ident,$($idxs:ident),+) $var:ident = $val:tt $($exp:tt)+ } => { ... };
    { unpack ($idx:ident) $var:ident = $val:tt $($exp:tt)+ } => { ... };
    { unpack $idxs:tt $var:ident = {$($e1:tt)+} $($e2:tt)+ } => { ... };
    { {$($e:tt)+} {!$ref:ident} $($more:tt)* } => { ... };
    { {$($e:tt)+} [$($i:tt)+] } => { ... };
    { {$($e:tt)+} [$($i:tt)+] $($more:tt)+ } => { ... };
    { {$($e:tt)+} $v:tt } => { ... };
    { {$($e:tt)+} $v:tt $($more:tt)+ } => { ... };
    { type $t:ident = $a:tt $($e:tt)+ } => { ... };
    { let $x:ident = $e1:tt $($e2:tt)+ } => { ... };
    { let $x:ident : $a:tt = $e1:tt $($e2:tt)+ } => { ... };
    { let rec $x:ident : $a:tt = $e1:tt $($e2:tt)+ } => { ... };
    { thk $v:tt $($e:tt)+ } => { ... };
    { ref 0 $($v:tt)+ } => { ... };
    { ref { $($e1:tt)+ } $($v2:tt)+ } => { ... };
    { ref $v1:tt $($v2:tt)+ } => { ... };
    { force $($v:tt)+ } => { ... };
    { refthunk $($v:tt)+ } => { ... };
    { get $($v:tt)+ } => { ... };
    { let ($($vars:tt)+) = {$($e1:tt)+} $($e2:tt)+ } => { ... };
    { let ($($vars:tt)+) = $v:tt $($e:tt)+ } => { ... };
    { match $v:tt {$x1:ident=>$e1:tt $x2:ident=>$e2:tt} } => { ... };
    { match $v:tt {$x1:ident=>$e1:tt $x2:ident=>$e2:tt $($more:tt)+} } => { ... };
    { memo{$($e1:tt)+}{$($e2:tt)+} } => { ... };
    { memo($($v:tt)+){$($e:tt)+} } => { ... };
    { match $v:tt {$x1:ident=>$e1:tt $x2:ident=>$e2:tt} } => { ... };
    { if ( $($v:tt)+ ) { $($e1:tt)+ } else { $($e2:tt)+ } } => { ... };
    { if { $($e:tt)+ } { $($e1:tt)+ } else { $($e2:tt)+ } } => { ... };
    { [$($v1:tt)+] $v2:tt } => { ... };
    { [$($v1:tt)+] $v2:tt $($more:tt)+ } => { ... };
    { $v1:tt, $v2:tt } => { ... };
    { $v1:tt, $($more:tt)+ } => { ... };
    { $v1:tt < $v2:tt } => { ... };
    { $v1:tt == $v2:tt } => { ... };
    { $v1:tt <= $v2:tt } => { ... };
    { $v1:tt + $v2:tt } => { ... };
    { unimplemented } => { ... };
    { label [$($n:tt)+]($($s:tt)+) $($e:tt)+ } => { ... };
    { label ($($s:tt)+)[$($n:tt)+] $($e:tt)+ } => { ... };
    { label ($($s:tt)+) $($e:tt)+ } => { ... };
    { label [$($n:tt)+] $($e:tt)+ } => { ... };
    { $($any:tt)* } => { ... };
}
Expand description

Parser for expressions

e::=
    fromast ast                     (inject ast nodes)
    unsafe (arity) rustfn           (inject an evaluation function written in Rust) <-- DEPRECATED
    hostfn (arity) host_e           (inject an evaluation function written in Rust)
    open x ; e                      (all decls in module x made local to e)
    decls { d } ; e                 (all decls in d are made local to e)
    decls { d }   e                 (optional semicolon)
    e : C                           (type annotation, no effect)
    e :> E                          (type annotation, with effect)
    {e}                             (parens)
    ws v e                          (write scope)
    ret v                           (lifted value)
    #x.e                            (lambda)
    fix x.e                         (recursive lambda)
    unroll v x.e                    (unroll recursively-typed value v as x in e)
    unroll match v { ... }          (unroll recursively-typed value and elim sum type)
    unpack (a1,...) x = (v) e       (unpack existentials from type, bind x to v)
    {e} [i1] ...                    (extened index application)
    {e} {!ref} ...                  (application get-sugar)
    {e} v1 ...                      (extened application)
    type t = (A) e                  (user type shorthand)
    let x = {e1} e2                 (let-binding)
    let x : A = {e1} e2             (annotated let-binding)
    let rec x : A = {e1} e2         (annotated let-rec binding)
    thk v e                         (create thunk)
    ref 0 v                         (create unnamed ref holding the given value)
    ref { e1 } v2                   (create ref with name from expression)
    ref v1 v2                       (create ref)
    force v                         (force thunk)
    refthunk v                      (coerce a value-producing thunk to a ref)
    get v                           (read from ref)
    let (x1,...) = {e1} e2          (let-split sugar)
    let (x1,...) = v e              (extended split)
    memo{e1}{e2}                    (memoize computation, sugar - compute name)
    memo(v){e}                      (memoize computation by name, return ref)
    match v {x1 => e1 ... }         (extended case analysis)
    if { e } { e1 } else { e2 }     (if-then-else; bool elim)
    if ( v ) { e1 } else { e2 }     (if-then-else; bool elim)
    [v1] v2 ...                     (curried name function application)
    v1, v2, ...                     (extended binary name construction)
    v1 < v2                         (less-than)
    unimplemented                   (marker for type checker)
    label (some text) e             (debug string label)
    label [n] e                     (debug name label)
    label (some text)[n] e          (debug string and name label)
    label [n](some text) e          (debug string and name label)