mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
JSSpecCompiler: Ignore notes in algorithm steps
This commit is contained in:
parent
ba61b61d67
commit
f7c952f842
6 changed files with 30 additions and 8 deletions
|
@ -97,7 +97,7 @@ bool AlgorithmStep::parse()
|
|||
{
|
||||
TextParser parser(m_ctx, m_tokens, m_node);
|
||||
|
||||
TextParseErrorOr<Tree> parse_result = TextParseError {};
|
||||
TextParseErrorOr<NullableTree> parse_result = TextParseError {};
|
||||
if (m_substeps)
|
||||
parse_result = parser.parse_step_with_substeps(RefPtr(m_substeps).release_nonnull());
|
||||
else
|
||||
|
@ -133,10 +133,12 @@ Optional<AlgorithmStepList> AlgorithmStepList::create(SpecificationParsingContex
|
|||
update_logical_scope_for_step(ctx, parent_scope, step_number);
|
||||
return AlgorithmStep::create(ctx, child);
|
||||
});
|
||||
if (!step_creation_result.has_value())
|
||||
if (!step_creation_result.has_value()) {
|
||||
all_steps_parsed = false;
|
||||
else
|
||||
step_expressions.append(step_creation_result.release_value().tree());
|
||||
} else {
|
||||
if (auto expression = step_creation_result.release_value().tree())
|
||||
step_expressions.append(expression.release_nonnull());
|
||||
}
|
||||
++step_number;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class AlgorithmStep {
|
|||
public:
|
||||
static Optional<AlgorithmStep> create(SpecificationParsingContext& ctx, XML::Node const* node);
|
||||
|
||||
Tree tree() const { return m_expression; }
|
||||
NullableTree tree() const { return m_expression; }
|
||||
|
||||
private:
|
||||
AlgorithmStep(SpecificationParsingContext& ctx)
|
||||
|
@ -75,7 +75,7 @@ private:
|
|||
SpecificationParsingContext& m_ctx;
|
||||
Vector<Token> m_tokens;
|
||||
XML::Node const* m_node;
|
||||
Tree m_expression = error_tree;
|
||||
NullableTree m_expression = error_tree;
|
||||
NullableTree m_substeps;
|
||||
};
|
||||
|
||||
|
|
|
@ -598,10 +598,16 @@ TextParseErrorOr<Tree> TextParser::parse_else(Tree else_branch)
|
|||
}
|
||||
|
||||
// <simple_step> | <inline_if>
|
||||
TextParseErrorOr<Tree> TextParser::parse_step_without_substeps()
|
||||
TextParseErrorOr<NullableTree> TextParser::parse_step_without_substeps()
|
||||
{
|
||||
auto rollback = rollback_point();
|
||||
|
||||
// NOTE: ...
|
||||
if (auto result = consume_word("NOTE:"sv); !result.is_error()) {
|
||||
rollback.disarm();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// <simple_step>
|
||||
if (auto result = parse_simple_step_or_inline_if_branch(); !result.is_error()) {
|
||||
rollback.disarm();
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
}
|
||||
|
||||
TextParseErrorOr<ClauseHeader> parse_clause_header(ClauseHasAoidAttribute clause_has_aoid_attribute);
|
||||
TextParseErrorOr<Tree> parse_step_without_substeps();
|
||||
TextParseErrorOr<NullableTree> parse_step_without_substeps();
|
||||
TextParseErrorOr<Tree> parse_step_with_substeps(Tree substeps);
|
||||
|
||||
FailedTextParseDiagnostic get_diagnostic() const;
|
||||
|
|
|
@ -73,4 +73,13 @@
|
|||
</ol>
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="7" aoid="Notes">
|
||||
<h1><span class="secnum">7</span> Notes ( )</h1>
|
||||
<emu-alg>
|
||||
<ol>
|
||||
<li>NOTE: This abstract operation returns <emu-const>unused</emu-const> in case you didn't notice.</li>
|
||||
<li>Return <emu-const>unused</emu-const>.</li>
|
||||
</ol>
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
</specification>
|
||||
|
|
|
@ -100,3 +100,8 @@ TreeList
|
|||
ReturnNode
|
||||
WellKnownNode Undefined
|
||||
|
||||
Notes():
|
||||
TreeList
|
||||
ReturnNode
|
||||
Enumerator unused
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue