1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +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:
Dan Klishch 2024-01-18 21:17:26 -05:00 committed by Andrew Kaster
parent 483e195e48
commit 14ee25b8ba
9 changed files with 255 additions and 58 deletions

View file

@ -7,26 +7,31 @@
#pragma once
#include "AST/AST.h"
#include "Function.h"
#include "Parser/ParseError.h"
#include "Parser/Token.h"
namespace JSSpecCompiler {
class TextParser {
public:
struct DefinitionParseResult {
StringView section_number;
StringView function_name;
Vector<StringView> arguments;
struct ClauseHeader {
struct FunctionDefinition {
StringView name;
Vector<FunctionArgument> arguments;
};
StringView section_number;
Variant<AK::Empty, FunctionDefinition> header;
};
class TextParser {
public:
TextParser(Vector<Token>& tokens_, XML::Node const* node_)
: m_tokens(tokens_)
, m_node(node_)
{
}
ParseErrorOr<DefinitionParseResult> parse_definition();
ParseErrorOr<ClauseHeader> parse_clause_header();
ParseErrorOr<Tree> parse_step_without_substeps();
ParseErrorOr<Tree> parse_step_with_substeps(Tree substeps);