Add parser support

This commit is contained in:
Pranav Gaddamadugu 2023-08-03 00:44:26 -04:00
parent e96475b3e2
commit 1049822979
4 changed files with 17 additions and 1 deletions

View File

@ -343,6 +343,19 @@ impl ParserContext<'_> {
right: Box::new(args.swap_remove(0)),
id: self.node_builder.next_id(),
}))
} else if let (2, Some(CoreFunction::SignatureVerify)) =
(args.len(), CoreFunction::from_symbols(sym::signature, method.name))
{
Ok(Expression::Access(AccessExpression::AssociatedFunction(AssociatedFunction {
ty: Type::Identifier(Identifier::new(sym::signature)),
name: method,
arguments: {
let mut arguments = vec![receiver];
arguments.extend(args);
arguments
},
span,
})))
} else {
// Attempt to parse the method call as a mapping operation.
match (args.len(), CoreFunction::from_symbols(sym::Mapping, method.name)) {

View File

@ -412,6 +412,7 @@ impl Token {
"record" => Token::Record,
"return" => Token::Return,
"scalar" => Token::Scalar,
"signature" => Token::Signature,
"self" => Token::SelfLower,
"string" => Token::String,
"struct" => Token::Struct,

View File

@ -114,6 +114,7 @@ mod tests {
return
scalar
self
signature
string
struct
test
@ -169,7 +170,7 @@ mod tests {
assert_eq!(
output,
r#""test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" test_ident 12345 address as assert assert_eq assert_neq async bool const else false field finalize for function group i128 i64 i32 i16 i8 if in inline input let mut private program public return scalar self string struct test then transition true u128 u64 u32 u16 u8 console ! != && ( ) * ** + , - -> => _ . .. / : ; < <= = == > >= [ ] { { } } || ? @ // test
r#""test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" test_ident 12345 address as assert assert_eq assert_neq async bool const else false field finalize for function group i128 i64 i32 i16 i8 if in inline input let mut private program public return scalar self signature string struct test then transition true u128 u64 u32 u16 u8 console ! != && ( ) * ** + , - -> => _ . .. / : ; < <= = == > >= [ ] { { } } || ? @ // test
/* test */ // "#
);
});

View File

@ -179,6 +179,7 @@ pub const KEYWORD_TOKENS: &[Token] = &[
Token::Record,
Token::Return,
Token::SelfLower,
Token::Signature,
Token::Scalar,
Token::String,
Token::Struct,