summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/AST.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-23 19:08:32 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-23 19:10:18 +0100
commitdf524203b2ebbe16356e594e9cd6ab845caa15dd (patch)
treea0a3934bae626db8a17a05674d5665645c0a0c35 /Libraries/LibJS/AST.h
parentfbb9e1b71507acefec54f8fbee68fa6b6d8a4512 (diff)
downloadserenity-df524203b2ebbe16356e594e9cd6ab845caa15dd.zip
LibJS: Consume semicolon at the end of a statement
A bunch of code was relying on this not happenind, in particular the parsing of "for" statements. Reorganized things so they work again.
Diffstat (limited to 'Libraries/LibJS/AST.h')
-rw-r--r--Libraries/LibJS/AST.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/Libraries/LibJS/AST.h b/Libraries/LibJS/AST.h
index 3f5e58bec5..d52335be8e 100644
--- a/Libraries/LibJS/AST.h
+++ b/Libraries/LibJS/AST.h
@@ -53,6 +53,7 @@ public:
virtual bool is_identifier() const { return false; }
virtual bool is_member_expression() const { return false; }
virtual bool is_scope_node() const { return false; }
+ virtual bool is_variable_declaration() const { return false; }
protected:
ASTNode() {}
@@ -61,8 +62,6 @@ private:
};
class Statement : public ASTNode {
-public:
- virtual bool is_variable_declaration() const { return false; }
};
class ErrorStatement final : public Statement {
@@ -259,7 +258,7 @@ private:
class ForStatement : public Statement {
public:
- ForStatement(RefPtr<Statement> init, RefPtr<Expression> test, RefPtr<Expression> update, NonnullRefPtr<ScopeNode> body)
+ ForStatement(RefPtr<ASTNode> init, RefPtr<Expression> test, RefPtr<Expression> update, NonnullRefPtr<ScopeNode> body)
: m_init(move(init))
, m_test(move(test))
, m_update(move(update))
@@ -267,7 +266,7 @@ public:
{
}
- const Statement* init() const { return m_init; }
+ const ASTNode* init() const { return m_init; }
const Expression* test() const { return m_test; }
const Expression* update() const { return m_update; }
const ScopeNode& body() const { return *m_body; }
@@ -278,7 +277,7 @@ public:
private:
virtual const char* class_name() const override { return "ForStatement"; }
- RefPtr<Statement> m_init;
+ RefPtr<ASTNode> m_init;
RefPtr<Expression> m_test;
RefPtr<Expression> m_update;
NonnullRefPtr<ScopeNode> m_body;