Skip to content

Commit

Permalink
Fixed opt_function_invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
if-loop69420 committed Aug 23, 2024
1 parent eaaa4ef commit fa7d498
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/grammar/function_invocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ use source_gen::T;

/// Looks ahead and parses a function invocation if applicable
pub(crate) fn opt_function_invocation(p: &mut Parser) -> bool {
if p.current().is_ident()
&& matches!(
p.lookahead(3).as_slice(),
&[T!["("], ..]
| &[T![.], T![quoted_ident], T!["("]]
| &[T![.], T![unquoted_ident], T!["("]]
)
{
if p.current().is_ident() && is_start_of_function(p.lookahead(3)) {
parse_function_invocation(p);
return true;
}
false
}

fn is_start_of_function(lookahead: Vec<TokenKind>) -> bool {
if lookahead.len() < 3 {
false
} else if lookahead[0] == T!["("] {
true
} else if lookahead[0] == T![.] && lookahead[1].is_ident() && lookahead[2] == T!["("] {
true
} else {
false
}
}

pub(crate) fn parse_function_invocation(p: &mut Parser) {
p.start(SyntaxKind::FunctionInvocation);
parse_ident(p, 1..2);
Expand Down

0 comments on commit fa7d498

Please sign in to comment.