Struct tagua_parser::ast::AnonymousFunction
[−]
[src]
pub struct AnonymousFunction<'a> {
pub declaration_scope: Scope,
pub inputs: Arity<'a>,
pub output: Ty<'a>,
pub enclosing_scope: Option<Vec<Expression<'a>>>,
pub body: Vec<Statement<'a>>,
}An anonymous function.
An anonymous function is defined like, and behaves like, a named
function Function except that the former has no name, and an
enclosed scope.
Examples
use tagua_parser::Result; use tagua_parser::ast::{ AnonymousFunction, Arity, Expression, Name, Parameter, Scope, Statement, Ty, Variable }; use tagua_parser::rules::expressions::primaries::anonymous_function; assert_eq!( anonymous_function(b"static function &(I ...$x) use (&$y, $z): O { return; }"), Result::Done( &b""[..], Expression::AnonymousFunction( AnonymousFunction { declaration_scope: Scope::Static, inputs : Arity::Infinite(vec![ Parameter { ty : Ty::Copy(Some(Name::Unqualified(&b"I"[..]))), name : Variable(&b"x"[..]), value: None } ]), output : Ty::Reference(Some(Name::Unqualified(&b"O"[..]))), enclosing_scope: Some(vec![ Expression::Reference( Box::new( Expression::Variable(Variable(&b"y"[..])) ) ), Expression::Variable(Variable(&b"z"[..])) ]), body: vec![Statement::Return] } ) ) );Run
Fields
declaration_scope: Scope
Declaration scope of the anonymous function.
inputs: Arity<'a>
Inputs, aka parameters, of the anonymous function.
output: Ty<'a>
Output type of the anonymous function.
enclosing_scope: Option<Vec<Expression<'a>>>
Enclosed scope (list of variables to be accessible from the body) of the anonymous function.
body: Vec<Statement<'a>>
Body of the anonymous function, i.e. a set of statements.
Trait Implementations
impl<'a> Debug for AnonymousFunction<'a>[src]
impl<'a> PartialEq for AnonymousFunction<'a>[src]
fn eq(&self, __arg_0: &AnonymousFunction<'a>) -> bool
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &AnonymousFunction<'a>) -> bool
This method tests for !=.