1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:48:12 +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

@ -54,7 +54,7 @@ Value ExpressionStatement::execute(Interpreter& interpreter) const
Value CallExpression::execute(Interpreter& interpreter) const
{
auto callee = interpreter.get_variable(name());
auto callee = m_callee->execute(interpreter);
ASSERT(callee.is_object());
ASSERT(callee.as_object()->is_function());
auto* function = static_cast<Function*>(callee.as_object());
@ -304,9 +304,8 @@ void UnaryExpression::dump(int indent) const
void CallExpression::dump(int indent) const
{
print_indent(indent);
printf("%s '%s'\n", class_name(), name().characters());
ASTNode::dump(indent);
m_callee->dump(indent + 1);
for (auto& argument : m_arguments)
argument.dump(indent + 1);
}