1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

JSSpecCompiler: Properly parse function calls with zero arguments

We cannot handle them normally since we need text between parenthesis to
be a valid expression. As a workaround, we now push an artificial value
to stack to act as an argument (it'll be later removed during function
call canonicalization).
This commit is contained in:
Dan Klishch 2024-01-16 00:21:59 -05:00 committed by Andrew Kaster
parent 14ee25b8ba
commit 33b36476d9
4 changed files with 50 additions and 1 deletions

View file

@ -130,7 +130,27 @@ protected:
void dump_tree(StringBuilder& builder) override;
};
class WellKnownNode : public Expression {
public:
enum Type {
ZeroArgumentFunctionCall,
// Update WellKnownNode::dump_tree after adding an entry here
};
WellKnownNode(Type type)
: m_type(type)
{
}
protected:
void dump_tree(StringBuilder& builder) override;
private:
Type m_type;
};
inline Tree const error_tree = make_ref_counted<ErrorNode>();
inline Tree const zero_argument_function_call = make_ref_counted<WellKnownNode>(WellKnownNode::ZeroArgumentFunctionCall);
class ControlFlowFunctionReturn : public ControlFlowOperator {
public: