mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-22 02:52:52 +00:00
JSSpecCompiler: Make -xspec capable of parsing the whole specification
... in theory. In practice, we fail to parse all of the functions.
This commit is contained in:
parent
483e195e48
commit
14ee25b8ba
Notes:
sideshowbarker
2024-07-17 03:45:48 +09:00
Author: https://github.com/DanShaders
Commit: 14ee25b8ba
Pull-request: https://github.com/SerenityOS/serenity/pull/22794
Reviewed-by: https://github.com/ADKaster ✅
9 changed files with 255 additions and 58 deletions
|
@ -479,24 +479,28 @@ ParseErrorOr<Tree> TextParser::parse_step_with_substeps(Tree substeps)
|
|||
return ParseError::create("Unable to parse step with substeps"sv, m_node);
|
||||
}
|
||||
|
||||
ParseErrorOr<TextParser::DefinitionParseResult> TextParser::parse_definition()
|
||||
ParseErrorOr<ClauseHeader> TextParser::parse_clause_header()
|
||||
{
|
||||
DefinitionParseResult result;
|
||||
ClauseHeader result;
|
||||
|
||||
auto section_number_token = TRY(consume_token_with_type(TokenType::SectionNumber));
|
||||
result.section_number = section_number_token->data;
|
||||
|
||||
result.function_name = TRY(consume_token())->data;
|
||||
ClauseHeader::FunctionDefinition function_definition;
|
||||
|
||||
function_definition.name = TRY(consume_token())->data;
|
||||
|
||||
TRY(consume_token_with_type(TokenType::ParenOpen));
|
||||
while (true) {
|
||||
result.arguments.append({ TRY(consume_token_with_type(TokenType::Identifier))->data });
|
||||
function_definition.arguments.append({ TRY(consume_token_with_type(TokenType::Identifier))->data });
|
||||
auto next_token = TRY(consume_token_with_one_of_types({ TokenType::ParenClose, TokenType::Comma }));
|
||||
if (next_token->type == TokenType::ParenClose)
|
||||
break;
|
||||
}
|
||||
TRY(expect_eof());
|
||||
|
||||
result.header = function_definition;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue