JSSpecCompiler: Parse '?' before function calls in xspec mode

This commit is contained in:
Dan Klishch 2024-01-20 21:52:02 -05:00 committed by Andrew Kaster
parent b800276347
commit 3d365326af
Notes: sideshowbarker 2024-07-17 03:03:37 +09:00
5 changed files with 20 additions and 1 deletions
Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler

View file

@ -242,7 +242,8 @@ protected:
#define ENUMERATE_UNARY_OPERATORS(F) \
F(Invalid) \
F(AssertCompletion) \
F(Minus)
F(Minus) \
F(ReturnIfAbrubt)
#define ENUMERATE_BINARY_OPERATORS(F) \
F(Invalid) \

View file

@ -71,6 +71,7 @@ void tokenize_string(SpecificationParsingContext& ctx, XML::Node const* node, St
{ ")"sv, TokenType::ParenClose },
{ "("sv, TokenType::ParenOpen },
{ "+"sv, TokenType::Plus },
{ "?"sv, TokenType::QuestionMark },
};
LineTrackingLexer lexer(view, node->offset);

View file

@ -44,6 +44,7 @@ constexpr i32 closing_bracket_precedence = 18;
F(ParenClose, 18, Invalid, Invalid, ParenOpen, "')'") \
F(ParenOpen, -1, Invalid, Invalid, ParenClose, "'('") \
F(Plus, 6, Invalid, Plus, Invalid, "plus") \
F(QuestionMark, 3, ReturnIfAbrubt, Invalid, Invalid, "question mark") \
F(SectionNumber, -1, Invalid, Invalid, Invalid, "section number") \
F(String, -1, Invalid, Invalid, Invalid, "string literal") \
F(Superscript, 4, Invalid, Power, Invalid, "subscript") \

View file

@ -33,4 +33,12 @@
</ol>
</emu-alg>
</emu-clause>
<emu-clause id="3" aoid="TestReturnIfAbrupt">
<h1><span class="secnum">3</span> TestReturnIfAbrupt ( <var>a</var> )</h1>
<emu-alg>
<ol>
<li>Return ? <emu-xref><a>WellKnownConstants</a></emu-xref>(<var>a</var>).</li>
</ol>
</emu-alg>
</emu-clause>
</specification>

View file

@ -46,3 +46,11 @@ TreeList
ReturnNode
WellKnownNode False
TestReturnIfAbrupt(a):
TreeList
ReturnNode
UnaryOperation ReturnIfAbrubt
FunctionCall
Func "WellKnownConstants"
Var a