Commit 0cd3f111 authored by zygzagZ's avatar zygzagZ

Nowa wersja gramatyki

parent 513b2d53
t.cpp t.cpp
t.e
*.o *.o
*.l *.l
*.y *.y
......
This diff is collapsed.
...@@ -60,9 +60,6 @@ public: ...@@ -60,9 +60,6 @@ public:
virtual void visitNoInit(NoInit *p) = 0; virtual void visitNoInit(NoInit *p) = 0;
virtual void visitInit(Init *p) = 0; virtual void visitInit(Init *p) = 0;
virtual void visitAss(Ass *p) = 0; virtual void visitAss(Ass *p) = 0;
virtual void visitTableAss(TableAss *p) = 0;
virtual void visitTableIncr(TableIncr *p) = 0;
virtual void visitTableDecr(TableDecr *p) = 0;
virtual void visitIncr(Incr *p) = 0; virtual void visitIncr(Incr *p) = 0;
virtual void visitDecr(Decr *p) = 0; virtual void visitDecr(Decr *p) = 0;
virtual void visitRet(Ret *p) = 0; virtual void visitRet(Ret *p) = 0;
...@@ -80,18 +77,16 @@ public: ...@@ -80,18 +77,16 @@ public:
virtual void visitClassT(ClassT *p) = 0; virtual void visitClassT(ClassT *p) = 0;
virtual void visitFun(Fun *p) = 0; virtual void visitFun(Fun *p) = 0;
virtual void visitEVar(EVar *p) = 0; virtual void visitEVar(EVar *p) = 0;
virtual void visitEIndexAcc(EIndexAcc *p) = 0;
virtual void visitEClsMmbr(EClsMmbr *p) = 0;
virtual void visitEApp(EApp *p) = 0;
virtual void visitELitInt(ELitInt *p) = 0; virtual void visitELitInt(ELitInt *p) = 0;
virtual void visitELitTrue(ELitTrue *p) = 0; virtual void visitELitTrue(ELitTrue *p) = 0;
virtual void visitELitFalse(ELitFalse *p) = 0; virtual void visitELitFalse(ELitFalse *p) = 0;
virtual void visitEApp(EApp *p) = 0;
virtual void visitEString(EString *p) = 0; virtual void visitEString(EString *p) = 0;
virtual void visitENewArray(ENewArray *p) = 0; virtual void visitENewArray(ENewArray *p) = 0;
virtual void visitENewClass(ENewClass *p) = 0; virtual void visitENewClass(ENewClass *p) = 0;
virtual void visitEClsMmbr(EClsMmbr *p) = 0; virtual void visitNullCast(NullCast *p) = 0;
virtual void visitEClsMthd(EClsMthd *p) = 0;
virtual void visitNull(Null *p) = 0;
virtual void visitEIndexAcc(EIndexAcc *p) = 0;
virtual void visitECast(ECast *p) = 0;
virtual void visitNeg(Neg *p) = 0; virtual void visitNeg(Neg *p) = 0;
virtual void visitNot(Not *p) = 0; virtual void visitNot(Not *p) = 0;
virtual void visitEMul(EMul *p) = 0; virtual void visitEMul(EMul *p) = 0;
...@@ -131,7 +126,7 @@ public: ...@@ -131,7 +126,7 @@ public:
class Visitable class Visitable
{ {
public: public:
virtual ~Visitable() {} virtual ~Visitable() {}
virtual void accept(Visitor *v) = 0; virtual void accept(Visitor *v) = 0;
}; };
...@@ -508,60 +503,14 @@ public: ...@@ -508,60 +503,14 @@ public:
void swap(Ass &); void swap(Ass &);
}; };
class TableAss : public Stmt
{
public:
PIdent *pident_;
Expr *expr_1;
Expr *expr_2;
TableAss(const TableAss &);
TableAss &operator=(const TableAss &);
TableAss(PIdent *p1, Expr *p2, Expr *p3);
~TableAss();
virtual void accept(Visitor *v);
virtual TableAss *clone() const;
void swap(TableAss &);
};
class TableIncr : public Stmt
{
public:
PIdent *pident_;
Expr *expr_;
TableIncr(const TableIncr &);
TableIncr &operator=(const TableIncr &);
TableIncr(PIdent *p1, Expr *p2);
~TableIncr();
virtual void accept(Visitor *v);
virtual TableIncr *clone() const;
void swap(TableIncr &);
};
class TableDecr : public Stmt
{
public:
PIdent *pident_;
Expr *expr_;
TableDecr(const TableDecr &);
TableDecr &operator=(const TableDecr &);
TableDecr(PIdent *p1, Expr *p2);
~TableDecr();
virtual void accept(Visitor *v);
virtual TableDecr *clone() const;
void swap(TableDecr &);
};
class Incr : public Stmt class Incr : public Stmt
{ {
public: public:
PIdent *pident_; Expr *expr_;
Incr(const Incr &); Incr(const Incr &);
Incr &operator=(const Incr &); Incr &operator=(const Incr &);
Incr(PIdent *p1); Incr(Expr *p1);
~Incr(); ~Incr();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Incr *clone() const; virtual Incr *clone() const;
...@@ -571,11 +520,11 @@ public: ...@@ -571,11 +520,11 @@ public:
class Decr : public Stmt class Decr : public Stmt
{ {
public: public:
PIdent *pident_; Expr *expr_;
Decr(const Decr &); Decr(const Decr &);
Decr &operator=(const Decr &); Decr &operator=(const Decr &);
Decr(PIdent *p1); Decr(Expr *p1);
~Decr(); ~Decr();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Decr *clone() const; virtual Decr *clone() const;
...@@ -831,6 +780,52 @@ public: ...@@ -831,6 +780,52 @@ public:
void swap(EVar &); void swap(EVar &);
}; };
class EIndexAcc : public Expr
{
public:
Expr *expr_1;
Expr *expr_2;
EIndexAcc(const EIndexAcc &);
EIndexAcc &operator=(const EIndexAcc &);
EIndexAcc(Expr *p1, Expr *p2);
~EIndexAcc();
virtual void accept(Visitor *v);
virtual EIndexAcc *clone() const;
void swap(EIndexAcc &);
};
class EClsMmbr : public Expr
{
public:
Expr *expr_;
PIdent *pident_;
EClsMmbr(const EClsMmbr &);
EClsMmbr &operator=(const EClsMmbr &);
EClsMmbr(Expr *p1, PIdent *p2);
~EClsMmbr();
virtual void accept(Visitor *v);
virtual EClsMmbr *clone() const;
void swap(EClsMmbr &);
};
class EApp : public Expr
{
public:
Expr *expr_;
ListExpr *listexpr_;
EApp(const EApp &);
EApp &operator=(const EApp &);
EApp(Expr *p1, ListExpr *p2);
~EApp();
virtual void accept(Visitor *v);
virtual EApp *clone() const;
void swap(EApp &);
};
class ELitInt : public Expr class ELitInt : public Expr
{ {
public: public:
...@@ -871,21 +866,6 @@ public: ...@@ -871,21 +866,6 @@ public:
void swap(ELitFalse &); void swap(ELitFalse &);
}; };
class EApp : public Expr
{
public:
PIdent *pident_;
ListExpr *listexpr_;
EApp(const EApp &);
EApp &operator=(const EApp &);
EApp(PIdent *p1, ListExpr *p2);
~EApp();
virtual void accept(Visitor *v);
virtual EApp *clone() const;
void swap(EApp &);
};
class EString : public Expr class EString : public Expr
{ {
public: public:
...@@ -929,78 +909,18 @@ public: ...@@ -929,78 +909,18 @@ public:
void swap(ENewClass &); void swap(ENewClass &);
}; };
class EClsMmbr : public Expr class NullCast : public Expr
{ {
public: public:
Expr *expr_; Expr *expr_;
PIdent *pident_;
EClsMmbr(const EClsMmbr &);
EClsMmbr &operator=(const EClsMmbr &);
EClsMmbr(Expr *p1, PIdent *p2);
~EClsMmbr();
virtual void accept(Visitor *v);
virtual EClsMmbr *clone() const;
void swap(EClsMmbr &);
};
class EClsMthd : public Expr
{
public:
Expr *expr_;
PIdent *pident_;
ListExpr *listexpr_;
EClsMthd(const EClsMthd &);
EClsMthd &operator=(const EClsMthd &);
EClsMthd(Expr *p1, PIdent *p2, ListExpr *p3);
~EClsMthd();
virtual void accept(Visitor *v);
virtual EClsMthd *clone() const;
void swap(EClsMthd &);
};
class Null : public Expr
{
public:
Null(const Null &);
Null &operator=(const Null &);
Null();
~Null();
virtual void accept(Visitor *v);
virtual Null *clone() const;
void swap(Null &);
};
class EIndexAcc : public Expr
{
public:
PIdent *pident_;
Expr *expr_;
EIndexAcc(const EIndexAcc &);
EIndexAcc &operator=(const EIndexAcc &);
EIndexAcc(PIdent *p1, Expr *p2);
~EIndexAcc();
virtual void accept(Visitor *v);
virtual EIndexAcc *clone() const;
void swap(EIndexAcc &);
};
class ECast : public Expr
{
public:
PIdent *pident_;
Expr *expr_;
ECast(const ECast &); NullCast(const NullCast &);
ECast &operator=(const ECast &); NullCast &operator=(const NullCast &);
ECast(PIdent *p1, Expr *p2); NullCast(Expr *p1);
~ECast(); ~NullCast();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ECast *clone() const; virtual NullCast *clone() const;
void swap(ECast &); void swap(NullCast &);
}; };
class Neg : public Expr class Neg : public Expr
......
This diff is collapsed.
This diff is collapsed.
...@@ -107,8 +107,9 @@ Program* pProgram(const char *str); ...@@ -107,8 +107,9 @@ Program* pProgram(const char *str);
#define _SYMB_40 299 #define _SYMB_40 299
#define _SYMB_41 300 #define _SYMB_41 300
#define _SYMB_42 301 #define _SYMB_42 301
#define _STRING_ 302 #define _SYMB_43 302
#define _INTEGER_ 303 #define _STRING_ 303
#define _INTEGER_ 304
extern YYSTYPE yylval; extern YYSTYPE yylval;
......
This diff is collapsed.
...@@ -58,9 +58,6 @@ class PrintAbsyn : public Visitor ...@@ -58,9 +58,6 @@ class PrintAbsyn : public Visitor
void visitBStmt(BStmt *p); void visitBStmt(BStmt *p);
void visitDecl(Decl *p); void visitDecl(Decl *p);
void visitAss(Ass *p); void visitAss(Ass *p);
void visitTableAss(TableAss *p);
void visitTableIncr(TableIncr *p);
void visitTableDecr(TableDecr *p);
void visitIncr(Incr *p); void visitIncr(Incr *p);
void visitDecr(Decr *p); void visitDecr(Decr *p);
void visitRet(Ret *p); void visitRet(Ret *p);
...@@ -85,18 +82,16 @@ class PrintAbsyn : public Visitor ...@@ -85,18 +82,16 @@ class PrintAbsyn : public Visitor
void visitListType(ListType *p); void visitListType(ListType *p);
void visitExpr(Expr *p); /* abstract class */ void visitExpr(Expr *p); /* abstract class */
void visitEVar(EVar *p); void visitEVar(EVar *p);
void visitEIndexAcc(EIndexAcc *p);
void visitEClsMmbr(EClsMmbr *p);
void visitEApp(EApp *p);
void visitELitInt(ELitInt *p); void visitELitInt(ELitInt *p);
void visitELitTrue(ELitTrue *p); void visitELitTrue(ELitTrue *p);
void visitELitFalse(ELitFalse *p); void visitELitFalse(ELitFalse *p);
void visitEApp(EApp *p);
void visitEString(EString *p); void visitEString(EString *p);
void visitENewArray(ENewArray *p); void visitENewArray(ENewArray *p);
void visitENewClass(ENewClass *p); void visitENewClass(ENewClass *p);
void visitEClsMmbr(EClsMmbr *p); void visitNullCast(NullCast *p);
void visitEClsMthd(EClsMthd *p);
void visitNull(Null *p);
void visitEIndexAcc(EIndexAcc *p);
void visitECast(ECast *p);
void visitNeg(Neg *p); void visitNeg(Neg *p);
void visitNot(Not *p); void visitNot(Not *p);
void visitEMul(EMul *p); void visitEMul(EMul *p);
...@@ -231,9 +226,6 @@ class ShowAbsyn : public Visitor ...@@ -231,9 +226,6 @@ class ShowAbsyn : public Visitor
void visitBStmt(BStmt *p); void visitBStmt(BStmt *p);
void visitDecl(Decl *p); void visitDecl(Decl *p);
void visitAss(Ass *p); void visitAss(Ass *p);
void visitTableAss(TableAss *p);
void visitTableIncr(TableIncr *p);
void visitTableDecr(TableDecr *p);
void visitIncr(Incr *p); void visitIncr(Incr *p);
void visitDecr(Decr *p); void visitDecr(Decr *p);
void visitRet(Ret *p); void visitRet(Ret *p);
...@@ -258,18 +250,16 @@ class ShowAbsyn : public Visitor ...@@ -258,18 +250,16 @@ class ShowAbsyn : public Visitor
void visitListType(ListType *p); void visitListType(ListType *p);
void visitExpr(Expr *p); /* abstract class */ void visitExpr(Expr *p); /* abstract class */
void visitEVar(EVar *p); void visitEVar(EVar *p);
void visitEIndexAcc(EIndexAcc *p);
void visitEClsMmbr(EClsMmbr *p);
void visitEApp(EApp *p);
void visitELitInt(ELitInt *p); void visitELitInt(ELitInt *p);
void visitELitTrue(ELitTrue *p); void visitELitTrue(ELitTrue *p);
void visitELitFalse(ELitFalse *p); void visitELitFalse(ELitFalse *p);
void visitEApp(EApp *p);
void visitEString(EString *p); void visitEString(EString *p);
void visitENewArray(ENewArray *p); void visitENewArray(ENewArray *p);
void visitENewClass(ENewClass *p); void visitENewClass(ENewClass *p);
void visitEClsMmbr(EClsMmbr *p); void visitNullCast(NullCast *p);
void visitEClsMthd(EClsMthd *p);
void visitNull(Null *p);
void visitEIndexAcc(EIndexAcc *p);
void visitECast(ECast *p);
void visitNeg(Neg *p); void visitNeg(Neg *p);
void visitNot(Not *p); void visitNot(Not *p);
void visitEMul(EMul *p); void visitEMul(EMul *p);
...@@ -370,4 +360,3 @@ class ShowAbsyn : public Visitor ...@@ -370,4 +360,3 @@ class ShowAbsyn : public Visitor
#endif #endif
...@@ -162,39 +162,11 @@ void Skeleton::visitAss(Ass *ass) ...@@ -162,39 +162,11 @@ void Skeleton::visitAss(Ass *ass)
} }
void Skeleton::visitTableAss(TableAss *table_ass)
{
/* Code For TableAss Goes Here */
table_ass->pident_->accept(this);
table_ass->expr_1->accept(this);
table_ass->expr_2->accept(this);
}
void Skeleton::visitTableIncr(TableIncr *table_incr)
{
/* Code For TableIncr Goes Here */
table_incr->pident_->accept(this);
table_incr->expr_->accept(this);
}
void Skeleton::visitTableDecr(TableDecr *table_decr)
{
/* Code For TableDecr Goes Here */
table_decr->pident_->accept(this);
table_decr->expr_->accept(this);
}
void Skeleton::visitIncr(Incr *incr) void Skeleton::visitIncr(Incr *incr)
{ {
/* Code For Incr Goes Here */ /* Code For Incr Goes Here */
incr->pident_->accept(this); incr->expr_->accept(this);
} }
...@@ -202,7 +174,7 @@ void Skeleton::visitDecr(Decr *decr) ...@@ -202,7 +174,7 @@ void Skeleton::visitDecr(Decr *decr)
{ {
/* Code For Decr Goes Here */ /* Code For Decr Goes Here */
decr->pident_->accept(this); decr->expr_->accept(this);
} }
...@@ -346,25 +318,21 @@ void Skeleton::visitEVar(EVar *e_var) ...@@ -346,25 +318,21 @@ void Skeleton::visitEVar(EVar *e_var)
} }
void Skeleton::visitELitInt(ELitInt *e_lit_int) void Skeleton::visitEIndexAcc(EIndexAcc *e_index_acc)
{
/* Code For ELitInt Goes Here */
visitInteger(e_lit_int->integer_);
}
void Skeleton::visitELitTrue(ELitTrue *e_lit_true)
{ {
/* Code For ELitTrue Goes Here */ /* Code For EIndexAcc Goes Here */
e_index_acc->expr_1->accept(this);
e_index_acc->expr_2->accept(this);
} }
void Skeleton::visitELitFalse(ELitFalse *e_lit_false) void Skeleton::visitEClsMmbr(EClsMmbr *e_cls_mmbr)
{ {
/* Code For ELitFalse Goes Here */ /* Code For EClsMmbr Goes Here */
e_cls_mmbr->expr_->accept(this);
e_cls_mmbr->pident_->accept(this);
} }
...@@ -372,77 +340,63 @@ void Skeleton::visitEApp(EApp *e_app) ...@@ -372,77 +340,63 @@ void Skeleton::visitEApp(EApp *e_app)
{ {
/* Code For EApp Goes Here */ /* Code For EApp Goes Here */
e_app->pident_->accept(this); e_app->expr_->accept(this);
e_app->listexpr_->accept(this); e_app->listexpr_->accept(this);
} }
void Skeleton::visitEString(EString *e_string) void Skeleton::visitELitInt(ELitInt *e_lit_int)
{
/* Code For EString Goes Here */
visitString(e_string->string_);
}
void Skeleton::visitENewArray(ENewArray *e_new_array)
{ {
/* Code For ENewArray Goes Here */ /* Code For ELitInt Goes Here */
e_new_array->type_->accept(this); visitInteger(e_lit_int->integer_);
e_new_array->expr_->accept(this);
} }
void Skeleton::visitENewClass(ENewClass *e_new_class) void Skeleton::visitELitTrue(ELitTrue *e_lit_true)
{ {
/* Code For ENewClass Goes Here */ /* Code For ELitTrue Goes Here */
e_new_class->pident_->accept(this);
} }
void Skeleton::visitEClsMmbr(EClsMmbr *e_cls_mmbr) void Skeleton::visitELitFalse(ELitFalse *e_lit_false)
{ {
/* Code For EClsMmbr Goes Here */ /* Code For ELitFalse Goes Here */
e_cls_mmbr->expr_->accept(this);
e_cls_mmbr->pident_->accept(this);
} }
void Skeleton::visitEClsMthd(EClsMthd *e_cls_mthd) void Skeleton::visitEString(EString *e_string)
{ {
/* Code For EClsMthd Goes Here */ /* Code For EString Goes Here */
e_cls_mthd->expr_->accept(this); visitString(e_string->string_);
e_cls_mthd->pident_->accept(this);
e_cls_mthd->listexpr_->accept(this);
} }
void Skeleton::visitNull(Null *null) void Skeleton::visitENewArray(ENewArray *e_new_array)
{ {
/* Code For Null Goes Here */ /* Code For ENewArray Goes Here */
e_new_array->type_->accept(this);
e_new_array->expr_->accept(this);
} }
void Skeleton::visitEIndexAcc(EIndexAcc *e_index_acc) void Skeleton::visitENewClass(ENewClass *e_new_class)
{ {
/* Code For EIndexAcc Goes Here */ /* Code For ENewClass Goes Here */
e_index_acc->pident_->accept(this); e_new_class->pident_->accept(this);
e_index_acc->expr_->accept(this);
} }
void Skeleton::visitECast(ECast *e_cast) void Skeleton::visitNullCast(NullCast *null_cast)
{ {
/* Code For ECast Goes Here */ /* Code For NullCast Goes Here */
e_cast->pident_->accept(this); null_cast->expr_->accept(this);
e_cast->expr_->accept(this);
} }
...@@ -671,4 +625,3 @@ void Skeleton::visitIdent(Ident x) ...@@ -671,4 +625,3 @@ void Skeleton::visitIdent(Ident x)
} }
...@@ -40,9 +40,6 @@ public: ...@@ -40,9 +40,6 @@ public:
void visitNoInit(NoInit *p); void visitNoInit(NoInit *p);
void visitInit(Init *p); void visitInit(Init *p);
void visitAss(Ass *p); void visitAss(Ass *p);
void visitTableAss(TableAss *p);
void visitTableIncr(TableIncr *p);
void visitTableDecr(TableDecr *p);
void visitIncr(Incr *p); void visitIncr(Incr *p);
void visitDecr(Decr *p); void visitDecr(Decr *p);
void visitRet(Ret *p); void visitRet(Ret *p);
...@@ -60,18 +57,16 @@ public: ...@@ -60,18 +57,16 @@ public:
void visitClassT(ClassT *p); void visitClassT(ClassT *p);
void visitFun(Fun *p); void visitFun(Fun *p);
void visitEVar(EVar *p); void visitEVar(EVar *p);
void visitEIndexAcc(EIndexAcc *p);
void visitEClsMmbr(EClsMmbr *p);
void visitEApp(EApp *p);
void visitELitInt(ELitInt *p); void visitELitInt(ELitInt *p);
void visitELitTrue(ELitTrue *p); void visitELitTrue(ELitTrue *p);
void visitELitFalse(ELitFalse *p); void visitELitFalse(ELitFalse *p);
void visitEApp(EApp *p);
void visitEString(EString *p); void visitEString(EString *p);
void visitENewArray(ENewArray *p); void visitENewArray(ENewArray *p);
void visitENewClass(ENewClass *p); void visitENewClass(ENewClass *p);
void visitEClsMmbr(EClsMmbr *p); void visitNullCast(NullCast *p);
void visitEClsMthd(EClsMthd *p);
void visitNull(Null *p);
void visitEIndexAcc(EIndexAcc *p);
void visitECast(ECast *p);
void visitNeg(Neg *p); void visitNeg(Neg *p);
void visitNot(Not *p); void visitNot(Not *p);
void visitEMul(EMul *p); void visitEMul(EMul *p);
...@@ -108,4 +103,4 @@ public: ...@@ -108,4 +103,4 @@ public:
}; };
#endif #endif
\ No newline at end of file
...@@ -122,51 +122,23 @@ void TypeCheck::visitDecl(Decl *decl) ...@@ -122,51 +122,23 @@ void TypeCheck::visitDecl(Decl *decl)
el->expr_->accept(this); el->expr_->accept(this);
VarInfoPtr var = make_shared<VarInfo>(el->pident_, type); VarInfoPtr var = make_shared<VarInfo>(el->pident_, type);
scope.currentBinding.variables << var; scope.currentBinding->variables << var;
} }
} }
void TypeCheck::visitAss(Ass *ass) void TypeCheck::visitAss(Ass *ass)
{ {
auto var = scope.currentBinding.variables[] // auto var = scope.currentBinding->variables[]
ass->expr_1->accept(this); ass->expr_1->accept(this);
ass->expr_2->accept(this); ass->expr_2->accept(this);
} }
void TypeCheck::visitTableAss(TableAss *table_ass)
{
/* Code For TableAss Goes Here */
table_ass->pident_->accept(this);
table_ass->expr_1->accept(this);
table_ass->expr_2->accept(this);
}
void TypeCheck::visitTableIncr(TableIncr *table_incr)
{
/* Code For TableIncr Goes Here */
table_incr->pident_->accept(this);
table_incr->expr_->accept(this);
}
void TypeCheck::visitTableDecr(TableDecr *table_decr)
{
/* Code For TableDecr Goes Here */
table_decr->pident_->accept(this);
table_decr->expr_->accept(this);
}
void TypeCheck::visitIncr(Incr *incr) void TypeCheck::visitIncr(Incr *incr)
{ {
/* Code For Incr Goes Here */ /* Code For Incr Goes Here */
incr->pident_->accept(this); incr->expr_->accept(this);
} }
...@@ -174,7 +146,7 @@ void TypeCheck::visitDecr(Decr *decr) ...@@ -174,7 +146,7 @@ void TypeCheck::visitDecr(Decr *decr)
{ {
/* Code For Decr Goes Here */ /* Code For Decr Goes Here */
decr->pident_->accept(this); decr->expr_->accept(this);
} }
...@@ -301,6 +273,33 @@ void TypeCheck::visitEVar(EVar *e_var) ...@@ -301,6 +273,33 @@ void TypeCheck::visitEVar(EVar *e_var)
} }
void TypeCheck::visitEIndexAcc(EIndexAcc *e_index_acc)
{
/* Code For EIndexAcc Goes Here */
e_index_acc->expr_1->accept(this);
e_index_acc->expr_2->accept(this);
}
void TypeCheck::visitEClsMmbr(EClsMmbr *e_cls_mmbr)
{
/* Code For EClsMmbr Goes Here */
e_cls_mmbr->expr_->accept(this);
e_cls_mmbr->pident_->accept(this);
}
void TypeCheck::visitEApp(EApp *e_app)
{
/* Code For EApp Goes Here */
e_app->expr_->accept(this);
e_app->listexpr_->accept(this);
}
void TypeCheck::visitELitInt(ELitInt *e_lit_int) void TypeCheck::visitELitInt(ELitInt *e_lit_int)
{ {
visitInteger(e_lit_int->integer_); visitInteger(e_lit_int->integer_);
...@@ -317,15 +316,6 @@ void TypeCheck::visitELitFalse(ELitFalse *e_lit_false) ...@@ -317,15 +316,6 @@ void TypeCheck::visitELitFalse(ELitFalse *e_lit_false)
lastType = make_shared<Bool>(); lastType = make_shared<Bool>();
} }
void TypeCheck::visitEApp(EApp *e_app)
{
/* Code For EApp Goes Here */
e_app->pident_->accept(this);
e_app->listexpr_->accept(this);
}
void TypeCheck::visitEString(EString *e) void TypeCheck::visitEString(EString *e)
{ {
/* Code For EString Goes Here */ /* Code For EString Goes Here */
...@@ -359,48 +349,56 @@ void TypeCheck::visitENewClass(ENewClass *e_new_class) ...@@ -359,48 +349,56 @@ void TypeCheck::visitENewClass(ENewClass *e_new_class)
lastType = make_shared<ClassT>(e_new_class->pident_); lastType = make_shared<ClassT>(e_new_class->pident_);
} }
void TypeCheck::visitEClsMmbr(EClsMmbr *e_cls_mmbr) void TypeCheck::visitNullCast(NullCast *null_cast)
{ {
/* Code For EClsMmbr Goes Here */ /* Code For NullCast Goes Here */
e_cls_mmbr->expr_->accept(this); null_cast->expr_->accept(this);
e_cls_mmbr->pident_->accept(this);
} }
void TypeCheck::visitEClsMthd(EClsMthd *e_cls_mthd) // void TypeCheck::visitEClsMmbr(EClsMmbr *e_cls_mmbr)
{ // {
/* Code For EClsMthd Goes Here */ // /* Code For EClsMmbr Goes Here */
e_cls_mthd->expr_->accept(this); // e_cls_mmbr->expr_->accept(this);
e_cls_mthd->pident_->accept(this); // e_cls_mmbr->pident_->accept(this);
e_cls_mthd->listexpr_->accept(this);
} // }
void TypeCheck::visitNull(Null *e) // void TypeCheck::visitEClsMthd(EClsMthd *e_cls_mthd)
{ // {
PIdent *ident = new PIdent("null", e->lineno); // /* Code For EClsMthd Goes Here */
lastType = make_shared<ClassT>(ident); // TODO
}
void TypeCheck::visitEIndexAcc(EIndexAcc *e_index_acc) // e_cls_mthd->expr_->accept(this);
{ // e_cls_mthd->pident_->accept(this);
/* Code For EIndexAcc Goes Here */ // e_cls_mthd->listexpr_->accept(this);
e_index_acc->pident_->accept(this); // }
e_index_acc->expr_->accept(this);
throw UndefinedError(e_index_acc->pident_); // TODO
}
void TypeCheck::visitECast(ECast *e_cast) // void TypeCheck::visitNull(Null *e)
{ // {
/* Code For ECast Goes Here */ // PIdent *ident = new PIdent("null", e->lineno);
// lastType = make_shared<ClassT>(ident); // TODO
// }
e_cast->pident_->accept(this); // void TypeCheck::visitEIndexAcc(EIndexAcc *e_index_acc)
e_cast->expr_->accept(this); // {
lastType = make_shared<ClassT>(e_cast->pident_); // /* Code For EIndexAcc Goes Here */
}
// e_index_acc->pident_->accept(this);
// e_index_acc->expr_->accept(this);
// throw UndefinedError(e_index_acc->pident_); // TODO
// }
// void TypeCheck::visitECast(ECast *e_cast)
// {
// /* Code For ECast Goes Here */
// e_cast->pident_->accept(this);
// e_cast->expr_->accept(this);
// lastType = make_shared<ClassT>(e_cast->pident_);
// }
void TypeCheck::visitNeg(Neg *e) void TypeCheck::visitNeg(Neg *e)
{ {
......
...@@ -37,9 +37,6 @@ protected: ...@@ -37,9 +37,6 @@ protected:
void visitBStmt(BStmt *p); void visitBStmt(BStmt *p);
void visitDecl(Decl *p); void visitDecl(Decl *p);
void visitAss(Ass *p); void visitAss(Ass *p);
void visitTableAss(TableAss *p);
void visitTableIncr(TableIncr *p);
void visitTableDecr(TableDecr *p);
void visitIncr(Incr *p); void visitIncr(Incr *p);
void visitDecr(Decr *p); void visitDecr(Decr *p);
void visitRet(Ret *p); void visitRet(Ret *p);
...@@ -57,18 +54,16 @@ protected: ...@@ -57,18 +54,16 @@ protected:
void visitClassT(ClassT *p); void visitClassT(ClassT *p);
void visitFun(Fun *p); void visitFun(Fun *p);
void visitEVar(EVar *p); void visitEVar(EVar *p);
void visitEIndexAcc(EIndexAcc *p);
void visitEClsMmbr(EClsMmbr *p);
void visitEApp(EApp *p);
void visitELitInt(ELitInt *p); void visitELitInt(ELitInt *p);
void visitELitTrue(ELitTrue *p); void visitELitTrue(ELitTrue *p);
void visitELitFalse(ELitFalse *p); void visitELitFalse(ELitFalse *p);
void visitEApp(EApp *p);
void visitEString(EString *p); void visitEString(EString *p);
void visitENewArray(ENewArray *p); void visitENewArray(ENewArray *p);
void visitENewClass(ENewClass *p); void visitENewClass(ENewClass *p);
void visitEClsMmbr(EClsMmbr *p); void visitNullCast(NullCast *p);
void visitEClsMthd(EClsMthd *p);
void visitNull(Null *p);
void visitEIndexAcc(EIndexAcc *p);
void visitECast(ECast *p);
void visitNeg(Neg *p); void visitNeg(Neg *p);
void visitNot(Not *p); void visitNot(Not *p);
void visitEMul(EMul *p); void visitEMul(EMul *p);
......
...@@ -48,9 +48,6 @@ class Decl; ...@@ -48,9 +48,6 @@ class Decl;
using NoInit = Item; using NoInit = Item;
using Init = Item; using Init = Item;
class Ass; class Ass;
class TableAss;
class TableIncr;
class TableDecr;
class Incr; class Incr;
class Decr; class Decr;
class Ret; class Ret;
...@@ -68,18 +65,16 @@ class Array; ...@@ -68,18 +65,16 @@ class Array;
class ClassT; class ClassT;
class Fun; class Fun;
class EVar; class EVar;
class EIndexAcc;
class EClsMmbr;
class EApp;
class ELitInt; class ELitInt;
class ELitTrue; class ELitTrue;
class ELitFalse; class ELitFalse;
class EApp;
class EString; class EString;
class ENewArray; class ENewArray;
class ENewClass; class ENewClass;
class EClsMmbr; class NullCast;
class EClsMthd;
class Null;
class EIndexAcc;
class ECast;
class Neg; class Neg;
class Not; class Not;
class EMul; class EMul;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment