Add parsing for associated function calls
This commit is contained in:
parent
a253c032d8
commit
5eef265652
@ -91,6 +91,7 @@ pub enum ExpressionKind {
|
||||
Accessed(Box<Expression>, String),
|
||||
Binop(BinaryOperator, Box<Expression>, Box<Expression>),
|
||||
FunctionCall(Box<FunctionCallExpression>),
|
||||
AssociatedFunctionCall(Type, Box<FunctionCallExpression>),
|
||||
BlockExpr(Box<Block>),
|
||||
IfExpr(Box<IfExpression>),
|
||||
StructExpression(StructExpression),
|
||||
|
@ -167,6 +167,18 @@ fn specific_int_lit(value: u128, stream: &mut TokenStream) -> Result<Expression,
|
||||
))
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AssociatedFunctionCall(Type, FunctionCallExpression);
|
||||
|
||||
impl Parse for AssociatedFunctionCall {
|
||||
fn parse(mut stream: TokenStream) -> Result<Self, Error> {
|
||||
let ty = stream.parse()?;
|
||||
stream.expect(Token::Colon)?;
|
||||
stream.expect(Token::Colon)?;
|
||||
Ok(AssociatedFunctionCall(ty, stream.parse()?))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PrimaryExpression(Expression);
|
||||
|
||||
@ -200,6 +212,11 @@ impl Parse for PrimaryExpression {
|
||||
Kind::UnaryOperation(unary, Box::new(stream.parse()?)),
|
||||
stream.get_range().unwrap(),
|
||||
)
|
||||
} else if let Ok(assoc_function) = stream.parse::<AssociatedFunctionCall>() {
|
||||
Expression(
|
||||
Kind::AssociatedFunctionCall(assoc_function.0, Box::new(assoc_function.1)),
|
||||
stream.get_range().unwrap(),
|
||||
)
|
||||
} else if let Some(token) = stream.peek() {
|
||||
match &token {
|
||||
Token::Identifier(v) => {
|
||||
|
@ -404,6 +404,7 @@ impl ast::Expression {
|
||||
.map(|e| e.process(module_id))
|
||||
.collect(),
|
||||
),
|
||||
ast::ExpressionKind::AssociatedFunctionCall(_, function_call_expression) => todo!(),
|
||||
};
|
||||
|
||||
mir::Expression(kind, self.1.as_meta(module_id))
|
||||
|
Loading…
Reference in New Issue
Block a user