mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 12:35:08 +00:00
JSSpecCompiler: Parse "Perform <expression>." steps
This commit is contained in:
parent
d1fc84c638
commit
ddf26a768c
2 changed files with 21 additions and 0 deletions
|
@ -463,6 +463,18 @@ TextParseErrorOr<Tree> TextParser::parse_assignment()
|
|||
return make_ref_counted<BinaryOperation>(op, lvalue, rvalue);
|
||||
}
|
||||
|
||||
// perform <expr>
|
||||
TextParseErrorOr<Tree> TextParser::parse_perform()
|
||||
{
|
||||
auto rollback = rollback_point();
|
||||
|
||||
TRY(consume_word("perform"sv));
|
||||
auto value = TRY(parse_expression());
|
||||
|
||||
rollback.disarm();
|
||||
return value;
|
||||
}
|
||||
|
||||
// <simple_step>
|
||||
TextParseErrorOr<Tree> TextParser::parse_simple_step_or_inline_if_branch()
|
||||
{
|
||||
|
@ -493,6 +505,14 @@ TextParseErrorOr<Tree> TextParser::parse_simple_step_or_inline_if_branch()
|
|||
return result.release_value();
|
||||
}
|
||||
|
||||
// Perform <expr>.$
|
||||
if (auto result = parse_perform(); !result.is_error()) {
|
||||
TRY(consume_token_with_type(TokenType::Dot));
|
||||
TRY(expect_eof());
|
||||
rollback.disarm();
|
||||
return result.release_value();
|
||||
}
|
||||
|
||||
return TextParseError {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue