Struct tagua_parser::ast::Function
[−]
[src]
pub struct Function<'a> { pub name: &'a [u8], pub inputs: Arity<'a>, pub output: Ty<'a>, pub body: Vec<Statement<'a>>, }
A function declaration.
Examples
use tagua_parser::Result; use tagua_parser::ast::{ Arity, Function, Name, Parameter, Statement, Ty, Variable }; use tagua_parser::rules::statements::function::function; assert_eq!( function(b"function f(I $x): O { return; }"), Result::Done( &b""[..], Statement::Function( Function { name : &b"f"[..], inputs: Arity::Finite(vec![ Parameter { ty : Ty::Copy(Some(Name::Unqualified(&b"I"[..]))), name : Variable(&b"x"[..]), value: None } ]), output: Ty::Copy(Some(Name::Unqualified(&b"O"[..]))), body : vec![Statement::Return] } ) ) );Run
Fields
name: &'a [u8]
Name of the function.
inputs: Arity<'a>
Inputs, aka parameters, of the function.
output: Ty<'a>
Output type of the function.
body: Vec<Statement<'a>>
Body of the function, i.e. a set of statements.