use luau_lexer::prelude::Token;
use luau_parser_derive::{Print, Range};
use crate::types::{
Attribute, Block, BracketedList, Expression, GenericDeclaration, Parameter, Pointer, PrefixExp, Table, TypeValue
};
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Range, Print)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum FunctionCallInvoked {
Function(Pointer<PrefixExp>),
TableMethod {
table: Pointer<PrefixExp>,
colon: Pointer<Token>,
method: Pointer<Token>,
},
}
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Range, Print)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct FunctionCall {
pub invoked: FunctionCallInvoked,
pub arguments: FunctionArguments,
}
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Range, Print)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum FunctionArguments {
String(Token),
Table(Table),
List(BracketedList<Pointer<FunctionArgument>>),
}
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Range, Print)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum FunctionArgument {
Expression(Pointer<Expression>),
VariadicValues(Token),
}
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Range, Print)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Closure {
pub attributes: Vec<Attribute>,
pub function_keyword: Token,
pub generics: Option<Pointer<GenericDeclaration>>,
pub parameters: BracketedList<Parameter>,
pub colon: Option<Pointer<Token>>,
pub return_type: Option<Pointer<TypeValue>>,
pub body: Block,
pub end_keyword: Token,
}