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

LibJS: Add operator precedence parsing

Obey precedence and associativity rules when parsing expressions
with chained operators.
This commit is contained in:
Stephan Unverwerth 2020-03-12 23:02:41 +01:00 committed by Andreas Kling
parent f347dd5c5e
commit 15d5b2d29e
8 changed files with 281 additions and 53 deletions

View file

@ -398,8 +398,8 @@ private:
class CallExpression : public Expression {
public:
explicit CallExpression(String name, NonnullOwnPtrVector<Expression> arguments = {})
: m_name(move(name))
explicit CallExpression(NonnullOwnPtr<Expression> callee, NonnullOwnPtrVector<Expression> arguments = {})
: m_callee(move(callee))
, m_arguments(move(arguments))
{
}
@ -407,12 +407,10 @@ public:
virtual Value execute(Interpreter&) const override;
virtual void dump(int indent) const override;
const String& name() const { return m_name; }
private:
virtual const char* class_name() const override { return "CallExpression"; }
String m_name;
NonnullOwnPtr<Expression> m_callee;
const NonnullOwnPtrVector<Expression> m_arguments;
};