Fix Scope
This commit is contained in:
@@ -78,7 +78,7 @@ statement(A) ::= T_FOR T_LPAREN expr(INIT) T_SEMICOLON expr(COND) T_SEMICOLON ex
|
||||
statement(A) ::= T_RFOR T_LPAREN expr(INIT) T_SEMICOLON T_CINT(P) T_SEMICOLON expr(STEP) T_RPAREN statement(S).
|
||||
{ A = 0; /* INIT P STEP S */ }
|
||||
statement(A) ::= T_RETURN expr(E) T_SEMICOLON. { A = 0; /* E */ }
|
||||
statement(A) ::= T_BEGIN statements(S) T_END. { A = 0; /* S */ }
|
||||
statement(A) ::= T_BEGIN statements(S) T_END. { A = new Scope(S); }
|
||||
statement(A) ::= vardef(V) T_SEMICOLON. { A = 0; /* V */ }
|
||||
statement(A) ::= expr(E) T_SEMICOLON. { A = 0; /* E */ }
|
||||
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
#define SCOPE_H
|
||||
|
||||
#include "AST/Statement.h"
|
||||
#include "AST/StatementList.h"
|
||||
|
||||
class Scope : public Statement {
|
||||
public:
|
||||
Scope(Statement* stmt);
|
||||
Scope(StatementList* sl);
|
||||
virtual ~Scope();
|
||||
|
||||
virtual void accept(ASTVisitor* visitor);
|
||||
|
||||
Statement* getStmt();
|
||||
StatementList* getSl();
|
||||
private:
|
||||
Statement* stmt_;
|
||||
StatementList* sl_;
|
||||
};
|
||||
|
||||
#endif // SCOPE_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "AST/Scope.h"
|
||||
#include "AST/ASTVisitor.h"
|
||||
|
||||
Scope::Scope(Statement* stmt) : stmt_(stmt) {
|
||||
Scope::Scope(StatementList *sl) : sl_(sl) {
|
||||
//
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ void Scope::accept(ASTVisitor* visitor) {
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
Statement* Scope::getStmt() {
|
||||
return stmt_;
|
||||
StatementList* Scope::getSl() {
|
||||
return sl_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user