Fix Scope

This commit is contained in:
Markus Hauschild
2013-06-01 02:29:23 +02:00
parent 8423949f42
commit 4c38e6f454
3 changed files with 8 additions and 7 deletions

View File

@@ -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 */ }

View File

@@ -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

View File

@@ -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_;
}