Skip to content

Commit ddf26a7

Browse files
DanShadersADKaster
authored andcommitted
JSSpecCompiler: Parse "Perform <expression>." steps
1 parent d1fc84c commit ddf26a7

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,18 @@ TextParseErrorOr<Tree> TextParser::parse_assignment()
463463
return make_ref_counted<BinaryOperation>(op, lvalue, rvalue);
464464
}
465465

466+
// perform <expr>
467+
TextParseErrorOr<Tree> TextParser::parse_perform()
468+
{
469+
auto rollback = rollback_point();
470+
471+
TRY(consume_word("perform"sv));
472+
auto value = TRY(parse_expression());
473+
474+
rollback.disarm();
475+
return value;
476+
}
477+
466478
// <simple_step>
467479
TextParseErrorOr<Tree> TextParser::parse_simple_step_or_inline_if_branch()
468480
{
@@ -493,6 +505,14 @@ TextParseErrorOr<Tree> TextParser::parse_simple_step_or_inline_if_branch()
493505
return result.release_value();
494506
}
495507

508+
// Perform <expr>.$
509+
if (auto result = parse_perform(); !result.is_error()) {
510+
TRY(consume_token_with_type(TokenType::Dot));
511+
TRY(expect_eof());
512+
rollback.disarm();
513+
return result.release_value();
514+
}
515+
496516
return TextParseError {};
497517
}
498518

Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class TextParser {
8484
TextParseErrorOr<Tree> parse_return_statement();
8585
TextParseErrorOr<Tree> parse_assert();
8686
TextParseErrorOr<Tree> parse_assignment();
87+
TextParseErrorOr<Tree> parse_perform();
8788
TextParseErrorOr<Tree> parse_simple_step_or_inline_if_branch();
8889
TextParseErrorOr<IfConditionParseResult> parse_if_beginning();
8990
TextParseErrorOr<Tree> parse_inline_if_else();

0 commit comments

Comments
 (0)