Commit 8072a075 authored by zygzagZ's avatar zygzagZ

Convert to tabs

parent 0df5b04c
...@@ -7,29 +7,29 @@ ...@@ -7,29 +7,29 @@
/******************** PIdent ********************/ /******************** PIdent ********************/
PIdent::PIdent(String p1, Integer p2) PIdent::PIdent(String p1, Integer p2)
{ {
string_ = p1; string_ = p1;
integer_ = p2; integer_ = p2;
} }
PIdent::PIdent(const PIdent & other) PIdent::PIdent(const PIdent & other)
{ {
string_ = other.string_; string_ = other.string_;
integer_ = other.integer_; integer_ = other.integer_;
} }
PIdent &PIdent::operator=(const PIdent & other) PIdent &PIdent::operator=(const PIdent & other)
{ {
PIdent tmp(other); PIdent tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void PIdent::swap(PIdent & other) void PIdent::swap(PIdent & other)
{ {
std::swap(string_, other.string_); std::swap(string_, other.string_);
std::swap(integer_, other.integer_); std::swap(integer_, other.integer_);
} }
...@@ -40,12 +40,12 @@ PIdent::~PIdent() ...@@ -40,12 +40,12 @@ PIdent::~PIdent()
void PIdent::accept(Visitor *v) void PIdent::accept(Visitor *v)
{ {
v->visitPIdent(this); v->visitPIdent(this);
} }
PIdent *PIdent::clone() const PIdent *PIdent::clone() const
{ {
return new PIdent(*this); return new PIdent(*this);
} }
...@@ -53,43 +53,43 @@ PIdent *PIdent::clone() const ...@@ -53,43 +53,43 @@ PIdent *PIdent::clone() const
/******************** Prog ********************/ /******************** Prog ********************/
Prog::Prog(ListTopDef *p1) Prog::Prog(ListTopDef *p1)
{ {
listtopdef_ = p1; listtopdef_ = p1;
} }
Prog::Prog(const Prog & other) Prog::Prog(const Prog & other)
{ {
listtopdef_ = other.listtopdef_->clone(); listtopdef_ = other.listtopdef_->clone();
} }
Prog &Prog::operator=(const Prog & other) Prog &Prog::operator=(const Prog & other)
{ {
Prog tmp(other); Prog tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Prog::swap(Prog & other) void Prog::swap(Prog & other)
{ {
std::swap(listtopdef_, other.listtopdef_); std::swap(listtopdef_, other.listtopdef_);
} }
Prog::~Prog() Prog::~Prog()
{ {
delete(listtopdef_); delete(listtopdef_);
} }
void Prog::accept(Visitor *v) void Prog::accept(Visitor *v)
{ {
v->visitProg(this); v->visitProg(this);
} }
Prog *Prog::clone() const Prog *Prog::clone() const
{ {
return new Prog(*this); return new Prog(*this);
} }
...@@ -97,43 +97,43 @@ Prog *Prog::clone() const ...@@ -97,43 +97,43 @@ Prog *Prog::clone() const
/******************** FnDef ********************/ /******************** FnDef ********************/
FnDef::FnDef(FunDef *p1) FnDef::FnDef(FunDef *p1)
{ {
fundef_ = p1; fundef_ = p1;
} }
FnDef::FnDef(const FnDef & other) FnDef::FnDef(const FnDef & other)
{ {
fundef_ = other.fundef_->clone(); fundef_ = other.fundef_->clone();
} }
FnDef &FnDef::operator=(const FnDef & other) FnDef &FnDef::operator=(const FnDef & other)
{ {
FnDef tmp(other); FnDef tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void FnDef::swap(FnDef & other) void FnDef::swap(FnDef & other)
{ {
std::swap(fundef_, other.fundef_); std::swap(fundef_, other.fundef_);
} }
FnDef::~FnDef() FnDef::~FnDef()
{ {
delete(fundef_); delete(fundef_);
} }
void FnDef::accept(Visitor *v) void FnDef::accept(Visitor *v)
{ {
v->visitFnDef(this); v->visitFnDef(this);
} }
FnDef *FnDef::clone() const FnDef *FnDef::clone() const
{ {
return new FnDef(*this); return new FnDef(*this);
} }
...@@ -141,43 +141,43 @@ FnDef *FnDef::clone() const ...@@ -141,43 +141,43 @@ FnDef *FnDef::clone() const
/******************** ClDef ********************/ /******************** ClDef ********************/
ClDef::ClDef(ClassDef *p1) ClDef::ClDef(ClassDef *p1)
{ {
classdef_ = p1; classdef_ = p1;
} }
ClDef::ClDef(const ClDef & other) ClDef::ClDef(const ClDef & other)
{ {
classdef_ = other.classdef_->clone(); classdef_ = other.classdef_->clone();
} }
ClDef &ClDef::operator=(const ClDef & other) ClDef &ClDef::operator=(const ClDef & other)
{ {
ClDef tmp(other); ClDef tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ClDef::swap(ClDef & other) void ClDef::swap(ClDef & other)
{ {
std::swap(classdef_, other.classdef_); std::swap(classdef_, other.classdef_);
} }
ClDef::~ClDef() ClDef::~ClDef()
{ {
delete(classdef_); delete(classdef_);
} }
void ClDef::accept(Visitor *v) void ClDef::accept(Visitor *v)
{ {
v->visitClDef(this); v->visitClDef(this);
} }
ClDef *ClDef::clone() const ClDef *ClDef::clone() const
{ {
return new ClDef(*this); return new ClDef(*this);
} }
...@@ -185,55 +185,55 @@ ClDef *ClDef::clone() const ...@@ -185,55 +185,55 @@ ClDef *ClDef::clone() const
/******************** FuncDef ********************/ /******************** FuncDef ********************/
FuncDef::FuncDef(Type *p1, PIdent *p2, ListArg *p3, Block *p4) FuncDef::FuncDef(Type *p1, PIdent *p2, ListArg *p3, Block *p4)
{ {
type_ = p1; type_ = p1;
pident_ = p2; pident_ = p2;
listarg_ = p3; listarg_ = p3;
block_ = p4; block_ = p4;
} }
FuncDef::FuncDef(const FuncDef & other) FuncDef::FuncDef(const FuncDef & other)
{ {
type_ = other.type_->clone(); type_ = other.type_->clone();
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
listarg_ = other.listarg_->clone(); listarg_ = other.listarg_->clone();
block_ = other.block_->clone(); block_ = other.block_->clone();
} }
FuncDef &FuncDef::operator=(const FuncDef & other) FuncDef &FuncDef::operator=(const FuncDef & other)
{ {
FuncDef tmp(other); FuncDef tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void FuncDef::swap(FuncDef & other) void FuncDef::swap(FuncDef & other)
{ {
std::swap(type_, other.type_); std::swap(type_, other.type_);
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
std::swap(listarg_, other.listarg_); std::swap(listarg_, other.listarg_);
std::swap(block_, other.block_); std::swap(block_, other.block_);
} }
FuncDef::~FuncDef() FuncDef::~FuncDef()
{ {
delete(type_); delete(type_);
delete(pident_); delete(pident_);
delete(listarg_); delete(listarg_);
delete(block_); delete(block_);
} }
void FuncDef::accept(Visitor *v) void FuncDef::accept(Visitor *v)
{ {
v->visitFuncDef(this); v->visitFuncDef(this);
} }
FuncDef *FuncDef::clone() const FuncDef *FuncDef::clone() const
{ {
return new FuncDef(*this); return new FuncDef(*this);
} }
...@@ -241,47 +241,47 @@ FuncDef *FuncDef::clone() const ...@@ -241,47 +241,47 @@ FuncDef *FuncDef::clone() const
/******************** Ar ********************/ /******************** Ar ********************/
Ar::Ar(Type *p1, PIdent *p2) Ar::Ar(Type *p1, PIdent *p2)
{ {
type_ = p1; type_ = p1;
pident_ = p2; pident_ = p2;
} }
Ar::Ar(const Ar & other) Ar::Ar(const Ar & other)
{ {
type_ = other.type_->clone(); type_ = other.type_->clone();
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
} }
Ar &Ar::operator=(const Ar & other) Ar &Ar::operator=(const Ar & other)
{ {
Ar tmp(other); Ar tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Ar::swap(Ar & other) void Ar::swap(Ar & other)
{ {
std::swap(type_, other.type_); std::swap(type_, other.type_);
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
} }
Ar::~Ar() Ar::~Ar()
{ {
delete(type_); delete(type_);
delete(pident_); delete(pident_);
} }
void Ar::accept(Visitor *v) void Ar::accept(Visitor *v)
{ {
v->visitAr(this); v->visitAr(this);
} }
Ar *Ar::clone() const Ar *Ar::clone() const
{ {
return new Ar(*this); return new Ar(*this);
} }
...@@ -289,47 +289,47 @@ Ar *Ar::clone() const ...@@ -289,47 +289,47 @@ Ar *Ar::clone() const
/******************** ClassDefN ********************/ /******************** ClassDefN ********************/
ClassDefN::ClassDefN(PIdent *p1, ClassBlock *p2) ClassDefN::ClassDefN(PIdent *p1, ClassBlock *p2)
{ {
pident_ = p1; pident_ = p1;
classblock_ = p2; classblock_ = p2;
} }
ClassDefN::ClassDefN(const ClassDefN & other) ClassDefN::ClassDefN(const ClassDefN & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
classblock_ = other.classblock_->clone(); classblock_ = other.classblock_->clone();
} }
ClassDefN &ClassDefN::operator=(const ClassDefN & other) ClassDefN &ClassDefN::operator=(const ClassDefN & other)
{ {
ClassDefN tmp(other); ClassDefN tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ClassDefN::swap(ClassDefN & other) void ClassDefN::swap(ClassDefN & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
std::swap(classblock_, other.classblock_); std::swap(classblock_, other.classblock_);
} }
ClassDefN::~ClassDefN() ClassDefN::~ClassDefN()
{ {
delete(pident_); delete(pident_);
delete(classblock_); delete(classblock_);
} }
void ClassDefN::accept(Visitor *v) void ClassDefN::accept(Visitor *v)
{ {
v->visitClassDefN(this); v->visitClassDefN(this);
} }
ClassDefN *ClassDefN::clone() const ClassDefN *ClassDefN::clone() const
{ {
return new ClassDefN(*this); return new ClassDefN(*this);
} }
...@@ -337,51 +337,51 @@ ClassDefN *ClassDefN::clone() const ...@@ -337,51 +337,51 @@ ClassDefN *ClassDefN::clone() const
/******************** ClassDefE ********************/ /******************** ClassDefE ********************/
ClassDefE::ClassDefE(PIdent *p1, PIdent *p2, ClassBlock *p3) ClassDefE::ClassDefE(PIdent *p1, PIdent *p2, ClassBlock *p3)
{ {
pident_1 = p1; pident_1 = p1;
pident_2 = p2; pident_2 = p2;
classblock_ = p3; classblock_ = p3;
} }
ClassDefE::ClassDefE(const ClassDefE & other) ClassDefE::ClassDefE(const ClassDefE & other)
{ {
pident_1 = other.pident_1->clone(); pident_1 = other.pident_1->clone();
pident_2 = other.pident_2->clone(); pident_2 = other.pident_2->clone();
classblock_ = other.classblock_->clone(); classblock_ = other.classblock_->clone();
} }
ClassDefE &ClassDefE::operator=(const ClassDefE & other) ClassDefE &ClassDefE::operator=(const ClassDefE & other)
{ {
ClassDefE tmp(other); ClassDefE tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ClassDefE::swap(ClassDefE & other) void ClassDefE::swap(ClassDefE & other)
{ {
std::swap(pident_1, other.pident_1); std::swap(pident_1, other.pident_1);
std::swap(pident_2, other.pident_2); std::swap(pident_2, other.pident_2);
std::swap(classblock_, other.classblock_); std::swap(classblock_, other.classblock_);
} }
ClassDefE::~ClassDefE() ClassDefE::~ClassDefE()
{ {
delete(pident_1); delete(pident_1);
delete(pident_2); delete(pident_2);
delete(classblock_); delete(classblock_);
} }
void ClassDefE::accept(Visitor *v) void ClassDefE::accept(Visitor *v)
{ {
v->visitClassDefE(this); v->visitClassDefE(this);
} }
ClassDefE *ClassDefE::clone() const ClassDefE *ClassDefE::clone() const
{ {
return new ClassDefE(*this); return new ClassDefE(*this);
} }
...@@ -389,43 +389,43 @@ ClassDefE *ClassDefE::clone() const ...@@ -389,43 +389,43 @@ ClassDefE *ClassDefE::clone() const
/******************** ClassBl ********************/ /******************** ClassBl ********************/
ClassBl::ClassBl(ListClassBlockDef *p1) ClassBl::ClassBl(ListClassBlockDef *p1)
{ {
listclassblockdef_ = p1; listclassblockdef_ = p1;
} }
ClassBl::ClassBl(const ClassBl & other) ClassBl::ClassBl(const ClassBl & other)
{ {
listclassblockdef_ = other.listclassblockdef_->clone(); listclassblockdef_ = other.listclassblockdef_->clone();
} }
ClassBl &ClassBl::operator=(const ClassBl & other) ClassBl &ClassBl::operator=(const ClassBl & other)
{ {
ClassBl tmp(other); ClassBl tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ClassBl::swap(ClassBl & other) void ClassBl::swap(ClassBl & other)
{ {
std::swap(listclassblockdef_, other.listclassblockdef_); std::swap(listclassblockdef_, other.listclassblockdef_);
} }
ClassBl::~ClassBl() ClassBl::~ClassBl()
{ {
delete(listclassblockdef_); delete(listclassblockdef_);
} }
void ClassBl::accept(Visitor *v) void ClassBl::accept(Visitor *v)
{ {
v->visitClassBl(this); v->visitClassBl(this);
} }
ClassBl *ClassBl::clone() const ClassBl *ClassBl::clone() const
{ {
return new ClassBl(*this); return new ClassBl(*this);
} }
...@@ -433,43 +433,43 @@ ClassBl *ClassBl::clone() const ...@@ -433,43 +433,43 @@ ClassBl *ClassBl::clone() const
/******************** ClassMthd ********************/ /******************** ClassMthd ********************/
ClassMthd::ClassMthd(FunDef *p1) ClassMthd::ClassMthd(FunDef *p1)
{ {
fundef_ = p1; fundef_ = p1;
} }
ClassMthd::ClassMthd(const ClassMthd & other) ClassMthd::ClassMthd(const ClassMthd & other)
{ {
fundef_ = other.fundef_->clone(); fundef_ = other.fundef_->clone();
} }
ClassMthd &ClassMthd::operator=(const ClassMthd & other) ClassMthd &ClassMthd::operator=(const ClassMthd & other)
{ {
ClassMthd tmp(other); ClassMthd tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ClassMthd::swap(ClassMthd & other) void ClassMthd::swap(ClassMthd & other)
{ {
std::swap(fundef_, other.fundef_); std::swap(fundef_, other.fundef_);
} }
ClassMthd::~ClassMthd() ClassMthd::~ClassMthd()
{ {
delete(fundef_); delete(fundef_);
} }
void ClassMthd::accept(Visitor *v) void ClassMthd::accept(Visitor *v)
{ {
v->visitClassMthd(this); v->visitClassMthd(this);
} }
ClassMthd *ClassMthd::clone() const ClassMthd *ClassMthd::clone() const
{ {
return new ClassMthd(*this); return new ClassMthd(*this);
} }
...@@ -477,47 +477,47 @@ ClassMthd *ClassMthd::clone() const ...@@ -477,47 +477,47 @@ ClassMthd *ClassMthd::clone() const
/******************** ClassFld ********************/ /******************** ClassFld ********************/
ClassFld::ClassFld(Type *p1, ListItem *p2) ClassFld::ClassFld(Type *p1, ListItem *p2)
{ {
type_ = p1; type_ = p1;
listitem_ = p2; listitem_ = p2;
} }
ClassFld::ClassFld(const ClassFld & other) ClassFld::ClassFld(const ClassFld & other)
{ {
type_ = other.type_->clone(); type_ = other.type_->clone();
listitem_ = other.listitem_->clone(); listitem_ = other.listitem_->clone();
} }
ClassFld &ClassFld::operator=(const ClassFld & other) ClassFld &ClassFld::operator=(const ClassFld & other)
{ {
ClassFld tmp(other); ClassFld tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ClassFld::swap(ClassFld & other) void ClassFld::swap(ClassFld & other)
{ {
std::swap(type_, other.type_); std::swap(type_, other.type_);
std::swap(listitem_, other.listitem_); std::swap(listitem_, other.listitem_);
} }
ClassFld::~ClassFld() ClassFld::~ClassFld()
{ {
delete(type_); delete(type_);
delete(listitem_); delete(listitem_);
} }
void ClassFld::accept(Visitor *v) void ClassFld::accept(Visitor *v)
{ {
v->visitClassFld(this); v->visitClassFld(this);
} }
ClassFld *ClassFld::clone() const ClassFld *ClassFld::clone() const
{ {
return new ClassFld(*this); return new ClassFld(*this);
} }
...@@ -525,43 +525,43 @@ ClassFld *ClassFld::clone() const ...@@ -525,43 +525,43 @@ ClassFld *ClassFld::clone() const
/******************** Blk ********************/ /******************** Blk ********************/
Blk::Blk(ListStmt *p1) Blk::Blk(ListStmt *p1)
{ {
liststmt_ = p1; liststmt_ = p1;
} }
Blk::Blk(const Blk & other) Blk::Blk(const Blk & other)
{ {
liststmt_ = other.liststmt_->clone(); liststmt_ = other.liststmt_->clone();
} }
Blk &Blk::operator=(const Blk & other) Blk &Blk::operator=(const Blk & other)
{ {
Blk tmp(other); Blk tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Blk::swap(Blk & other) void Blk::swap(Blk & other)
{ {
std::swap(liststmt_, other.liststmt_); std::swap(liststmt_, other.liststmt_);
} }
Blk::~Blk() Blk::~Blk()
{ {
delete(liststmt_); delete(liststmt_);
} }
void Blk::accept(Visitor *v) void Blk::accept(Visitor *v)
{ {
v->visitBlk(this); v->visitBlk(this);
} }
Blk *Blk::clone() const Blk *Blk::clone() const
{ {
return new Blk(*this); return new Blk(*this);
} }
...@@ -579,9 +579,9 @@ Empty::Empty(const Empty & other) ...@@ -579,9 +579,9 @@ Empty::Empty(const Empty & other)
Empty &Empty::operator=(const Empty & other) Empty &Empty::operator=(const Empty & other)
{ {
Empty tmp(other); Empty tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Empty::swap(Empty & other) void Empty::swap(Empty & other)
...@@ -596,12 +596,12 @@ Empty::~Empty() ...@@ -596,12 +596,12 @@ Empty::~Empty()
void Empty::accept(Visitor *v) void Empty::accept(Visitor *v)
{ {
v->visitEmpty(this); v->visitEmpty(this);
} }
Empty *Empty::clone() const Empty *Empty::clone() const
{ {
return new Empty(*this); return new Empty(*this);
} }
...@@ -609,43 +609,43 @@ Empty *Empty::clone() const ...@@ -609,43 +609,43 @@ Empty *Empty::clone() const
/******************** BStmt ********************/ /******************** BStmt ********************/
BStmt::BStmt(Block *p1) BStmt::BStmt(Block *p1)
{ {
block_ = p1; block_ = p1;
} }
BStmt::BStmt(const BStmt & other) BStmt::BStmt(const BStmt & other)
{ {
block_ = other.block_->clone(); block_ = other.block_->clone();
} }
BStmt &BStmt::operator=(const BStmt & other) BStmt &BStmt::operator=(const BStmt & other)
{ {
BStmt tmp(other); BStmt tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void BStmt::swap(BStmt & other) void BStmt::swap(BStmt & other)
{ {
std::swap(block_, other.block_); std::swap(block_, other.block_);
} }
BStmt::~BStmt() BStmt::~BStmt()
{ {
delete(block_); delete(block_);
} }
void BStmt::accept(Visitor *v) void BStmt::accept(Visitor *v)
{ {
v->visitBStmt(this); v->visitBStmt(this);
} }
BStmt *BStmt::clone() const BStmt *BStmt::clone() const
{ {
return new BStmt(*this); return new BStmt(*this);
} }
...@@ -653,47 +653,47 @@ BStmt *BStmt::clone() const ...@@ -653,47 +653,47 @@ BStmt *BStmt::clone() const
/******************** Decl ********************/ /******************** Decl ********************/
Decl::Decl(Type *p1, ListItem *p2) Decl::Decl(Type *p1, ListItem *p2)
{ {
type_ = p1; type_ = p1;
listitem_ = p2; listitem_ = p2;
} }
Decl::Decl(const Decl & other) Decl::Decl(const Decl & other)
{ {
type_ = other.type_->clone(); type_ = other.type_->clone();
listitem_ = other.listitem_->clone(); listitem_ = other.listitem_->clone();
} }
Decl &Decl::operator=(const Decl & other) Decl &Decl::operator=(const Decl & other)
{ {
Decl tmp(other); Decl tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Decl::swap(Decl & other) void Decl::swap(Decl & other)
{ {
std::swap(type_, other.type_); std::swap(type_, other.type_);
std::swap(listitem_, other.listitem_); std::swap(listitem_, other.listitem_);
} }
Decl::~Decl() Decl::~Decl()
{ {
delete(type_); delete(type_);
delete(listitem_); delete(listitem_);
} }
void Decl::accept(Visitor *v) void Decl::accept(Visitor *v)
{ {
v->visitDecl(this); v->visitDecl(this);
} }
Decl *Decl::clone() const Decl *Decl::clone() const
{ {
return new Decl(*this); return new Decl(*this);
} }
...@@ -701,47 +701,47 @@ Decl *Decl::clone() const ...@@ -701,47 +701,47 @@ Decl *Decl::clone() const
/******************** Ass ********************/ /******************** Ass ********************/
Ass::Ass(Expr *p1, Expr *p2) Ass::Ass(Expr *p1, Expr *p2)
{ {
expr_1 = p1; expr_1 = p1;
expr_2 = p2; expr_2 = p2;
} }
Ass::Ass(const Ass & other) Ass::Ass(const Ass & other)
{ {
expr_1 = other.expr_1->clone(); expr_1 = other.expr_1->clone();
expr_2 = other.expr_2->clone(); expr_2 = other.expr_2->clone();
} }
Ass &Ass::operator=(const Ass & other) Ass &Ass::operator=(const Ass & other)
{ {
Ass tmp(other); Ass tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Ass::swap(Ass & other) void Ass::swap(Ass & other)
{ {
std::swap(expr_1, other.expr_1); std::swap(expr_1, other.expr_1);
std::swap(expr_2, other.expr_2); std::swap(expr_2, other.expr_2);
} }
Ass::~Ass() Ass::~Ass()
{ {
delete(expr_1); delete(expr_1);
delete(expr_2); delete(expr_2);
} }
void Ass::accept(Visitor *v) void Ass::accept(Visitor *v)
{ {
v->visitAss(this); v->visitAss(this);
} }
Ass *Ass::clone() const Ass *Ass::clone() const
{ {
return new Ass(*this); return new Ass(*this);
} }
...@@ -749,51 +749,51 @@ Ass *Ass::clone() const ...@@ -749,51 +749,51 @@ Ass *Ass::clone() const
/******************** TableAss ********************/ /******************** TableAss ********************/
TableAss::TableAss(PIdent *p1, Expr *p2, Expr *p3) TableAss::TableAss(PIdent *p1, Expr *p2, Expr *p3)
{ {
pident_ = p1; pident_ = p1;
expr_1 = p2; expr_1 = p2;
expr_2 = p3; expr_2 = p3;
} }
TableAss::TableAss(const TableAss & other) TableAss::TableAss(const TableAss & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
expr_1 = other.expr_1->clone(); expr_1 = other.expr_1->clone();
expr_2 = other.expr_2->clone(); expr_2 = other.expr_2->clone();
} }
TableAss &TableAss::operator=(const TableAss & other) TableAss &TableAss::operator=(const TableAss & other)
{ {
TableAss tmp(other); TableAss tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void TableAss::swap(TableAss & other) void TableAss::swap(TableAss & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
std::swap(expr_1, other.expr_1); std::swap(expr_1, other.expr_1);
std::swap(expr_2, other.expr_2); std::swap(expr_2, other.expr_2);
} }
TableAss::~TableAss() TableAss::~TableAss()
{ {
delete(pident_); delete(pident_);
delete(expr_1); delete(expr_1);
delete(expr_2); delete(expr_2);
} }
void TableAss::accept(Visitor *v) void TableAss::accept(Visitor *v)
{ {
v->visitTableAss(this); v->visitTableAss(this);
} }
TableAss *TableAss::clone() const TableAss *TableAss::clone() const
{ {
return new TableAss(*this); return new TableAss(*this);
} }
...@@ -801,47 +801,47 @@ TableAss *TableAss::clone() const ...@@ -801,47 +801,47 @@ TableAss *TableAss::clone() const
/******************** TableIncr ********************/ /******************** TableIncr ********************/
TableIncr::TableIncr(PIdent *p1, Expr *p2) TableIncr::TableIncr(PIdent *p1, Expr *p2)
{ {
pident_ = p1; pident_ = p1;
expr_ = p2; expr_ = p2;
} }
TableIncr::TableIncr(const TableIncr & other) TableIncr::TableIncr(const TableIncr & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
} }
TableIncr &TableIncr::operator=(const TableIncr & other) TableIncr &TableIncr::operator=(const TableIncr & other)
{ {
TableIncr tmp(other); TableIncr tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void TableIncr::swap(TableIncr & other) void TableIncr::swap(TableIncr & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
} }
TableIncr::~TableIncr() TableIncr::~TableIncr()
{ {
delete(pident_); delete(pident_);
delete(expr_); delete(expr_);
} }
void TableIncr::accept(Visitor *v) void TableIncr::accept(Visitor *v)
{ {
v->visitTableIncr(this); v->visitTableIncr(this);
} }
TableIncr *TableIncr::clone() const TableIncr *TableIncr::clone() const
{ {
return new TableIncr(*this); return new TableIncr(*this);
} }
...@@ -849,47 +849,47 @@ TableIncr *TableIncr::clone() const ...@@ -849,47 +849,47 @@ TableIncr *TableIncr::clone() const
/******************** TableDecr ********************/ /******************** TableDecr ********************/
TableDecr::TableDecr(PIdent *p1, Expr *p2) TableDecr::TableDecr(PIdent *p1, Expr *p2)
{ {
pident_ = p1; pident_ = p1;
expr_ = p2; expr_ = p2;
} }
TableDecr::TableDecr(const TableDecr & other) TableDecr::TableDecr(const TableDecr & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
} }
TableDecr &TableDecr::operator=(const TableDecr & other) TableDecr &TableDecr::operator=(const TableDecr & other)
{ {
TableDecr tmp(other); TableDecr tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void TableDecr::swap(TableDecr & other) void TableDecr::swap(TableDecr & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
} }
TableDecr::~TableDecr() TableDecr::~TableDecr()
{ {
delete(pident_); delete(pident_);
delete(expr_); delete(expr_);
} }
void TableDecr::accept(Visitor *v) void TableDecr::accept(Visitor *v)
{ {
v->visitTableDecr(this); v->visitTableDecr(this);
} }
TableDecr *TableDecr::clone() const TableDecr *TableDecr::clone() const
{ {
return new TableDecr(*this); return new TableDecr(*this);
} }
...@@ -897,43 +897,43 @@ TableDecr *TableDecr::clone() const ...@@ -897,43 +897,43 @@ TableDecr *TableDecr::clone() const
/******************** Incr ********************/ /******************** Incr ********************/
Incr::Incr(PIdent *p1) Incr::Incr(PIdent *p1)
{ {
pident_ = p1; pident_ = p1;
} }
Incr::Incr(const Incr & other) Incr::Incr(const Incr & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
} }
Incr &Incr::operator=(const Incr & other) Incr &Incr::operator=(const Incr & other)
{ {
Incr tmp(other); Incr tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Incr::swap(Incr & other) void Incr::swap(Incr & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
} }
Incr::~Incr() Incr::~Incr()
{ {
delete(pident_); delete(pident_);
} }
void Incr::accept(Visitor *v) void Incr::accept(Visitor *v)
{ {
v->visitIncr(this); v->visitIncr(this);
} }
Incr *Incr::clone() const Incr *Incr::clone() const
{ {
return new Incr(*this); return new Incr(*this);
} }
...@@ -941,43 +941,43 @@ Incr *Incr::clone() const ...@@ -941,43 +941,43 @@ Incr *Incr::clone() const
/******************** Decr ********************/ /******************** Decr ********************/
Decr::Decr(PIdent *p1) Decr::Decr(PIdent *p1)
{ {
pident_ = p1; pident_ = p1;
} }
Decr::Decr(const Decr & other) Decr::Decr(const Decr & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
} }
Decr &Decr::operator=(const Decr & other) Decr &Decr::operator=(const Decr & other)
{ {
Decr tmp(other); Decr tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Decr::swap(Decr & other) void Decr::swap(Decr & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
} }
Decr::~Decr() Decr::~Decr()
{ {
delete(pident_); delete(pident_);
} }
void Decr::accept(Visitor *v) void Decr::accept(Visitor *v)
{ {
v->visitDecr(this); v->visitDecr(this);
} }
Decr *Decr::clone() const Decr *Decr::clone() const
{ {
return new Decr(*this); return new Decr(*this);
} }
...@@ -985,43 +985,43 @@ Decr *Decr::clone() const ...@@ -985,43 +985,43 @@ Decr *Decr::clone() const
/******************** Ret ********************/ /******************** Ret ********************/
Ret::Ret(Expr *p1) Ret::Ret(Expr *p1)
{ {
expr_ = p1; expr_ = p1;
} }
Ret::Ret(const Ret & other) Ret::Ret(const Ret & other)
{ {
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
} }
Ret &Ret::operator=(const Ret & other) Ret &Ret::operator=(const Ret & other)
{ {
Ret tmp(other); Ret tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Ret::swap(Ret & other) void Ret::swap(Ret & other)
{ {
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
} }
Ret::~Ret() Ret::~Ret()
{ {
delete(expr_); delete(expr_);
} }
void Ret::accept(Visitor *v) void Ret::accept(Visitor *v)
{ {
v->visitRet(this); v->visitRet(this);
} }
Ret *Ret::clone() const Ret *Ret::clone() const
{ {
return new Ret(*this); return new Ret(*this);
} }
...@@ -1039,9 +1039,9 @@ VRet::VRet(const VRet & other) ...@@ -1039,9 +1039,9 @@ VRet::VRet(const VRet & other)
VRet &VRet::operator=(const VRet & other) VRet &VRet::operator=(const VRet & other)
{ {
VRet tmp(other); VRet tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void VRet::swap(VRet & other) void VRet::swap(VRet & other)
...@@ -1056,12 +1056,12 @@ VRet::~VRet() ...@@ -1056,12 +1056,12 @@ VRet::~VRet()
void VRet::accept(Visitor *v) void VRet::accept(Visitor *v)
{ {
v->visitVRet(this); v->visitVRet(this);
} }
VRet *VRet::clone() const VRet *VRet::clone() const
{ {
return new VRet(*this); return new VRet(*this);
} }
...@@ -1069,47 +1069,47 @@ VRet *VRet::clone() const ...@@ -1069,47 +1069,47 @@ VRet *VRet::clone() const
/******************** Cond ********************/ /******************** Cond ********************/
Cond::Cond(Expr *p1, Stmt *p2) Cond::Cond(Expr *p1, Stmt *p2)
{ {
expr_ = p1; expr_ = p1;
stmt_ = p2; stmt_ = p2;
} }
Cond::Cond(const Cond & other) Cond::Cond(const Cond & other)
{ {
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
stmt_ = other.stmt_->clone(); stmt_ = other.stmt_->clone();
} }
Cond &Cond::operator=(const Cond & other) Cond &Cond::operator=(const Cond & other)
{ {
Cond tmp(other); Cond tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Cond::swap(Cond & other) void Cond::swap(Cond & other)
{ {
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
std::swap(stmt_, other.stmt_); std::swap(stmt_, other.stmt_);
} }
Cond::~Cond() Cond::~Cond()
{ {
delete(expr_); delete(expr_);
delete(stmt_); delete(stmt_);
} }
void Cond::accept(Visitor *v) void Cond::accept(Visitor *v)
{ {
v->visitCond(this); v->visitCond(this);
} }
Cond *Cond::clone() const Cond *Cond::clone() const
{ {
return new Cond(*this); return new Cond(*this);
} }
...@@ -1117,51 +1117,51 @@ Cond *Cond::clone() const ...@@ -1117,51 +1117,51 @@ Cond *Cond::clone() const
/******************** CondElse ********************/ /******************** CondElse ********************/
CondElse::CondElse(Expr *p1, Stmt *p2, Stmt *p3) CondElse::CondElse(Expr *p1, Stmt *p2, Stmt *p3)
{ {
expr_ = p1; expr_ = p1;
stmt_1 = p2; stmt_1 = p2;
stmt_2 = p3; stmt_2 = p3;
} }
CondElse::CondElse(const CondElse & other) CondElse::CondElse(const CondElse & other)
{ {
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
stmt_1 = other.stmt_1->clone(); stmt_1 = other.stmt_1->clone();
stmt_2 = other.stmt_2->clone(); stmt_2 = other.stmt_2->clone();
} }
CondElse &CondElse::operator=(const CondElse & other) CondElse &CondElse::operator=(const CondElse & other)
{ {
CondElse tmp(other); CondElse tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void CondElse::swap(CondElse & other) void CondElse::swap(CondElse & other)
{ {
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
std::swap(stmt_1, other.stmt_1); std::swap(stmt_1, other.stmt_1);
std::swap(stmt_2, other.stmt_2); std::swap(stmt_2, other.stmt_2);
} }
CondElse::~CondElse() CondElse::~CondElse()
{ {
delete(expr_); delete(expr_);
delete(stmt_1); delete(stmt_1);
delete(stmt_2); delete(stmt_2);
} }
void CondElse::accept(Visitor *v) void CondElse::accept(Visitor *v)
{ {
v->visitCondElse(this); v->visitCondElse(this);
} }
CondElse *CondElse::clone() const CondElse *CondElse::clone() const
{ {
return new CondElse(*this); return new CondElse(*this);
} }
...@@ -1169,47 +1169,47 @@ CondElse *CondElse::clone() const ...@@ -1169,47 +1169,47 @@ CondElse *CondElse::clone() const
/******************** While ********************/ /******************** While ********************/
While::While(Expr *p1, Stmt *p2) While::While(Expr *p1, Stmt *p2)
{ {
expr_ = p1; expr_ = p1;
stmt_ = p2; stmt_ = p2;
} }
While::While(const While & other) While::While(const While & other)
{ {
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
stmt_ = other.stmt_->clone(); stmt_ = other.stmt_->clone();
} }
While &While::operator=(const While & other) While &While::operator=(const While & other)
{ {
While tmp(other); While tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void While::swap(While & other) void While::swap(While & other)
{ {
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
std::swap(stmt_, other.stmt_); std::swap(stmt_, other.stmt_);
} }
While::~While() While::~While()
{ {
delete(expr_); delete(expr_);
delete(stmt_); delete(stmt_);
} }
void While::accept(Visitor *v) void While::accept(Visitor *v)
{ {
v->visitWhile(this); v->visitWhile(this);
} }
While *While::clone() const While *While::clone() const
{ {
return new While(*this); return new While(*this);
} }
...@@ -1217,43 +1217,43 @@ While *While::clone() const ...@@ -1217,43 +1217,43 @@ While *While::clone() const
/******************** SExp ********************/ /******************** SExp ********************/
SExp::SExp(Expr *p1) SExp::SExp(Expr *p1)
{ {
expr_ = p1; expr_ = p1;
} }
SExp::SExp(const SExp & other) SExp::SExp(const SExp & other)
{ {
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
} }
SExp &SExp::operator=(const SExp & other) SExp &SExp::operator=(const SExp & other)
{ {
SExp tmp(other); SExp tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void SExp::swap(SExp & other) void SExp::swap(SExp & other)
{ {
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
} }
SExp::~SExp() SExp::~SExp()
{ {
delete(expr_); delete(expr_);
} }
void SExp::accept(Visitor *v) void SExp::accept(Visitor *v)
{ {
v->visitSExp(this); v->visitSExp(this);
} }
SExp *SExp::clone() const SExp *SExp::clone() const
{ {
return new SExp(*this); return new SExp(*this);
} }
...@@ -1261,55 +1261,55 @@ SExp *SExp::clone() const ...@@ -1261,55 +1261,55 @@ SExp *SExp::clone() const
/******************** ForEach ********************/ /******************** ForEach ********************/
ForEach::ForEach(Type *p1, PIdent *p2, Expr *p3, Stmt *p4) ForEach::ForEach(Type *p1, PIdent *p2, Expr *p3, Stmt *p4)
{ {
type_ = p1; type_ = p1;
pident_ = p2; pident_ = p2;
expr_ = p3; expr_ = p3;
stmt_ = p4; stmt_ = p4;
} }
ForEach::ForEach(const ForEach & other) ForEach::ForEach(const ForEach & other)
{ {
type_ = other.type_->clone(); type_ = other.type_->clone();
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
stmt_ = other.stmt_->clone(); stmt_ = other.stmt_->clone();
} }
ForEach &ForEach::operator=(const ForEach & other) ForEach &ForEach::operator=(const ForEach & other)
{ {
ForEach tmp(other); ForEach tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ForEach::swap(ForEach & other) void ForEach::swap(ForEach & other)
{ {
std::swap(type_, other.type_); std::swap(type_, other.type_);
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
std::swap(stmt_, other.stmt_); std::swap(stmt_, other.stmt_);
} }
ForEach::~ForEach() ForEach::~ForEach()
{ {
delete(type_); delete(type_);
delete(pident_); delete(pident_);
delete(expr_); delete(expr_);
delete(stmt_); delete(stmt_);
} }
void ForEach::accept(Visitor *v) void ForEach::accept(Visitor *v)
{ {
v->visitForEach(this); v->visitForEach(this);
} }
ForEach *ForEach::clone() const ForEach *ForEach::clone() const
{ {
return new ForEach(*this); return new ForEach(*this);
} }
...@@ -1317,43 +1317,43 @@ ForEach *ForEach::clone() const ...@@ -1317,43 +1317,43 @@ ForEach *ForEach::clone() const
/******************** NoInit ********************/ /******************** NoInit ********************/
NoInit::NoInit(PIdent *p1) NoInit::NoInit(PIdent *p1)
{ {
pident_ = p1; pident_ = p1;
} }
NoInit::NoInit(const NoInit & other) NoInit::NoInit(const NoInit & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
} }
NoInit &NoInit::operator=(const NoInit & other) NoInit &NoInit::operator=(const NoInit & other)
{ {
NoInit tmp(other); NoInit tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void NoInit::swap(NoInit & other) void NoInit::swap(NoInit & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
} }
NoInit::~NoInit() NoInit::~NoInit()
{ {
delete(pident_); delete(pident_);
} }
void NoInit::accept(Visitor *v) void NoInit::accept(Visitor *v)
{ {
v->visitNoInit(this); v->visitNoInit(this);
} }
NoInit *NoInit::clone() const NoInit *NoInit::clone() const
{ {
return new NoInit(*this); return new NoInit(*this);
} }
...@@ -1361,47 +1361,47 @@ NoInit *NoInit::clone() const ...@@ -1361,47 +1361,47 @@ NoInit *NoInit::clone() const
/******************** Init ********************/ /******************** Init ********************/
Init::Init(PIdent *p1, Expr *p2) Init::Init(PIdent *p1, Expr *p2)
{ {
pident_ = p1; pident_ = p1;
expr_ = p2; expr_ = p2;
} }
Init::Init(const Init & other) Init::Init(const Init & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
} }
Init &Init::operator=(const Init & other) Init &Init::operator=(const Init & other)
{ {
Init tmp(other); Init tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Init::swap(Init & other) void Init::swap(Init & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
} }
Init::~Init() Init::~Init()
{ {
delete(pident_); delete(pident_);
delete(expr_); delete(expr_);
} }
void Init::accept(Visitor *v) void Init::accept(Visitor *v)
{ {
v->visitInit(this); v->visitInit(this);
} }
Init *Init::clone() const Init *Init::clone() const
{ {
return new Init(*this); return new Init(*this);
} }
...@@ -1419,9 +1419,9 @@ Int::Int(const Int & other) ...@@ -1419,9 +1419,9 @@ Int::Int(const Int & other)
Int &Int::operator=(const Int & other) Int &Int::operator=(const Int & other)
{ {
Int tmp(other); Int tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Int::swap(Int & other) void Int::swap(Int & other)
...@@ -1436,12 +1436,12 @@ Int::~Int() ...@@ -1436,12 +1436,12 @@ Int::~Int()
void Int::accept(Visitor *v) void Int::accept(Visitor *v)
{ {
v->visitInt(this); v->visitInt(this);
} }
Int *Int::clone() const Int *Int::clone() const
{ {
return new Int(*this); return new Int(*this);
} }
...@@ -1459,9 +1459,9 @@ Str::Str(const Str & other) ...@@ -1459,9 +1459,9 @@ Str::Str(const Str & other)
Str &Str::operator=(const Str & other) Str &Str::operator=(const Str & other)
{ {
Str tmp(other); Str tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Str::swap(Str & other) void Str::swap(Str & other)
...@@ -1476,12 +1476,12 @@ Str::~Str() ...@@ -1476,12 +1476,12 @@ Str::~Str()
void Str::accept(Visitor *v) void Str::accept(Visitor *v)
{ {
v->visitStr(this); v->visitStr(this);
} }
Str *Str::clone() const Str *Str::clone() const
{ {
return new Str(*this); return new Str(*this);
} }
...@@ -1499,9 +1499,9 @@ Bool::Bool(const Bool & other) ...@@ -1499,9 +1499,9 @@ Bool::Bool(const Bool & other)
Bool &Bool::operator=(const Bool & other) Bool &Bool::operator=(const Bool & other)
{ {
Bool tmp(other); Bool tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Bool::swap(Bool & other) void Bool::swap(Bool & other)
...@@ -1516,12 +1516,12 @@ Bool::~Bool() ...@@ -1516,12 +1516,12 @@ Bool::~Bool()
void Bool::accept(Visitor *v) void Bool::accept(Visitor *v)
{ {
v->visitBool(this); v->visitBool(this);
} }
Bool *Bool::clone() const Bool *Bool::clone() const
{ {
return new Bool(*this); return new Bool(*this);
} }
...@@ -1539,9 +1539,9 @@ Void::Void(const Void & other) ...@@ -1539,9 +1539,9 @@ Void::Void(const Void & other)
Void &Void::operator=(const Void & other) Void &Void::operator=(const Void & other)
{ {
Void tmp(other); Void tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Void::swap(Void & other) void Void::swap(Void & other)
...@@ -1556,12 +1556,12 @@ Void::~Void() ...@@ -1556,12 +1556,12 @@ Void::~Void()
void Void::accept(Visitor *v) void Void::accept(Visitor *v)
{ {
v->visitVoid(this); v->visitVoid(this);
} }
Void *Void::clone() const Void *Void::clone() const
{ {
return new Void(*this); return new Void(*this);
} }
...@@ -1569,43 +1569,43 @@ Void *Void::clone() const ...@@ -1569,43 +1569,43 @@ Void *Void::clone() const
/******************** Array ********************/ /******************** Array ********************/
Array::Array(Type *p1) Array::Array(Type *p1)
{ {
type_ = p1; type_ = p1;
} }
Array::Array(const Array & other) Array::Array(const Array & other)
{ {
type_ = other.type_->clone(); type_ = other.type_->clone();
} }
Array &Array::operator=(const Array & other) Array &Array::operator=(const Array & other)
{ {
Array tmp(other); Array tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Array::swap(Array & other) void Array::swap(Array & other)
{ {
std::swap(type_, other.type_); std::swap(type_, other.type_);
} }
Array::~Array() Array::~Array()
{ {
delete(type_); delete(type_);
} }
void Array::accept(Visitor *v) void Array::accept(Visitor *v)
{ {
v->visitArray(this); v->visitArray(this);
} }
Array *Array::clone() const Array *Array::clone() const
{ {
return new Array(*this); return new Array(*this);
} }
...@@ -1613,43 +1613,43 @@ Array *Array::clone() const ...@@ -1613,43 +1613,43 @@ Array *Array::clone() const
/******************** ClassT ********************/ /******************** ClassT ********************/
ClassT::ClassT(PIdent *p1) ClassT::ClassT(PIdent *p1)
{ {
pident_ = p1; pident_ = p1;
} }
ClassT::ClassT(const ClassT & other) ClassT::ClassT(const ClassT & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
} }
ClassT &ClassT::operator=(const ClassT & other) ClassT &ClassT::operator=(const ClassT & other)
{ {
ClassT tmp(other); ClassT tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ClassT::swap(ClassT & other) void ClassT::swap(ClassT & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
} }
ClassT::~ClassT() ClassT::~ClassT()
{ {
delete(pident_); delete(pident_);
} }
void ClassT::accept(Visitor *v) void ClassT::accept(Visitor *v)
{ {
v->visitClassT(this); v->visitClassT(this);
} }
ClassT *ClassT::clone() const ClassT *ClassT::clone() const
{ {
return new ClassT(*this); return new ClassT(*this);
} }
...@@ -1657,47 +1657,47 @@ ClassT *ClassT::clone() const ...@@ -1657,47 +1657,47 @@ ClassT *ClassT::clone() const
/******************** Fun ********************/ /******************** Fun ********************/
Fun::Fun(Type *p1, ListType *p2) Fun::Fun(Type *p1, ListType *p2)
{ {
type_ = p1; type_ = p1;
listtype_ = p2; listtype_ = p2;
} }
Fun::Fun(const Fun & other) Fun::Fun(const Fun & other)
{ {
type_ = other.type_->clone(); type_ = other.type_->clone();
listtype_ = other.listtype_->clone(); listtype_ = other.listtype_->clone();
} }
Fun &Fun::operator=(const Fun & other) Fun &Fun::operator=(const Fun & other)
{ {
Fun tmp(other); Fun tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Fun::swap(Fun & other) void Fun::swap(Fun & other)
{ {
std::swap(type_, other.type_); std::swap(type_, other.type_);
std::swap(listtype_, other.listtype_); std::swap(listtype_, other.listtype_);
} }
Fun::~Fun() Fun::~Fun()
{ {
delete(type_); delete(type_);
delete(listtype_); delete(listtype_);
} }
void Fun::accept(Visitor *v) void Fun::accept(Visitor *v)
{ {
v->visitFun(this); v->visitFun(this);
} }
Fun *Fun::clone() const Fun *Fun::clone() const
{ {
return new Fun(*this); return new Fun(*this);
} }
...@@ -1705,43 +1705,43 @@ Fun *Fun::clone() const ...@@ -1705,43 +1705,43 @@ Fun *Fun::clone() const
/******************** EVar ********************/ /******************** EVar ********************/
EVar::EVar(PIdent *p1) EVar::EVar(PIdent *p1)
{ {
pident_ = p1; pident_ = p1;
} }
EVar::EVar(const EVar & other) EVar::EVar(const EVar & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
} }
EVar &EVar::operator=(const EVar & other) EVar &EVar::operator=(const EVar & other)
{ {
EVar tmp(other); EVar tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void EVar::swap(EVar & other) void EVar::swap(EVar & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
} }
EVar::~EVar() EVar::~EVar()
{ {
delete(pident_); delete(pident_);
} }
void EVar::accept(Visitor *v) void EVar::accept(Visitor *v)
{ {
v->visitEVar(this); v->visitEVar(this);
} }
EVar *EVar::clone() const EVar *EVar::clone() const
{ {
return new EVar(*this); return new EVar(*this);
} }
...@@ -1749,26 +1749,26 @@ EVar *EVar::clone() const ...@@ -1749,26 +1749,26 @@ EVar *EVar::clone() const
/******************** ELitInt ********************/ /******************** ELitInt ********************/
ELitInt::ELitInt(Integer p1) ELitInt::ELitInt(Integer p1)
{ {
integer_ = p1; integer_ = p1;
} }
ELitInt::ELitInt(const ELitInt & other) ELitInt::ELitInt(const ELitInt & other)
{ {
integer_ = other.integer_; integer_ = other.integer_;
} }
ELitInt &ELitInt::operator=(const ELitInt & other) ELitInt &ELitInt::operator=(const ELitInt & other)
{ {
ELitInt tmp(other); ELitInt tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ELitInt::swap(ELitInt & other) void ELitInt::swap(ELitInt & other)
{ {
std::swap(integer_, other.integer_); std::swap(integer_, other.integer_);
} }
...@@ -1779,12 +1779,12 @@ ELitInt::~ELitInt() ...@@ -1779,12 +1779,12 @@ ELitInt::~ELitInt()
void ELitInt::accept(Visitor *v) void ELitInt::accept(Visitor *v)
{ {
v->visitELitInt(this); v->visitELitInt(this);
} }
ELitInt *ELitInt::clone() const ELitInt *ELitInt::clone() const
{ {
return new ELitInt(*this); return new ELitInt(*this);
} }
...@@ -1802,9 +1802,9 @@ ELitTrue::ELitTrue(const ELitTrue & other) ...@@ -1802,9 +1802,9 @@ ELitTrue::ELitTrue(const ELitTrue & other)
ELitTrue &ELitTrue::operator=(const ELitTrue & other) ELitTrue &ELitTrue::operator=(const ELitTrue & other)
{ {
ELitTrue tmp(other); ELitTrue tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ELitTrue::swap(ELitTrue & other) void ELitTrue::swap(ELitTrue & other)
...@@ -1819,12 +1819,12 @@ ELitTrue::~ELitTrue() ...@@ -1819,12 +1819,12 @@ ELitTrue::~ELitTrue()
void ELitTrue::accept(Visitor *v) void ELitTrue::accept(Visitor *v)
{ {
v->visitELitTrue(this); v->visitELitTrue(this);
} }
ELitTrue *ELitTrue::clone() const ELitTrue *ELitTrue::clone() const
{ {
return new ELitTrue(*this); return new ELitTrue(*this);
} }
...@@ -1842,9 +1842,9 @@ ELitFalse::ELitFalse(const ELitFalse & other) ...@@ -1842,9 +1842,9 @@ ELitFalse::ELitFalse(const ELitFalse & other)
ELitFalse &ELitFalse::operator=(const ELitFalse & other) ELitFalse &ELitFalse::operator=(const ELitFalse & other)
{ {
ELitFalse tmp(other); ELitFalse tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ELitFalse::swap(ELitFalse & other) void ELitFalse::swap(ELitFalse & other)
...@@ -1859,12 +1859,12 @@ ELitFalse::~ELitFalse() ...@@ -1859,12 +1859,12 @@ ELitFalse::~ELitFalse()
void ELitFalse::accept(Visitor *v) void ELitFalse::accept(Visitor *v)
{ {
v->visitELitFalse(this); v->visitELitFalse(this);
} }
ELitFalse *ELitFalse::clone() const ELitFalse *ELitFalse::clone() const
{ {
return new ELitFalse(*this); return new ELitFalse(*this);
} }
...@@ -1872,47 +1872,47 @@ ELitFalse *ELitFalse::clone() const ...@@ -1872,47 +1872,47 @@ ELitFalse *ELitFalse::clone() const
/******************** EApp ********************/ /******************** EApp ********************/
EApp::EApp(PIdent *p1, ListExpr *p2) EApp::EApp(PIdent *p1, ListExpr *p2)
{ {
pident_ = p1; pident_ = p1;
listexpr_ = p2; listexpr_ = p2;
} }
EApp::EApp(const EApp & other) EApp::EApp(const EApp & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
listexpr_ = other.listexpr_->clone(); listexpr_ = other.listexpr_->clone();
} }
EApp &EApp::operator=(const EApp & other) EApp &EApp::operator=(const EApp & other)
{ {
EApp tmp(other); EApp tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void EApp::swap(EApp & other) void EApp::swap(EApp & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
std::swap(listexpr_, other.listexpr_); std::swap(listexpr_, other.listexpr_);
} }
EApp::~EApp() EApp::~EApp()
{ {
delete(pident_); delete(pident_);
delete(listexpr_); delete(listexpr_);
} }
void EApp::accept(Visitor *v) void EApp::accept(Visitor *v)
{ {
v->visitEApp(this); v->visitEApp(this);
} }
EApp *EApp::clone() const EApp *EApp::clone() const
{ {
return new EApp(*this); return new EApp(*this);
} }
...@@ -1920,26 +1920,26 @@ EApp *EApp::clone() const ...@@ -1920,26 +1920,26 @@ EApp *EApp::clone() const
/******************** EString ********************/ /******************** EString ********************/
EString::EString(String p1) EString::EString(String p1)
{ {
string_ = p1; string_ = p1;
} }
EString::EString(const EString & other) EString::EString(const EString & other)
{ {
string_ = other.string_; string_ = other.string_;
} }
EString &EString::operator=(const EString & other) EString &EString::operator=(const EString & other)
{ {
EString tmp(other); EString tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void EString::swap(EString & other) void EString::swap(EString & other)
{ {
std::swap(string_, other.string_); std::swap(string_, other.string_);
} }
...@@ -1950,12 +1950,12 @@ EString::~EString() ...@@ -1950,12 +1950,12 @@ EString::~EString()
void EString::accept(Visitor *v) void EString::accept(Visitor *v)
{ {
v->visitEString(this); v->visitEString(this);
} }
EString *EString::clone() const EString *EString::clone() const
{ {
return new EString(*this); return new EString(*this);
} }
...@@ -1963,47 +1963,47 @@ EString *EString::clone() const ...@@ -1963,47 +1963,47 @@ EString *EString::clone() const
/******************** ENewArray ********************/ /******************** ENewArray ********************/
ENewArray::ENewArray(Type *p1, Expr *p2) ENewArray::ENewArray(Type *p1, Expr *p2)
{ {
type_ = p1; type_ = p1;
expr_ = p2; expr_ = p2;
} }
ENewArray::ENewArray(const ENewArray & other) ENewArray::ENewArray(const ENewArray & other)
{ {
type_ = other.type_->clone(); type_ = other.type_->clone();
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
} }
ENewArray &ENewArray::operator=(const ENewArray & other) ENewArray &ENewArray::operator=(const ENewArray & other)
{ {
ENewArray tmp(other); ENewArray tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ENewArray::swap(ENewArray & other) void ENewArray::swap(ENewArray & other)
{ {
std::swap(type_, other.type_); std::swap(type_, other.type_);
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
} }
ENewArray::~ENewArray() ENewArray::~ENewArray()
{ {
delete(type_); delete(type_);
delete(expr_); delete(expr_);
} }
void ENewArray::accept(Visitor *v) void ENewArray::accept(Visitor *v)
{ {
v->visitENewArray(this); v->visitENewArray(this);
} }
ENewArray *ENewArray::clone() const ENewArray *ENewArray::clone() const
{ {
return new ENewArray(*this); return new ENewArray(*this);
} }
...@@ -2011,43 +2011,43 @@ ENewArray *ENewArray::clone() const ...@@ -2011,43 +2011,43 @@ ENewArray *ENewArray::clone() const
/******************** ENewClass ********************/ /******************** ENewClass ********************/
ENewClass::ENewClass(PIdent *p1) ENewClass::ENewClass(PIdent *p1)
{ {
pident_ = p1; pident_ = p1;
} }
ENewClass::ENewClass(const ENewClass & other) ENewClass::ENewClass(const ENewClass & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
} }
ENewClass &ENewClass::operator=(const ENewClass & other) ENewClass &ENewClass::operator=(const ENewClass & other)
{ {
ENewClass tmp(other); ENewClass tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ENewClass::swap(ENewClass & other) void ENewClass::swap(ENewClass & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
} }
ENewClass::~ENewClass() ENewClass::~ENewClass()
{ {
delete(pident_); delete(pident_);
} }
void ENewClass::accept(Visitor *v) void ENewClass::accept(Visitor *v)
{ {
v->visitENewClass(this); v->visitENewClass(this);
} }
ENewClass *ENewClass::clone() const ENewClass *ENewClass::clone() const
{ {
return new ENewClass(*this); return new ENewClass(*this);
} }
...@@ -2055,47 +2055,47 @@ ENewClass *ENewClass::clone() const ...@@ -2055,47 +2055,47 @@ ENewClass *ENewClass::clone() const
/******************** EClsMmbr ********************/ /******************** EClsMmbr ********************/
EClsMmbr::EClsMmbr(Expr *p1, PIdent *p2) EClsMmbr::EClsMmbr(Expr *p1, PIdent *p2)
{ {
expr_ = p1; expr_ = p1;
pident_ = p2; pident_ = p2;
} }
EClsMmbr::EClsMmbr(const EClsMmbr & other) EClsMmbr::EClsMmbr(const EClsMmbr & other)
{ {
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
} }
EClsMmbr &EClsMmbr::operator=(const EClsMmbr & other) EClsMmbr &EClsMmbr::operator=(const EClsMmbr & other)
{ {
EClsMmbr tmp(other); EClsMmbr tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void EClsMmbr::swap(EClsMmbr & other) void EClsMmbr::swap(EClsMmbr & other)
{ {
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
} }
EClsMmbr::~EClsMmbr() EClsMmbr::~EClsMmbr()
{ {
delete(expr_); delete(expr_);
delete(pident_); delete(pident_);
} }
void EClsMmbr::accept(Visitor *v) void EClsMmbr::accept(Visitor *v)
{ {
v->visitEClsMmbr(this); v->visitEClsMmbr(this);
} }
EClsMmbr *EClsMmbr::clone() const EClsMmbr *EClsMmbr::clone() const
{ {
return new EClsMmbr(*this); return new EClsMmbr(*this);
} }
...@@ -2103,51 +2103,51 @@ EClsMmbr *EClsMmbr::clone() const ...@@ -2103,51 +2103,51 @@ EClsMmbr *EClsMmbr::clone() const
/******************** EClsMthd ********************/ /******************** EClsMthd ********************/
EClsMthd::EClsMthd(Expr *p1, PIdent *p2, ListExpr *p3) EClsMthd::EClsMthd(Expr *p1, PIdent *p2, ListExpr *p3)
{ {
expr_ = p1; expr_ = p1;
pident_ = p2; pident_ = p2;
listexpr_ = p3; listexpr_ = p3;
} }
EClsMthd::EClsMthd(const EClsMthd & other) EClsMthd::EClsMthd(const EClsMthd & other)
{ {
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
listexpr_ = other.listexpr_->clone(); listexpr_ = other.listexpr_->clone();
} }
EClsMthd &EClsMthd::operator=(const EClsMthd & other) EClsMthd &EClsMthd::operator=(const EClsMthd & other)
{ {
EClsMthd tmp(other); EClsMthd tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void EClsMthd::swap(EClsMthd & other) void EClsMthd::swap(EClsMthd & other)
{ {
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
std::swap(listexpr_, other.listexpr_); std::swap(listexpr_, other.listexpr_);
} }
EClsMthd::~EClsMthd() EClsMthd::~EClsMthd()
{ {
delete(expr_); delete(expr_);
delete(pident_); delete(pident_);
delete(listexpr_); delete(listexpr_);
} }
void EClsMthd::accept(Visitor *v) void EClsMthd::accept(Visitor *v)
{ {
v->visitEClsMthd(this); v->visitEClsMthd(this);
} }
EClsMthd *EClsMthd::clone() const EClsMthd *EClsMthd::clone() const
{ {
return new EClsMthd(*this); return new EClsMthd(*this);
} }
...@@ -2165,9 +2165,9 @@ Null::Null(const Null & other) ...@@ -2165,9 +2165,9 @@ Null::Null(const Null & other)
Null &Null::operator=(const Null & other) Null &Null::operator=(const Null & other)
{ {
Null tmp(other); Null tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Null::swap(Null & other) void Null::swap(Null & other)
...@@ -2182,12 +2182,12 @@ Null::~Null() ...@@ -2182,12 +2182,12 @@ Null::~Null()
void Null::accept(Visitor *v) void Null::accept(Visitor *v)
{ {
v->visitNull(this); v->visitNull(this);
} }
Null *Null::clone() const Null *Null::clone() const
{ {
return new Null(*this); return new Null(*this);
} }
...@@ -2195,47 +2195,47 @@ Null *Null::clone() const ...@@ -2195,47 +2195,47 @@ Null *Null::clone() const
/******************** EIndexAcc ********************/ /******************** EIndexAcc ********************/
EIndexAcc::EIndexAcc(PIdent *p1, Expr *p2) EIndexAcc::EIndexAcc(PIdent *p1, Expr *p2)
{ {
pident_ = p1; pident_ = p1;
expr_ = p2; expr_ = p2;
} }
EIndexAcc::EIndexAcc(const EIndexAcc & other) EIndexAcc::EIndexAcc(const EIndexAcc & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
} }
EIndexAcc &EIndexAcc::operator=(const EIndexAcc & other) EIndexAcc &EIndexAcc::operator=(const EIndexAcc & other)
{ {
EIndexAcc tmp(other); EIndexAcc tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void EIndexAcc::swap(EIndexAcc & other) void EIndexAcc::swap(EIndexAcc & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
} }
EIndexAcc::~EIndexAcc() EIndexAcc::~EIndexAcc()
{ {
delete(pident_); delete(pident_);
delete(expr_); delete(expr_);
} }
void EIndexAcc::accept(Visitor *v) void EIndexAcc::accept(Visitor *v)
{ {
v->visitEIndexAcc(this); v->visitEIndexAcc(this);
} }
EIndexAcc *EIndexAcc::clone() const EIndexAcc *EIndexAcc::clone() const
{ {
return new EIndexAcc(*this); return new EIndexAcc(*this);
} }
...@@ -2243,47 +2243,47 @@ EIndexAcc *EIndexAcc::clone() const ...@@ -2243,47 +2243,47 @@ EIndexAcc *EIndexAcc::clone() const
/******************** ECast ********************/ /******************** ECast ********************/
ECast::ECast(PIdent *p1, Expr *p2) ECast::ECast(PIdent *p1, Expr *p2)
{ {
pident_ = p1; pident_ = p1;
expr_ = p2; expr_ = p2;
} }
ECast::ECast(const ECast & other) ECast::ECast(const ECast & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
} }
ECast &ECast::operator=(const ECast & other) ECast &ECast::operator=(const ECast & other)
{ {
ECast tmp(other); ECast tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ECast::swap(ECast & other) void ECast::swap(ECast & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
} }
ECast::~ECast() ECast::~ECast()
{ {
delete(pident_); delete(pident_);
delete(expr_); delete(expr_);
} }
void ECast::accept(Visitor *v) void ECast::accept(Visitor *v)
{ {
v->visitECast(this); v->visitECast(this);
} }
ECast *ECast::clone() const ECast *ECast::clone() const
{ {
return new ECast(*this); return new ECast(*this);
} }
...@@ -2291,43 +2291,43 @@ ECast *ECast::clone() const ...@@ -2291,43 +2291,43 @@ ECast *ECast::clone() const
/******************** Neg ********************/ /******************** Neg ********************/
Neg::Neg(Expr *p1) Neg::Neg(Expr *p1)
{ {
expr_ = p1; expr_ = p1;
} }
Neg::Neg(const Neg & other) Neg::Neg(const Neg & other)
{ {
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
} }
Neg &Neg::operator=(const Neg & other) Neg &Neg::operator=(const Neg & other)
{ {
Neg tmp(other); Neg tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Neg::swap(Neg & other) void Neg::swap(Neg & other)
{ {
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
} }
Neg::~Neg() Neg::~Neg()
{ {
delete(expr_); delete(expr_);
} }
void Neg::accept(Visitor *v) void Neg::accept(Visitor *v)
{ {
v->visitNeg(this); v->visitNeg(this);
} }
Neg *Neg::clone() const Neg *Neg::clone() const
{ {
return new Neg(*this); return new Neg(*this);
} }
...@@ -2335,43 +2335,43 @@ Neg *Neg::clone() const ...@@ -2335,43 +2335,43 @@ Neg *Neg::clone() const
/******************** Not ********************/ /******************** Not ********************/
Not::Not(Expr *p1) Not::Not(Expr *p1)
{ {
expr_ = p1; expr_ = p1;
} }
Not::Not(const Not & other) Not::Not(const Not & other)
{ {
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
} }
Not &Not::operator=(const Not & other) Not &Not::operator=(const Not & other)
{ {
Not tmp(other); Not tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Not::swap(Not & other) void Not::swap(Not & other)
{ {
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
} }
Not::~Not() Not::~Not()
{ {
delete(expr_); delete(expr_);
} }
void Not::accept(Visitor *v) void Not::accept(Visitor *v)
{ {
v->visitNot(this); v->visitNot(this);
} }
Not *Not::clone() const Not *Not::clone() const
{ {
return new Not(*this); return new Not(*this);
} }
...@@ -2379,51 +2379,51 @@ Not *Not::clone() const ...@@ -2379,51 +2379,51 @@ Not *Not::clone() const
/******************** EMul ********************/ /******************** EMul ********************/
EMul::EMul(Expr *p1, MulOp *p2, Expr *p3) EMul::EMul(Expr *p1, MulOp *p2, Expr *p3)
{ {
expr_1 = p1; expr_1 = p1;
mulop_ = p2; mulop_ = p2;
expr_2 = p3; expr_2 = p3;
} }
EMul::EMul(const EMul & other) EMul::EMul(const EMul & other)
{ {
expr_1 = other.expr_1->clone(); expr_1 = other.expr_1->clone();
mulop_ = other.mulop_->clone(); mulop_ = other.mulop_->clone();
expr_2 = other.expr_2->clone(); expr_2 = other.expr_2->clone();
} }
EMul &EMul::operator=(const EMul & other) EMul &EMul::operator=(const EMul & other)
{ {
EMul tmp(other); EMul tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void EMul::swap(EMul & other) void EMul::swap(EMul & other)
{ {
std::swap(expr_1, other.expr_1); std::swap(expr_1, other.expr_1);
std::swap(mulop_, other.mulop_); std::swap(mulop_, other.mulop_);
std::swap(expr_2, other.expr_2); std::swap(expr_2, other.expr_2);
} }
EMul::~EMul() EMul::~EMul()
{ {
delete(expr_1); delete(expr_1);
delete(mulop_); delete(mulop_);
delete(expr_2); delete(expr_2);
} }
void EMul::accept(Visitor *v) void EMul::accept(Visitor *v)
{ {
v->visitEMul(this); v->visitEMul(this);
} }
EMul *EMul::clone() const EMul *EMul::clone() const
{ {
return new EMul(*this); return new EMul(*this);
} }
...@@ -2431,51 +2431,51 @@ EMul *EMul::clone() const ...@@ -2431,51 +2431,51 @@ EMul *EMul::clone() const
/******************** EAdd ********************/ /******************** EAdd ********************/
EAdd::EAdd(Expr *p1, AddOp *p2, Expr *p3) EAdd::EAdd(Expr *p1, AddOp *p2, Expr *p3)
{ {
expr_1 = p1; expr_1 = p1;
addop_ = p2; addop_ = p2;
expr_2 = p3; expr_2 = p3;
} }
EAdd::EAdd(const EAdd & other) EAdd::EAdd(const EAdd & other)
{ {
expr_1 = other.expr_1->clone(); expr_1 = other.expr_1->clone();
addop_ = other.addop_->clone(); addop_ = other.addop_->clone();
expr_2 = other.expr_2->clone(); expr_2 = other.expr_2->clone();
} }
EAdd &EAdd::operator=(const EAdd & other) EAdd &EAdd::operator=(const EAdd & other)
{ {
EAdd tmp(other); EAdd tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void EAdd::swap(EAdd & other) void EAdd::swap(EAdd & other)
{ {
std::swap(expr_1, other.expr_1); std::swap(expr_1, other.expr_1);
std::swap(addop_, other.addop_); std::swap(addop_, other.addop_);
std::swap(expr_2, other.expr_2); std::swap(expr_2, other.expr_2);
} }
EAdd::~EAdd() EAdd::~EAdd()
{ {
delete(expr_1); delete(expr_1);
delete(addop_); delete(addop_);
delete(expr_2); delete(expr_2);
} }
void EAdd::accept(Visitor *v) void EAdd::accept(Visitor *v)
{ {
v->visitEAdd(this); v->visitEAdd(this);
} }
EAdd *EAdd::clone() const EAdd *EAdd::clone() const
{ {
return new EAdd(*this); return new EAdd(*this);
} }
...@@ -2483,51 +2483,51 @@ EAdd *EAdd::clone() const ...@@ -2483,51 +2483,51 @@ EAdd *EAdd::clone() const
/******************** ERel ********************/ /******************** ERel ********************/
ERel::ERel(Expr *p1, RelOp *p2, Expr *p3) ERel::ERel(Expr *p1, RelOp *p2, Expr *p3)
{ {
expr_1 = p1; expr_1 = p1;
relop_ = p2; relop_ = p2;
expr_2 = p3; expr_2 = p3;
} }
ERel::ERel(const ERel & other) ERel::ERel(const ERel & other)
{ {
expr_1 = other.expr_1->clone(); expr_1 = other.expr_1->clone();
relop_ = other.relop_->clone(); relop_ = other.relop_->clone();
expr_2 = other.expr_2->clone(); expr_2 = other.expr_2->clone();
} }
ERel &ERel::operator=(const ERel & other) ERel &ERel::operator=(const ERel & other)
{ {
ERel tmp(other); ERel tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void ERel::swap(ERel & other) void ERel::swap(ERel & other)
{ {
std::swap(expr_1, other.expr_1); std::swap(expr_1, other.expr_1);
std::swap(relop_, other.relop_); std::swap(relop_, other.relop_);
std::swap(expr_2, other.expr_2); std::swap(expr_2, other.expr_2);
} }
ERel::~ERel() ERel::~ERel()
{ {
delete(expr_1); delete(expr_1);
delete(relop_); delete(relop_);
delete(expr_2); delete(expr_2);
} }
void ERel::accept(Visitor *v) void ERel::accept(Visitor *v)
{ {
v->visitERel(this); v->visitERel(this);
} }
ERel *ERel::clone() const ERel *ERel::clone() const
{ {
return new ERel(*this); return new ERel(*this);
} }
...@@ -2535,47 +2535,47 @@ ERel *ERel::clone() const ...@@ -2535,47 +2535,47 @@ ERel *ERel::clone() const
/******************** EAnd ********************/ /******************** EAnd ********************/
EAnd::EAnd(Expr *p1, Expr *p2) EAnd::EAnd(Expr *p1, Expr *p2)
{ {
expr_1 = p1; expr_1 = p1;
expr_2 = p2; expr_2 = p2;
} }
EAnd::EAnd(const EAnd & other) EAnd::EAnd(const EAnd & other)
{ {
expr_1 = other.expr_1->clone(); expr_1 = other.expr_1->clone();
expr_2 = other.expr_2->clone(); expr_2 = other.expr_2->clone();
} }
EAnd &EAnd::operator=(const EAnd & other) EAnd &EAnd::operator=(const EAnd & other)
{ {
EAnd tmp(other); EAnd tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void EAnd::swap(EAnd & other) void EAnd::swap(EAnd & other)
{ {
std::swap(expr_1, other.expr_1); std::swap(expr_1, other.expr_1);
std::swap(expr_2, other.expr_2); std::swap(expr_2, other.expr_2);
} }
EAnd::~EAnd() EAnd::~EAnd()
{ {
delete(expr_1); delete(expr_1);
delete(expr_2); delete(expr_2);
} }
void EAnd::accept(Visitor *v) void EAnd::accept(Visitor *v)
{ {
v->visitEAnd(this); v->visitEAnd(this);
} }
EAnd *EAnd::clone() const EAnd *EAnd::clone() const
{ {
return new EAnd(*this); return new EAnd(*this);
} }
...@@ -2583,47 +2583,47 @@ EAnd *EAnd::clone() const ...@@ -2583,47 +2583,47 @@ EAnd *EAnd::clone() const
/******************** EOr ********************/ /******************** EOr ********************/
EOr::EOr(Expr *p1, Expr *p2) EOr::EOr(Expr *p1, Expr *p2)
{ {
expr_1 = p1; expr_1 = p1;
expr_2 = p2; expr_2 = p2;
} }
EOr::EOr(const EOr & other) EOr::EOr(const EOr & other)
{ {
expr_1 = other.expr_1->clone(); expr_1 = other.expr_1->clone();
expr_2 = other.expr_2->clone(); expr_2 = other.expr_2->clone();
} }
EOr &EOr::operator=(const EOr & other) EOr &EOr::operator=(const EOr & other)
{ {
EOr tmp(other); EOr tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void EOr::swap(EOr & other) void EOr::swap(EOr & other)
{ {
std::swap(expr_1, other.expr_1); std::swap(expr_1, other.expr_1);
std::swap(expr_2, other.expr_2); std::swap(expr_2, other.expr_2);
} }
EOr::~EOr() EOr::~EOr()
{ {
delete(expr_1); delete(expr_1);
delete(expr_2); delete(expr_2);
} }
void EOr::accept(Visitor *v) void EOr::accept(Visitor *v)
{ {
v->visitEOr(this); v->visitEOr(this);
} }
EOr *EOr::clone() const EOr *EOr::clone() const
{ {
return new EOr(*this); return new EOr(*this);
} }
...@@ -2641,9 +2641,9 @@ Plus::Plus(const Plus & other) ...@@ -2641,9 +2641,9 @@ Plus::Plus(const Plus & other)
Plus &Plus::operator=(const Plus & other) Plus &Plus::operator=(const Plus & other)
{ {
Plus tmp(other); Plus tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Plus::swap(Plus & other) void Plus::swap(Plus & other)
...@@ -2658,12 +2658,12 @@ Plus::~Plus() ...@@ -2658,12 +2658,12 @@ Plus::~Plus()
void Plus::accept(Visitor *v) void Plus::accept(Visitor *v)
{ {
v->visitPlus(this); v->visitPlus(this);
} }
Plus *Plus::clone() const Plus *Plus::clone() const
{ {
return new Plus(*this); return new Plus(*this);
} }
...@@ -2681,9 +2681,9 @@ Minus::Minus(const Minus & other) ...@@ -2681,9 +2681,9 @@ Minus::Minus(const Minus & other)
Minus &Minus::operator=(const Minus & other) Minus &Minus::operator=(const Minus & other)
{ {
Minus tmp(other); Minus tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Minus::swap(Minus & other) void Minus::swap(Minus & other)
...@@ -2698,12 +2698,12 @@ Minus::~Minus() ...@@ -2698,12 +2698,12 @@ Minus::~Minus()
void Minus::accept(Visitor *v) void Minus::accept(Visitor *v)
{ {
v->visitMinus(this); v->visitMinus(this);
} }
Minus *Minus::clone() const Minus *Minus::clone() const
{ {
return new Minus(*this); return new Minus(*this);
} }
...@@ -2721,9 +2721,9 @@ Times::Times(const Times & other) ...@@ -2721,9 +2721,9 @@ Times::Times(const Times & other)
Times &Times::operator=(const Times & other) Times &Times::operator=(const Times & other)
{ {
Times tmp(other); Times tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Times::swap(Times & other) void Times::swap(Times & other)
...@@ -2738,12 +2738,12 @@ Times::~Times() ...@@ -2738,12 +2738,12 @@ Times::~Times()
void Times::accept(Visitor *v) void Times::accept(Visitor *v)
{ {
v->visitTimes(this); v->visitTimes(this);
} }
Times *Times::clone() const Times *Times::clone() const
{ {
return new Times(*this); return new Times(*this);
} }
...@@ -2761,9 +2761,9 @@ Div::Div(const Div & other) ...@@ -2761,9 +2761,9 @@ Div::Div(const Div & other)
Div &Div::operator=(const Div & other) Div &Div::operator=(const Div & other)
{ {
Div tmp(other); Div tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Div::swap(Div & other) void Div::swap(Div & other)
...@@ -2778,12 +2778,12 @@ Div::~Div() ...@@ -2778,12 +2778,12 @@ Div::~Div()
void Div::accept(Visitor *v) void Div::accept(Visitor *v)
{ {
v->visitDiv(this); v->visitDiv(this);
} }
Div *Div::clone() const Div *Div::clone() const
{ {
return new Div(*this); return new Div(*this);
} }
...@@ -2801,9 +2801,9 @@ Mod::Mod(const Mod & other) ...@@ -2801,9 +2801,9 @@ Mod::Mod(const Mod & other)
Mod &Mod::operator=(const Mod & other) Mod &Mod::operator=(const Mod & other)
{ {
Mod tmp(other); Mod tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Mod::swap(Mod & other) void Mod::swap(Mod & other)
...@@ -2818,12 +2818,12 @@ Mod::~Mod() ...@@ -2818,12 +2818,12 @@ Mod::~Mod()
void Mod::accept(Visitor *v) void Mod::accept(Visitor *v)
{ {
v->visitMod(this); v->visitMod(this);
} }
Mod *Mod::clone() const Mod *Mod::clone() const
{ {
return new Mod(*this); return new Mod(*this);
} }
...@@ -2841,9 +2841,9 @@ LTH::LTH(const LTH & other) ...@@ -2841,9 +2841,9 @@ LTH::LTH(const LTH & other)
LTH &LTH::operator=(const LTH & other) LTH &LTH::operator=(const LTH & other)
{ {
LTH tmp(other); LTH tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void LTH::swap(LTH & other) void LTH::swap(LTH & other)
...@@ -2858,12 +2858,12 @@ LTH::~LTH() ...@@ -2858,12 +2858,12 @@ LTH::~LTH()
void LTH::accept(Visitor *v) void LTH::accept(Visitor *v)
{ {
v->visitLTH(this); v->visitLTH(this);
} }
LTH *LTH::clone() const LTH *LTH::clone() const
{ {
return new LTH(*this); return new LTH(*this);
} }
...@@ -2881,9 +2881,9 @@ LE::LE(const LE & other) ...@@ -2881,9 +2881,9 @@ LE::LE(const LE & other)
LE &LE::operator=(const LE & other) LE &LE::operator=(const LE & other)
{ {
LE tmp(other); LE tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void LE::swap(LE & other) void LE::swap(LE & other)
...@@ -2898,12 +2898,12 @@ LE::~LE() ...@@ -2898,12 +2898,12 @@ LE::~LE()
void LE::accept(Visitor *v) void LE::accept(Visitor *v)
{ {
v->visitLE(this); v->visitLE(this);
} }
LE *LE::clone() const LE *LE::clone() const
{ {
return new LE(*this); return new LE(*this);
} }
...@@ -2921,9 +2921,9 @@ GTH::GTH(const GTH & other) ...@@ -2921,9 +2921,9 @@ GTH::GTH(const GTH & other)
GTH &GTH::operator=(const GTH & other) GTH &GTH::operator=(const GTH & other)
{ {
GTH tmp(other); GTH tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void GTH::swap(GTH & other) void GTH::swap(GTH & other)
...@@ -2938,12 +2938,12 @@ GTH::~GTH() ...@@ -2938,12 +2938,12 @@ GTH::~GTH()
void GTH::accept(Visitor *v) void GTH::accept(Visitor *v)
{ {
v->visitGTH(this); v->visitGTH(this);
} }
GTH *GTH::clone() const GTH *GTH::clone() const
{ {
return new GTH(*this); return new GTH(*this);
} }
...@@ -2961,9 +2961,9 @@ GE::GE(const GE & other) ...@@ -2961,9 +2961,9 @@ GE::GE(const GE & other)
GE &GE::operator=(const GE & other) GE &GE::operator=(const GE & other)
{ {
GE tmp(other); GE tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void GE::swap(GE & other) void GE::swap(GE & other)
...@@ -2978,12 +2978,12 @@ GE::~GE() ...@@ -2978,12 +2978,12 @@ GE::~GE()
void GE::accept(Visitor *v) void GE::accept(Visitor *v)
{ {
v->visitGE(this); v->visitGE(this);
} }
GE *GE::clone() const GE *GE::clone() const
{ {
return new GE(*this); return new GE(*this);
} }
...@@ -3001,9 +3001,9 @@ EQU::EQU(const EQU & other) ...@@ -3001,9 +3001,9 @@ EQU::EQU(const EQU & other)
EQU &EQU::operator=(const EQU & other) EQU &EQU::operator=(const EQU & other)
{ {
EQU tmp(other); EQU tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void EQU::swap(EQU & other) void EQU::swap(EQU & other)
...@@ -3018,12 +3018,12 @@ EQU::~EQU() ...@@ -3018,12 +3018,12 @@ EQU::~EQU()
void EQU::accept(Visitor *v) void EQU::accept(Visitor *v)
{ {
v->visitEQU(this); v->visitEQU(this);
} }
EQU *EQU::clone() const EQU *EQU::clone() const
{ {
return new EQU(*this); return new EQU(*this);
} }
...@@ -3041,9 +3041,9 @@ NE::NE(const NE & other) ...@@ -3041,9 +3041,9 @@ NE::NE(const NE & other)
NE &NE::operator=(const NE & other) NE &NE::operator=(const NE & other)
{ {
NE tmp(other); NE tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void NE::swap(NE & other) void NE::swap(NE & other)
...@@ -3058,12 +3058,12 @@ NE::~NE() ...@@ -3058,12 +3058,12 @@ NE::~NE()
void NE::accept(Visitor *v) void NE::accept(Visitor *v)
{ {
v->visitNE(this); v->visitNE(this);
} }
NE *NE::clone() const NE *NE::clone() const
{ {
return new NE(*this); return new NE(*this);
} }
...@@ -3073,13 +3073,13 @@ NE *NE::clone() const ...@@ -3073,13 +3073,13 @@ NE *NE::clone() const
void ListTopDef::accept(Visitor *v) void ListTopDef::accept(Visitor *v)
{ {
v->visitListTopDef(this); v->visitListTopDef(this);
} }
ListTopDef *ListTopDef::clone() const ListTopDef *ListTopDef::clone() const
{ {
return new ListTopDef(*this); return new ListTopDef(*this);
} }
...@@ -3087,13 +3087,13 @@ ListTopDef *ListTopDef::clone() const ...@@ -3087,13 +3087,13 @@ ListTopDef *ListTopDef::clone() const
void ListArg::accept(Visitor *v) void ListArg::accept(Visitor *v)
{ {
v->visitListArg(this); v->visitListArg(this);
} }
ListArg *ListArg::clone() const ListArg *ListArg::clone() const
{ {
return new ListArg(*this); return new ListArg(*this);
} }
...@@ -3101,13 +3101,13 @@ ListArg *ListArg::clone() const ...@@ -3101,13 +3101,13 @@ ListArg *ListArg::clone() const
void ListClassBlockDef::accept(Visitor *v) void ListClassBlockDef::accept(Visitor *v)
{ {
v->visitListClassBlockDef(this); v->visitListClassBlockDef(this);
} }
ListClassBlockDef *ListClassBlockDef::clone() const ListClassBlockDef *ListClassBlockDef::clone() const
{ {
return new ListClassBlockDef(*this); return new ListClassBlockDef(*this);
} }
...@@ -3115,13 +3115,13 @@ ListClassBlockDef *ListClassBlockDef::clone() const ...@@ -3115,13 +3115,13 @@ ListClassBlockDef *ListClassBlockDef::clone() const
void ListStmt::accept(Visitor *v) void ListStmt::accept(Visitor *v)
{ {
v->visitListStmt(this); v->visitListStmt(this);
} }
ListStmt *ListStmt::clone() const ListStmt *ListStmt::clone() const
{ {
return new ListStmt(*this); return new ListStmt(*this);
} }
...@@ -3129,13 +3129,13 @@ ListStmt *ListStmt::clone() const ...@@ -3129,13 +3129,13 @@ ListStmt *ListStmt::clone() const
void ListItem::accept(Visitor *v) void ListItem::accept(Visitor *v)
{ {
v->visitListItem(this); v->visitListItem(this);
} }
ListItem *ListItem::clone() const ListItem *ListItem::clone() const
{ {
return new ListItem(*this); return new ListItem(*this);
} }
...@@ -3143,13 +3143,13 @@ ListItem *ListItem::clone() const ...@@ -3143,13 +3143,13 @@ ListItem *ListItem::clone() const
void ListType::accept(Visitor *v) void ListType::accept(Visitor *v)
{ {
v->visitListType(this); v->visitListType(this);
} }
ListType *ListType::clone() const ListType *ListType::clone() const
{ {
return new ListType(*this); return new ListType(*this);
} }
...@@ -3157,15 +3157,11 @@ ListType *ListType::clone() const ...@@ -3157,15 +3157,11 @@ ListType *ListType::clone() const
void ListExpr::accept(Visitor *v) void ListExpr::accept(Visitor *v)
{ {
v->visitListExpr(this); v->visitListExpr(this);
} }
ListExpr *ListExpr::clone() const ListExpr *ListExpr::clone() const
{ {
return new ListExpr(*this); return new ListExpr(*this);
} }
...@@ -115,104 +115,104 @@ class PIdent; ...@@ -115,104 +115,104 @@ class PIdent;
class Visitor class Visitor
{ {
public: public:
virtual ~Visitor() {} virtual ~Visitor() {}
virtual void visitProgram(Program *p) = 0; virtual void visitProgram(Program *p) = 0;
virtual void visitTopDef(TopDef *p) = 0; virtual void visitTopDef(TopDef *p) = 0;
virtual void visitFunDef(FunDef *p) = 0; virtual void visitFunDef(FunDef *p) = 0;
virtual void visitArg(Arg *p) = 0; virtual void visitArg(Arg *p) = 0;
virtual void visitClassDef(ClassDef *p) = 0; virtual void visitClassDef(ClassDef *p) = 0;
virtual void visitClassBlock(ClassBlock *p) = 0; virtual void visitClassBlock(ClassBlock *p) = 0;
virtual void visitClassBlockDef(ClassBlockDef *p) = 0; virtual void visitClassBlockDef(ClassBlockDef *p) = 0;
virtual void visitBlock(Block *p) = 0; virtual void visitBlock(Block *p) = 0;
virtual void visitStmt(Stmt *p) = 0; virtual void visitStmt(Stmt *p) = 0;
virtual void visitItem(Item *p) = 0; virtual void visitItem(Item *p) = 0;
virtual void visitType(Type *p) = 0; virtual void visitType(Type *p) = 0;
virtual void visitExpr(Expr *p) = 0; virtual void visitExpr(Expr *p) = 0;
virtual void visitAddOp(AddOp *p) = 0; virtual void visitAddOp(AddOp *p) = 0;
virtual void visitMulOp(MulOp *p) = 0; virtual void visitMulOp(MulOp *p) = 0;
virtual void visitRelOp(RelOp *p) = 0; virtual void visitRelOp(RelOp *p) = 0;
virtual void visitProg(Prog *p) = 0; virtual void visitProg(Prog *p) = 0;
virtual void visitFnDef(FnDef *p) = 0; virtual void visitFnDef(FnDef *p) = 0;
virtual void visitClDef(ClDef *p) = 0; virtual void visitClDef(ClDef *p) = 0;
virtual void visitFuncDef(FuncDef *p) = 0; virtual void visitFuncDef(FuncDef *p) = 0;
virtual void visitAr(Ar *p) = 0; virtual void visitAr(Ar *p) = 0;
virtual void visitClassDefN(ClassDefN *p) = 0; virtual void visitClassDefN(ClassDefN *p) = 0;
virtual void visitClassDefE(ClassDefE *p) = 0; virtual void visitClassDefE(ClassDefE *p) = 0;
virtual void visitClassBl(ClassBl *p) = 0; virtual void visitClassBl(ClassBl *p) = 0;
virtual void visitClassMthd(ClassMthd *p) = 0; virtual void visitClassMthd(ClassMthd *p) = 0;
virtual void visitClassFld(ClassFld *p) = 0; virtual void visitClassFld(ClassFld *p) = 0;
virtual void visitBlk(Blk *p) = 0; virtual void visitBlk(Blk *p) = 0;
virtual void visitEmpty(Empty *p) = 0; virtual void visitEmpty(Empty *p) = 0;
virtual void visitBStmt(BStmt *p) = 0; virtual void visitBStmt(BStmt *p) = 0;
virtual void visitDecl(Decl *p) = 0; virtual void visitDecl(Decl *p) = 0;
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 visitTableAss(TableAss *p) = 0;
virtual void visitTableIncr(TableIncr *p) = 0; virtual void visitTableIncr(TableIncr *p) = 0;
virtual void visitTableDecr(TableDecr *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;
virtual void visitVRet(VRet *p) = 0; virtual void visitVRet(VRet *p) = 0;
virtual void visitCond(Cond *p) = 0; virtual void visitCond(Cond *p) = 0;
virtual void visitCondElse(CondElse *p) = 0; virtual void visitCondElse(CondElse *p) = 0;
virtual void visitWhile(While *p) = 0; virtual void visitWhile(While *p) = 0;
virtual void visitSExp(SExp *p) = 0; virtual void visitSExp(SExp *p) = 0;
virtual void visitForEach(ForEach *p) = 0; virtual void visitForEach(ForEach *p) = 0;
virtual void visitInt(Int *p) = 0; virtual void visitInt(Int *p) = 0;
virtual void visitStr(Str *p) = 0; virtual void visitStr(Str *p) = 0;
virtual void visitBool(Bool *p) = 0; virtual void visitBool(Bool *p) = 0;
virtual void visitVoid(Void *p) = 0; virtual void visitVoid(Void *p) = 0;
virtual void visitArray(Array *p) = 0; virtual void visitArray(Array *p) = 0;
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 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 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 visitEClsMmbr(EClsMmbr *p) = 0;
virtual void visitEClsMthd(EClsMthd *p) = 0; virtual void visitEClsMthd(EClsMthd *p) = 0;
virtual void visitNull(Null *p) = 0; virtual void visitNull(Null *p) = 0;
virtual void visitEIndexAcc(EIndexAcc *p) = 0; virtual void visitEIndexAcc(EIndexAcc *p) = 0;
virtual void visitECast(ECast *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;
virtual void visitEAdd(EAdd *p) = 0; virtual void visitEAdd(EAdd *p) = 0;
virtual void visitERel(ERel *p) = 0; virtual void visitERel(ERel *p) = 0;
virtual void visitEAnd(EAnd *p) = 0; virtual void visitEAnd(EAnd *p) = 0;
virtual void visitEOr(EOr *p) = 0; virtual void visitEOr(EOr *p) = 0;
virtual void visitPlus(Plus *p) = 0; virtual void visitPlus(Plus *p) = 0;
virtual void visitMinus(Minus *p) = 0; virtual void visitMinus(Minus *p) = 0;
virtual void visitTimes(Times *p) = 0; virtual void visitTimes(Times *p) = 0;
virtual void visitDiv(Div *p) = 0; virtual void visitDiv(Div *p) = 0;
virtual void visitMod(Mod *p) = 0; virtual void visitMod(Mod *p) = 0;
virtual void visitLTH(LTH *p) = 0; virtual void visitLTH(LTH *p) = 0;
virtual void visitLE(LE *p) = 0; virtual void visitLE(LE *p) = 0;
virtual void visitGTH(GTH *p) = 0; virtual void visitGTH(GTH *p) = 0;
virtual void visitGE(GE *p) = 0; virtual void visitGE(GE *p) = 0;
virtual void visitEQU(EQU *p) = 0; virtual void visitEQU(EQU *p) = 0;
virtual void visitNE(NE *p) = 0; virtual void visitNE(NE *p) = 0;
virtual void visitListTopDef(ListTopDef *p) = 0; virtual void visitListTopDef(ListTopDef *p) = 0;
virtual void visitListArg(ListArg *p) = 0; virtual void visitListArg(ListArg *p) = 0;
virtual void visitListClassBlockDef(ListClassBlockDef *p) = 0; virtual void visitListClassBlockDef(ListClassBlockDef *p) = 0;
virtual void visitListStmt(ListStmt *p) = 0; virtual void visitListStmt(ListStmt *p) = 0;
virtual void visitListItem(ListItem *p) = 0; virtual void visitListItem(ListItem *p) = 0;
virtual void visitListType(ListType *p) = 0; virtual void visitListType(ListType *p) = 0;
virtual void visitListExpr(ListExpr *p) = 0; virtual void visitListExpr(ListExpr *p) = 0;
virtual void visitPIdent(PIdent *p) = 0; virtual void visitPIdent(PIdent *p) = 0;
virtual void visitInteger(Integer x) = 0; virtual void visitInteger(Integer x) = 0;
virtual void visitChar(Char x) = 0; virtual void visitChar(Char x) = 0;
virtual void visitDouble(Double x) = 0; virtual void visitDouble(Double x) = 0;
virtual void visitString(String x) = 0; virtual void visitString(String x) = 0;
virtual void visitIdent(Ident x) = 0; virtual void visitIdent(Ident x) = 0;
}; };
...@@ -220,8 +220,8 @@ public: ...@@ -220,8 +220,8 @@ public:
class Visitable class Visitable
{ {
public: public:
virtual ~Visitable() {} virtual ~Visitable() {}
virtual void accept(Visitor *v) = 0; virtual void accept(Visitor *v) = 0;
}; };
...@@ -230,108 +230,108 @@ class Visitable ...@@ -230,108 +230,108 @@ class Visitable
class Program : public Visitable class Program : public Visitable
{ {
public: public:
virtual Program *clone() const = 0; virtual Program *clone() const = 0;
}; };
class TopDef : public Visitable class TopDef : public Visitable
{ {
public: public:
virtual TopDef *clone() const = 0; virtual TopDef *clone() const = 0;
}; };
class FunDef : public Visitable class FunDef : public Visitable
{ {
public: public:
virtual FunDef *clone() const = 0; virtual FunDef *clone() const = 0;
}; };
class Arg : public Visitable class Arg : public Visitable
{ {
public: public:
virtual Arg *clone() const = 0; virtual Arg *clone() const = 0;
}; };
class ClassDef : public Visitable class ClassDef : public Visitable
{ {
public: public:
virtual PIdent *getName() const = 0; virtual PIdent *getName() const = 0;
virtual PIdent *getParent() const = 0; virtual PIdent *getParent() const = 0;
virtual ClassBlock *getBlock() const = 0; virtual ClassBlock *getBlock() const = 0;
virtual ClassDef *clone() const = 0; virtual ClassDef *clone() const = 0;
}; };
class ClassBlock : public Visitable class ClassBlock : public Visitable
{ {
public: public:
virtual ClassBlock *clone() const = 0; virtual ClassBlock *clone() const = 0;
}; };
class ClassBlockDef : public Visitable class ClassBlockDef : public Visitable
{ {
public: public:
virtual ClassBlockDef *clone() const = 0; virtual ClassBlockDef *clone() const = 0;
}; };
class Block : public Visitable class Block : public Visitable
{ {
public: public:
virtual Block *clone() const = 0; virtual Block *clone() const = 0;
}; };
class Stmt : public Visitable class Stmt : public Visitable
{ {
public: public:
virtual Stmt *clone() const = 0; virtual Stmt *clone() const = 0;
}; };
class Item : public Visitable class Item : public Visitable
{ {
public: public:
virtual Item *clone() const = 0; virtual Item *clone() const = 0;
}; };
class Type : public Visitable class Type : public Visitable
{ {
public: public:
virtual Type *clone() const = 0; virtual Type *clone() const = 0;
}; };
class Expr : public Visitable class Expr : public Visitable
{ {
public: public:
virtual Expr *clone() const = 0; virtual Expr *clone() const = 0;
}; };
class AddOp : public Visitable class AddOp : public Visitable
{ {
public: public:
virtual AddOp *clone() const = 0; virtual AddOp *clone() const = 0;
}; };
class MulOp : public Visitable class MulOp : public Visitable
{ {
public: public:
virtual MulOp *clone() const = 0; virtual MulOp *clone() const = 0;
}; };
class RelOp : public Visitable class RelOp : public Visitable
{ {
public: public:
virtual RelOp *clone() const = 0; virtual RelOp *clone() const = 0;
}; };
...@@ -340,980 +340,980 @@ public: ...@@ -340,980 +340,980 @@ public:
class PIdent : public Visitable class PIdent : public Visitable
{ {
public: public:
String string_; String string_;
Integer integer_; Integer integer_;
PIdent(const PIdent &); PIdent(const PIdent &);
PIdent &operator=(const PIdent &); PIdent &operator=(const PIdent &);
PIdent(String p1, Integer p2); PIdent(String p1, Integer p2);
~PIdent(); ~PIdent();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual PIdent *clone() const; virtual PIdent *clone() const;
void swap(PIdent &); void swap(PIdent &);
}; };
class Prog : public Program class Prog : public Program
{ {
public: public:
ListTopDef *listtopdef_; ListTopDef *listtopdef_;
Prog(const Prog &); Prog(const Prog &);
Prog &operator=(const Prog &); Prog &operator=(const Prog &);
Prog(ListTopDef *p1); Prog(ListTopDef *p1);
~Prog(); ~Prog();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Prog *clone() const; virtual Prog *clone() const;
void swap(Prog &); void swap(Prog &);
}; };
class FnDef : public TopDef class FnDef : public TopDef
{ {
public: public:
FunDef *fundef_; FunDef *fundef_;
FnDef(const FnDef &); FnDef(const FnDef &);
FnDef &operator=(const FnDef &); FnDef &operator=(const FnDef &);
FnDef(FunDef *p1); FnDef(FunDef *p1);
~FnDef(); ~FnDef();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual FnDef *clone() const; virtual FnDef *clone() const;
void swap(FnDef &); void swap(FnDef &);
}; };
class ClDef : public TopDef class ClDef : public TopDef
{ {
public: public:
ClassDef *classdef_; ClassDef *classdef_;
ClDef(const ClDef &); ClDef(const ClDef &);
ClDef &operator=(const ClDef &); ClDef &operator=(const ClDef &);
ClDef(ClassDef *p1); ClDef(ClassDef *p1);
~ClDef(); ~ClDef();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ClDef *clone() const; virtual ClDef *clone() const;
void swap(ClDef &); void swap(ClDef &);
}; };
class FuncDef : public FunDef class FuncDef : public FunDef
{ {
public: public:
Type *type_; Type *type_;
PIdent *pident_; PIdent *pident_;
ListArg *listarg_; ListArg *listarg_;
Block *block_; Block *block_;
FuncDef(const FuncDef &); FuncDef(const FuncDef &);
FuncDef &operator=(const FuncDef &); FuncDef &operator=(const FuncDef &);
FuncDef(Type *p1, PIdent *p2, ListArg *p3, Block *p4); FuncDef(Type *p1, PIdent *p2, ListArg *p3, Block *p4);
~FuncDef(); ~FuncDef();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual FuncDef *clone() const; virtual FuncDef *clone() const;
void swap(FuncDef &); void swap(FuncDef &);
}; };
class Ar : public Arg class Ar : public Arg
{ {
public: public:
Type *type_; Type *type_;
PIdent *pident_; PIdent *pident_;
Ar(const Ar &); Ar(const Ar &);
Ar &operator=(const Ar &); Ar &operator=(const Ar &);
Ar(Type *p1, PIdent *p2); Ar(Type *p1, PIdent *p2);
~Ar(); ~Ar();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Ar *clone() const; virtual Ar *clone() const;
void swap(Ar &); void swap(Ar &);
}; };
class ClassDefN : public ClassDef class ClassDefN : public ClassDef
{ {
public: public:
PIdent *pident_; PIdent *pident_;
ClassBlock *classblock_; ClassBlock *classblock_;
ClassDefN(const ClassDefN &); ClassDefN(const ClassDefN &);
ClassDefN &operator=(const ClassDefN &); ClassDefN &operator=(const ClassDefN &);
ClassDefN(PIdent *p1, ClassBlock *p2); ClassDefN(PIdent *p1, ClassBlock *p2);
~ClassDefN(); ~ClassDefN();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ClassDefN *clone() const; virtual ClassDefN *clone() const;
void swap(ClassDefN &); void swap(ClassDefN &);
virtual PIdent *getName() const { return pident_; }; virtual PIdent *getName() const { return pident_; };
virtual PIdent *getParent() const { return NULL; }; virtual PIdent *getParent() const { return NULL; };
virtual ClassBlock *getBlock() const { return classblock_; }; virtual ClassBlock *getBlock() const { return classblock_; };
}; };
class ClassDefE : public ClassDef class ClassDefE : public ClassDef
{ {
public: public:
PIdent *pident_1; PIdent *pident_1;
PIdent *pident_2; PIdent *pident_2;
ClassBlock *classblock_; ClassBlock *classblock_;
ClassDefE(const ClassDefE &); ClassDefE(const ClassDefE &);
ClassDefE &operator=(const ClassDefE &); ClassDefE &operator=(const ClassDefE &);
ClassDefE(PIdent *p1, PIdent *p2, ClassBlock *p3); ClassDefE(PIdent *p1, PIdent *p2, ClassBlock *p3);
~ClassDefE(); ~ClassDefE();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ClassDefE *clone() const; virtual ClassDefE *clone() const;
void swap(ClassDefE &); void swap(ClassDefE &);
virtual PIdent *getName() const { return pident_1; }; virtual PIdent *getName() const { return pident_1; };
virtual PIdent *getParent() const { return pident_2; }; virtual PIdent *getParent() const { return pident_2; };
virtual ClassBlock *getBlock() const { return classblock_; }; virtual ClassBlock *getBlock() const { return classblock_; };
}; };
class ClassBl : public ClassBlock class ClassBl : public ClassBlock
{ {
public: public:
ListClassBlockDef *listclassblockdef_; ListClassBlockDef *listclassblockdef_;
ClassBl(const ClassBl &); ClassBl(const ClassBl &);
ClassBl &operator=(const ClassBl &); ClassBl &operator=(const ClassBl &);
ClassBl(ListClassBlockDef *p1); ClassBl(ListClassBlockDef *p1);
~ClassBl(); ~ClassBl();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ClassBl *clone() const; virtual ClassBl *clone() const;
void swap(ClassBl &); void swap(ClassBl &);
}; };
class ClassMthd : public ClassBlockDef class ClassMthd : public ClassBlockDef
{ {
public: public:
FunDef *fundef_; FunDef *fundef_;
ClassMthd(const ClassMthd &); ClassMthd(const ClassMthd &);
ClassMthd &operator=(const ClassMthd &); ClassMthd &operator=(const ClassMthd &);
ClassMthd(FunDef *p1); ClassMthd(FunDef *p1);
~ClassMthd(); ~ClassMthd();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ClassMthd *clone() const; virtual ClassMthd *clone() const;
void swap(ClassMthd &); void swap(ClassMthd &);
}; };
class ClassFld : public ClassBlockDef class ClassFld : public ClassBlockDef
{ {
public: public:
Type *type_; Type *type_;
ListItem *listitem_; ListItem *listitem_;
ClassFld(const ClassFld &); ClassFld(const ClassFld &);
ClassFld &operator=(const ClassFld &); ClassFld &operator=(const ClassFld &);
ClassFld(Type *p1, ListItem *p2); ClassFld(Type *p1, ListItem *p2);
~ClassFld(); ~ClassFld();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ClassFld *clone() const; virtual ClassFld *clone() const;
void swap(ClassFld &); void swap(ClassFld &);
}; };
class Blk : public Block class Blk : public Block
{ {
public: public:
ListStmt *liststmt_; ListStmt *liststmt_;
Blk(const Blk &); Blk(const Blk &);
Blk &operator=(const Blk &); Blk &operator=(const Blk &);
Blk(ListStmt *p1); Blk(ListStmt *p1);
~Blk(); ~Blk();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Blk *clone() const; virtual Blk *clone() const;
void swap(Blk &); void swap(Blk &);
}; };
class Empty : public Stmt class Empty : public Stmt
{ {
public: public:
Empty(const Empty &); Empty(const Empty &);
Empty &operator=(const Empty &); Empty &operator=(const Empty &);
Empty(); Empty();
~Empty(); ~Empty();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Empty *clone() const; virtual Empty *clone() const;
void swap(Empty &); void swap(Empty &);
}; };
class BStmt : public Stmt class BStmt : public Stmt
{ {
public: public:
Block *block_; Block *block_;
BStmt(const BStmt &); BStmt(const BStmt &);
BStmt &operator=(const BStmt &); BStmt &operator=(const BStmt &);
BStmt(Block *p1); BStmt(Block *p1);
~BStmt(); ~BStmt();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual BStmt *clone() const; virtual BStmt *clone() const;
void swap(BStmt &); void swap(BStmt &);
}; };
class Decl : public Stmt class Decl : public Stmt
{ {
public: public:
Type *type_; Type *type_;
ListItem *listitem_; ListItem *listitem_;
Decl(const Decl &); Decl(const Decl &);
Decl &operator=(const Decl &); Decl &operator=(const Decl &);
Decl(Type *p1, ListItem *p2); Decl(Type *p1, ListItem *p2);
~Decl(); ~Decl();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Decl *clone() const; virtual Decl *clone() const;
void swap(Decl &); void swap(Decl &);
}; };
class Ass : public Stmt class Ass : public Stmt
{ {
public: public:
Expr *expr_1; Expr *expr_1;
Expr *expr_2; Expr *expr_2;
Ass(const Ass &); Ass(const Ass &);
Ass &operator=(const Ass &); Ass &operator=(const Ass &);
Ass(Expr *p1, Expr *p2); Ass(Expr *p1, Expr *p2);
~Ass(); ~Ass();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Ass *clone() const; virtual Ass *clone() const;
void swap(Ass &); void swap(Ass &);
}; };
class TableAss : public Stmt class TableAss : public Stmt
{ {
public: public:
PIdent *pident_; PIdent *pident_;
Expr *expr_1; Expr *expr_1;
Expr *expr_2; Expr *expr_2;
TableAss(const TableAss &); TableAss(const TableAss &);
TableAss &operator=(const TableAss &); TableAss &operator=(const TableAss &);
TableAss(PIdent *p1, Expr *p2, Expr *p3); TableAss(PIdent *p1, Expr *p2, Expr *p3);
~TableAss(); ~TableAss();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual TableAss *clone() const; virtual TableAss *clone() const;
void swap(TableAss &); void swap(TableAss &);
}; };
class TableIncr : public Stmt class TableIncr : public Stmt
{ {
public: public:
PIdent *pident_; PIdent *pident_;
Expr *expr_; Expr *expr_;
TableIncr(const TableIncr &); TableIncr(const TableIncr &);
TableIncr &operator=(const TableIncr &); TableIncr &operator=(const TableIncr &);
TableIncr(PIdent *p1, Expr *p2); TableIncr(PIdent *p1, Expr *p2);
~TableIncr(); ~TableIncr();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual TableIncr *clone() const; virtual TableIncr *clone() const;
void swap(TableIncr &); void swap(TableIncr &);
}; };
class TableDecr : public Stmt class TableDecr : public Stmt
{ {
public: public:
PIdent *pident_; PIdent *pident_;
Expr *expr_; Expr *expr_;
TableDecr(const TableDecr &); TableDecr(const TableDecr &);
TableDecr &operator=(const TableDecr &); TableDecr &operator=(const TableDecr &);
TableDecr(PIdent *p1, Expr *p2); TableDecr(PIdent *p1, Expr *p2);
~TableDecr(); ~TableDecr();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual TableDecr *clone() const; virtual TableDecr *clone() const;
void swap(TableDecr &); void swap(TableDecr &);
}; };
class Incr : public Stmt class Incr : public Stmt
{ {
public: public:
PIdent *pident_; PIdent *pident_;
Incr(const Incr &); Incr(const Incr &);
Incr &operator=(const Incr &); Incr &operator=(const Incr &);
Incr(PIdent *p1); Incr(PIdent *p1);
~Incr(); ~Incr();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Incr *clone() const; virtual Incr *clone() const;
void swap(Incr &); void swap(Incr &);
}; };
class Decr : public Stmt class Decr : public Stmt
{ {
public: public:
PIdent *pident_; PIdent *pident_;
Decr(const Decr &); Decr(const Decr &);
Decr &operator=(const Decr &); Decr &operator=(const Decr &);
Decr(PIdent *p1); Decr(PIdent *p1);
~Decr(); ~Decr();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Decr *clone() const; virtual Decr *clone() const;
void swap(Decr &); void swap(Decr &);
}; };
class Ret : public Stmt class Ret : public Stmt
{ {
public: public:
Expr *expr_; Expr *expr_;
Ret(const Ret &); Ret(const Ret &);
Ret &operator=(const Ret &); Ret &operator=(const Ret &);
Ret(Expr *p1); Ret(Expr *p1);
~Ret(); ~Ret();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Ret *clone() const; virtual Ret *clone() const;
void swap(Ret &); void swap(Ret &);
}; };
class VRet : public Stmt class VRet : public Stmt
{ {
public: public:
VRet(const VRet &); VRet(const VRet &);
VRet &operator=(const VRet &); VRet &operator=(const VRet &);
VRet(); VRet();
~VRet(); ~VRet();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual VRet *clone() const; virtual VRet *clone() const;
void swap(VRet &); void swap(VRet &);
}; };
class Cond : public Stmt class Cond : public Stmt
{ {
public: public:
Expr *expr_; Expr *expr_;
Stmt *stmt_; Stmt *stmt_;
Cond(const Cond &); Cond(const Cond &);
Cond &operator=(const Cond &); Cond &operator=(const Cond &);
Cond(Expr *p1, Stmt *p2); Cond(Expr *p1, Stmt *p2);
~Cond(); ~Cond();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Cond *clone() const; virtual Cond *clone() const;
void swap(Cond &); void swap(Cond &);
}; };
class CondElse : public Stmt class CondElse : public Stmt
{ {
public: public:
Expr *expr_; Expr *expr_;
Stmt *stmt_1; Stmt *stmt_1;
Stmt *stmt_2; Stmt *stmt_2;
CondElse(const CondElse &); CondElse(const CondElse &);
CondElse &operator=(const CondElse &); CondElse &operator=(const CondElse &);
CondElse(Expr *p1, Stmt *p2, Stmt *p3); CondElse(Expr *p1, Stmt *p2, Stmt *p3);
~CondElse(); ~CondElse();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual CondElse *clone() const; virtual CondElse *clone() const;
void swap(CondElse &); void swap(CondElse &);
}; };
class While : public Stmt class While : public Stmt
{ {
public: public:
Expr *expr_; Expr *expr_;
Stmt *stmt_; Stmt *stmt_;
While(const While &); While(const While &);
While &operator=(const While &); While &operator=(const While &);
While(Expr *p1, Stmt *p2); While(Expr *p1, Stmt *p2);
~While(); ~While();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual While *clone() const; virtual While *clone() const;
void swap(While &); void swap(While &);
}; };
class SExp : public Stmt class SExp : public Stmt
{ {
public: public:
Expr *expr_; Expr *expr_;
SExp(const SExp &); SExp(const SExp &);
SExp &operator=(const SExp &); SExp &operator=(const SExp &);
SExp(Expr *p1); SExp(Expr *p1);
~SExp(); ~SExp();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual SExp *clone() const; virtual SExp *clone() const;
void swap(SExp &); void swap(SExp &);
}; };
class ForEach : public Stmt class ForEach : public Stmt
{ {
public: public:
Type *type_; Type *type_;
PIdent *pident_; PIdent *pident_;
Expr *expr_; Expr *expr_;
Stmt *stmt_; Stmt *stmt_;
ForEach(const ForEach &); ForEach(const ForEach &);
ForEach &operator=(const ForEach &); ForEach &operator=(const ForEach &);
ForEach(Type *p1, PIdent *p2, Expr *p3, Stmt *p4); ForEach(Type *p1, PIdent *p2, Expr *p3, Stmt *p4);
~ForEach(); ~ForEach();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ForEach *clone() const; virtual ForEach *clone() const;
void swap(ForEach &); void swap(ForEach &);
}; };
class NoInit : public Item class NoInit : public Item
{ {
public: public:
PIdent *pident_; PIdent *pident_;
NoInit(const NoInit &); NoInit(const NoInit &);
NoInit &operator=(const NoInit &); NoInit &operator=(const NoInit &);
NoInit(PIdent *p1); NoInit(PIdent *p1);
~NoInit(); ~NoInit();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual NoInit *clone() const; virtual NoInit *clone() const;
void swap(NoInit &); void swap(NoInit &);
}; };
class Init : public Item class Init : public Item
{ {
public: public:
PIdent *pident_; PIdent *pident_;
Expr *expr_; Expr *expr_;
Init(const Init &); Init(const Init &);
Init &operator=(const Init &); Init &operator=(const Init &);
Init(PIdent *p1, Expr *p2); Init(PIdent *p1, Expr *p2);
~Init(); ~Init();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Init *clone() const; virtual Init *clone() const;
void swap(Init &); void swap(Init &);
}; };
class Int : public Type class Int : public Type
{ {
public: public:
Int(const Int &); Int(const Int &);
Int &operator=(const Int &); Int &operator=(const Int &);
Int(); Int();
~Int(); ~Int();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Int *clone() const; virtual Int *clone() const;
void swap(Int &); void swap(Int &);
}; };
class Str : public Type class Str : public Type
{ {
public: public:
Str(const Str &); Str(const Str &);
Str &operator=(const Str &); Str &operator=(const Str &);
Str(); Str();
~Str(); ~Str();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Str *clone() const; virtual Str *clone() const;
void swap(Str &); void swap(Str &);
}; };
class Bool : public Type class Bool : public Type
{ {
public: public:
Bool(const Bool &); Bool(const Bool &);
Bool &operator=(const Bool &); Bool &operator=(const Bool &);
Bool(); Bool();
~Bool(); ~Bool();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Bool *clone() const; virtual Bool *clone() const;
void swap(Bool &); void swap(Bool &);
}; };
class Void : public Type class Void : public Type
{ {
public: public:
Void(const Void &); Void(const Void &);
Void &operator=(const Void &); Void &operator=(const Void &);
Void(); Void();
~Void(); ~Void();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Void *clone() const; virtual Void *clone() const;
void swap(Void &); void swap(Void &);
}; };
class Array : public Type class Array : public Type
{ {
public: public:
Type *type_; Type *type_;
Array(const Array &); Array(const Array &);
Array &operator=(const Array &); Array &operator=(const Array &);
Array(Type *p1); Array(Type *p1);
~Array(); ~Array();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Array *clone() const; virtual Array *clone() const;
void swap(Array &); void swap(Array &);
}; };
class ClassT : public Type class ClassT : public Type
{ {
public: public:
PIdent *pident_; PIdent *pident_;
ClassT(const ClassT &); ClassT(const ClassT &);
ClassT &operator=(const ClassT &); ClassT &operator=(const ClassT &);
ClassT(PIdent *p1); ClassT(PIdent *p1);
~ClassT(); ~ClassT();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ClassT *clone() const; virtual ClassT *clone() const;
void swap(ClassT &); void swap(ClassT &);
}; };
class Fun : public Type class Fun : public Type
{ {
public: public:
Type *type_; Type *type_;
ListType *listtype_; ListType *listtype_;
Fun(const Fun &); Fun(const Fun &);
Fun &operator=(const Fun &); Fun &operator=(const Fun &);
Fun(Type *p1, ListType *p2); Fun(Type *p1, ListType *p2);
~Fun(); ~Fun();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Fun *clone() const; virtual Fun *clone() const;
void swap(Fun &); void swap(Fun &);
}; };
class EVar : public Expr class EVar : public Expr
{ {
public: public:
PIdent *pident_; PIdent *pident_;
EVar(const EVar &); EVar(const EVar &);
EVar &operator=(const EVar &); EVar &operator=(const EVar &);
EVar(PIdent *p1); EVar(PIdent *p1);
~EVar(); ~EVar();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual EVar *clone() const; virtual EVar *clone() const;
void swap(EVar &); void swap(EVar &);
}; };
class ELitInt : public Expr class ELitInt : public Expr
{ {
public: public:
Integer integer_; Integer integer_;
ELitInt(const ELitInt &); ELitInt(const ELitInt &);
ELitInt &operator=(const ELitInt &); ELitInt &operator=(const ELitInt &);
ELitInt(Integer p1); ELitInt(Integer p1);
~ELitInt(); ~ELitInt();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ELitInt *clone() const; virtual ELitInt *clone() const;
void swap(ELitInt &); void swap(ELitInt &);
}; };
class ELitTrue : public Expr class ELitTrue : public Expr
{ {
public: public:
ELitTrue(const ELitTrue &); ELitTrue(const ELitTrue &);
ELitTrue &operator=(const ELitTrue &); ELitTrue &operator=(const ELitTrue &);
ELitTrue(); ELitTrue();
~ELitTrue(); ~ELitTrue();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ELitTrue *clone() const; virtual ELitTrue *clone() const;
void swap(ELitTrue &); void swap(ELitTrue &);
}; };
class ELitFalse : public Expr class ELitFalse : public Expr
{ {
public: public:
ELitFalse(const ELitFalse &); ELitFalse(const ELitFalse &);
ELitFalse &operator=(const ELitFalse &); ELitFalse &operator=(const ELitFalse &);
ELitFalse(); ELitFalse();
~ELitFalse(); ~ELitFalse();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ELitFalse *clone() const; virtual ELitFalse *clone() const;
void swap(ELitFalse &); void swap(ELitFalse &);
}; };
class EApp : public Expr class EApp : public Expr
{ {
public: public:
PIdent *pident_; PIdent *pident_;
ListExpr *listexpr_; ListExpr *listexpr_;
EApp(const EApp &); EApp(const EApp &);
EApp &operator=(const EApp &); EApp &operator=(const EApp &);
EApp(PIdent *p1, ListExpr *p2); EApp(PIdent *p1, ListExpr *p2);
~EApp(); ~EApp();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual EApp *clone() const; virtual EApp *clone() const;
void swap(EApp &); void swap(EApp &);
}; };
class EString : public Expr class EString : public Expr
{ {
public: public:
String string_; String string_;
EString(const EString &); EString(const EString &);
EString &operator=(const EString &); EString &operator=(const EString &);
EString(String p1); EString(String p1);
~EString(); ~EString();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual EString *clone() const; virtual EString *clone() const;
void swap(EString &); void swap(EString &);
}; };
class ENewArray : public Expr class ENewArray : public Expr
{ {
public: public:
Type *type_; Type *type_;
Expr *expr_; Expr *expr_;
ENewArray(const ENewArray &); ENewArray(const ENewArray &);
ENewArray &operator=(const ENewArray &); ENewArray &operator=(const ENewArray &);
ENewArray(Type *p1, Expr *p2); ENewArray(Type *p1, Expr *p2);
~ENewArray(); ~ENewArray();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ENewArray *clone() const; virtual ENewArray *clone() const;
void swap(ENewArray &); void swap(ENewArray &);
}; };
class ENewClass : public Expr class ENewClass : public Expr
{ {
public: public:
PIdent *pident_; PIdent *pident_;
ENewClass(const ENewClass &); ENewClass(const ENewClass &);
ENewClass &operator=(const ENewClass &); ENewClass &operator=(const ENewClass &);
ENewClass(PIdent *p1); ENewClass(PIdent *p1);
~ENewClass(); ~ENewClass();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ENewClass *clone() const; virtual ENewClass *clone() const;
void swap(ENewClass &); void swap(ENewClass &);
}; };
class EClsMmbr : public Expr class EClsMmbr : public Expr
{ {
public: public:
Expr *expr_; Expr *expr_;
PIdent *pident_; PIdent *pident_;
EClsMmbr(const EClsMmbr &); EClsMmbr(const EClsMmbr &);
EClsMmbr &operator=(const EClsMmbr &); EClsMmbr &operator=(const EClsMmbr &);
EClsMmbr(Expr *p1, PIdent *p2); EClsMmbr(Expr *p1, PIdent *p2);
~EClsMmbr(); ~EClsMmbr();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual EClsMmbr *clone() const; virtual EClsMmbr *clone() const;
void swap(EClsMmbr &); void swap(EClsMmbr &);
}; };
class EClsMthd : public Expr class EClsMthd : public Expr
{ {
public: public:
Expr *expr_; Expr *expr_;
PIdent *pident_; PIdent *pident_;
ListExpr *listexpr_; ListExpr *listexpr_;
EClsMthd(const EClsMthd &); EClsMthd(const EClsMthd &);
EClsMthd &operator=(const EClsMthd &); EClsMthd &operator=(const EClsMthd &);
EClsMthd(Expr *p1, PIdent *p2, ListExpr *p3); EClsMthd(Expr *p1, PIdent *p2, ListExpr *p3);
~EClsMthd(); ~EClsMthd();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual EClsMthd *clone() const; virtual EClsMthd *clone() const;
void swap(EClsMthd &); void swap(EClsMthd &);
}; };
class Null : public Expr class Null : public Expr
{ {
public: public:
Null(const Null &); Null(const Null &);
Null &operator=(const Null &); Null &operator=(const Null &);
Null(); Null();
~Null(); ~Null();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Null *clone() const; virtual Null *clone() const;
void swap(Null &); void swap(Null &);
}; };
class EIndexAcc : public Expr class EIndexAcc : public Expr
{ {
public: public:
PIdent *pident_; PIdent *pident_;
Expr *expr_; Expr *expr_;
EIndexAcc(const EIndexAcc &); EIndexAcc(const EIndexAcc &);
EIndexAcc &operator=(const EIndexAcc &); EIndexAcc &operator=(const EIndexAcc &);
EIndexAcc(PIdent *p1, Expr *p2); EIndexAcc(PIdent *p1, Expr *p2);
~EIndexAcc(); ~EIndexAcc();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual EIndexAcc *clone() const; virtual EIndexAcc *clone() const;
void swap(EIndexAcc &); void swap(EIndexAcc &);
}; };
class ECast : public Expr class ECast : public Expr
{ {
public: public:
PIdent *pident_; PIdent *pident_;
Expr *expr_; Expr *expr_;
ECast(const ECast &); ECast(const ECast &);
ECast &operator=(const ECast &); ECast &operator=(const ECast &);
ECast(PIdent *p1, Expr *p2); ECast(PIdent *p1, Expr *p2);
~ECast(); ~ECast();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ECast *clone() const; virtual ECast *clone() const;
void swap(ECast &); void swap(ECast &);
}; };
class Neg : public Expr class Neg : public Expr
{ {
public: public:
Expr *expr_; Expr *expr_;
Neg(const Neg &); Neg(const Neg &);
Neg &operator=(const Neg &); Neg &operator=(const Neg &);
Neg(Expr *p1); Neg(Expr *p1);
~Neg(); ~Neg();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Neg *clone() const; virtual Neg *clone() const;
void swap(Neg &); void swap(Neg &);
}; };
class Not : public Expr class Not : public Expr
{ {
public: public:
Expr *expr_; Expr *expr_;
Not(const Not &); Not(const Not &);
Not &operator=(const Not &); Not &operator=(const Not &);
Not(Expr *p1); Not(Expr *p1);
~Not(); ~Not();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Not *clone() const; virtual Not *clone() const;
void swap(Not &); void swap(Not &);
}; };
class EMul : public Expr class EMul : public Expr
{ {
public: public:
Expr *expr_1; Expr *expr_1;
MulOp *mulop_; MulOp *mulop_;
Expr *expr_2; Expr *expr_2;
EMul(const EMul &); EMul(const EMul &);
EMul &operator=(const EMul &); EMul &operator=(const EMul &);
EMul(Expr *p1, MulOp *p2, Expr *p3); EMul(Expr *p1, MulOp *p2, Expr *p3);
~EMul(); ~EMul();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual EMul *clone() const; virtual EMul *clone() const;
void swap(EMul &); void swap(EMul &);
}; };
class EAdd : public Expr class EAdd : public Expr
{ {
public: public:
Expr *expr_1; Expr *expr_1;
AddOp *addop_; AddOp *addop_;
Expr *expr_2; Expr *expr_2;
EAdd(const EAdd &); EAdd(const EAdd &);
EAdd &operator=(const EAdd &); EAdd &operator=(const EAdd &);
EAdd(Expr *p1, AddOp *p2, Expr *p3); EAdd(Expr *p1, AddOp *p2, Expr *p3);
~EAdd(); ~EAdd();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual EAdd *clone() const; virtual EAdd *clone() const;
void swap(EAdd &); void swap(EAdd &);
}; };
class ERel : public Expr class ERel : public Expr
{ {
public: public:
Expr *expr_1; Expr *expr_1;
RelOp *relop_; RelOp *relop_;
Expr *expr_2; Expr *expr_2;
ERel(const ERel &); ERel(const ERel &);
ERel &operator=(const ERel &); ERel &operator=(const ERel &);
ERel(Expr *p1, RelOp *p2, Expr *p3); ERel(Expr *p1, RelOp *p2, Expr *p3);
~ERel(); ~ERel();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ERel *clone() const; virtual ERel *clone() const;
void swap(ERel &); void swap(ERel &);
}; };
class EAnd : public Expr class EAnd : public Expr
{ {
public: public:
Expr *expr_1; Expr *expr_1;
Expr *expr_2; Expr *expr_2;
EAnd(const EAnd &); EAnd(const EAnd &);
EAnd &operator=(const EAnd &); EAnd &operator=(const EAnd &);
EAnd(Expr *p1, Expr *p2); EAnd(Expr *p1, Expr *p2);
~EAnd(); ~EAnd();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual EAnd *clone() const; virtual EAnd *clone() const;
void swap(EAnd &); void swap(EAnd &);
}; };
class EOr : public Expr class EOr : public Expr
{ {
public: public:
Expr *expr_1; Expr *expr_1;
Expr *expr_2; Expr *expr_2;
EOr(const EOr &); EOr(const EOr &);
EOr &operator=(const EOr &); EOr &operator=(const EOr &);
EOr(Expr *p1, Expr *p2); EOr(Expr *p1, Expr *p2);
~EOr(); ~EOr();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual EOr *clone() const; virtual EOr *clone() const;
void swap(EOr &); void swap(EOr &);
}; };
class Plus : public AddOp class Plus : public AddOp
{ {
public: public:
Plus(const Plus &); Plus(const Plus &);
Plus &operator=(const Plus &); Plus &operator=(const Plus &);
Plus(); Plus();
~Plus(); ~Plus();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Plus *clone() const; virtual Plus *clone() const;
void swap(Plus &); void swap(Plus &);
}; };
class Minus : public AddOp class Minus : public AddOp
{ {
public: public:
Minus(const Minus &); Minus(const Minus &);
Minus &operator=(const Minus &); Minus &operator=(const Minus &);
Minus(); Minus();
~Minus(); ~Minus();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Minus *clone() const; virtual Minus *clone() const;
void swap(Minus &); void swap(Minus &);
}; };
class Times : public MulOp class Times : public MulOp
{ {
public: public:
Times(const Times &); Times(const Times &);
Times &operator=(const Times &); Times &operator=(const Times &);
Times(); Times();
~Times(); ~Times();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Times *clone() const; virtual Times *clone() const;
void swap(Times &); void swap(Times &);
}; };
class Div : public MulOp class Div : public MulOp
{ {
public: public:
Div(const Div &); Div(const Div &);
Div &operator=(const Div &); Div &operator=(const Div &);
Div(); Div();
~Div(); ~Div();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Div *clone() const; virtual Div *clone() const;
void swap(Div &); void swap(Div &);
}; };
class Mod : public MulOp class Mod : public MulOp
{ {
public: public:
Mod(const Mod &); Mod(const Mod &);
Mod &operator=(const Mod &); Mod &operator=(const Mod &);
Mod(); Mod();
~Mod(); ~Mod();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual Mod *clone() const; virtual Mod *clone() const;
void swap(Mod &); void swap(Mod &);
}; };
class LTH : public RelOp class LTH : public RelOp
{ {
public: public:
LTH(const LTH &); LTH(const LTH &);
LTH &operator=(const LTH &); LTH &operator=(const LTH &);
LTH(); LTH();
~LTH(); ~LTH();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual LTH *clone() const; virtual LTH *clone() const;
void swap(LTH &); void swap(LTH &);
}; };
class LE : public RelOp class LE : public RelOp
{ {
public: public:
LE(const LE &); LE(const LE &);
LE &operator=(const LE &); LE &operator=(const LE &);
LE(); LE();
~LE(); ~LE();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual LE *clone() const; virtual LE *clone() const;
void swap(LE &); void swap(LE &);
}; };
class GTH : public RelOp class GTH : public RelOp
{ {
public: public:
GTH(const GTH &); GTH(const GTH &);
GTH &operator=(const GTH &); GTH &operator=(const GTH &);
GTH(); GTH();
~GTH(); ~GTH();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual GTH *clone() const; virtual GTH *clone() const;
void swap(GTH &); void swap(GTH &);
}; };
class GE : public RelOp class GE : public RelOp
{ {
public: public:
GE(const GE &); GE(const GE &);
GE &operator=(const GE &); GE &operator=(const GE &);
GE(); GE();
~GE(); ~GE();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual GE *clone() const; virtual GE *clone() const;
void swap(GE &); void swap(GE &);
}; };
class EQU : public RelOp class EQU : public RelOp
{ {
public: public:
EQU(const EQU &); EQU(const EQU &);
EQU &operator=(const EQU &); EQU &operator=(const EQU &);
EQU(); EQU();
~EQU(); ~EQU();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual EQU *clone() const; virtual EQU *clone() const;
void swap(EQU &); void swap(EQU &);
}; };
class NE : public RelOp class NE : public RelOp
{ {
public: public:
NE(const NE &); NE(const NE &);
NE &operator=(const NE &); NE &operator=(const NE &);
NE(); NE();
~NE(); ~NE();
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual NE *clone() const; virtual NE *clone() const;
void swap(NE &); void swap(NE &);
}; };
...@@ -1321,50 +1321,50 @@ public: ...@@ -1321,50 +1321,50 @@ public:
class ListTopDef : public Visitable, public std::vector<TopDef*> class ListTopDef : public Visitable, public std::vector<TopDef*>
{ {
public: public:
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ListTopDef *clone() const; virtual ListTopDef *clone() const;
}; };
class ListArg : public Visitable, public std::vector<Arg*> class ListArg : public Visitable, public std::vector<Arg*>
{ {
public: public:
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ListArg *clone() const; virtual ListArg *clone() const;
}; };
class ListClassBlockDef : public Visitable, public std::vector<ClassBlockDef*> class ListClassBlockDef : public Visitable, public std::vector<ClassBlockDef*>
{ {
public: public:
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ListClassBlockDef *clone() const; virtual ListClassBlockDef *clone() const;
}; };
class ListStmt : public Visitable, public std::vector<Stmt*> class ListStmt : public Visitable, public std::vector<Stmt*>
{ {
public: public:
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ListStmt *clone() const; virtual ListStmt *clone() const;
}; };
class ListItem : public Visitable, public std::vector<Item*> class ListItem : public Visitable, public std::vector<Item*>
{ {
public: public:
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ListItem *clone() const; virtual ListItem *clone() const;
}; };
class ListType : public Visitable, public std::vector<Type*> class ListType : public Visitable, public std::vector<Type*>
{ {
public: public:
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ListType *clone() const; virtual ListType *clone() const;
}; };
class ListExpr : public Visitable, public std::vector<Expr*> class ListExpr : public Visitable, public std::vector<Expr*>
{ {
public: public:
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual ListExpr *clone() const; virtual ListExpr *clone() const;
}; };
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -30,32 +30,32 @@ class RelOp; ...@@ -30,32 +30,32 @@ class RelOp;
typedef union typedef union
{ {
int int_; int int_;
char char_; char char_;
double double_; double double_;
char* string_; char* string_;
Program* program_; Program* program_;
TopDef* topdef_; TopDef* topdef_;
ListTopDef* listtopdef_; ListTopDef* listtopdef_;
FunDef* fundef_; FunDef* fundef_;
Arg* arg_; Arg* arg_;
ListArg* listarg_; ListArg* listarg_;
ClassDef* classdef_; ClassDef* classdef_;
ClassBlock* classblock_; ClassBlock* classblock_;
ClassBlockDef* classblockdef_; ClassBlockDef* classblockdef_;
ListClassBlockDef* listclassblockdef_; ListClassBlockDef* listclassblockdef_;
Block* block_; Block* block_;
ListStmt* liststmt_; ListStmt* liststmt_;
Stmt* stmt_; Stmt* stmt_;
Item* item_; Item* item_;
ListItem* listitem_; ListItem* listitem_;
Type* type_; Type* type_;
ListType* listtype_; ListType* listtype_;
Expr* expr_; Expr* expr_;
ListExpr* listexpr_; ListExpr* listexpr_;
AddOp* addop_; AddOp* addop_;
MulOp* mulop_; MulOp* mulop_;
RelOp* relop_; RelOp* relop_;
} YYSTYPE; } YYSTYPE;
Program* pProgram(FILE *inp); Program* pProgram(FILE *inp);
......
...@@ -8,97 +8,97 @@ ...@@ -8,97 +8,97 @@
//You may wish to change render //You may wish to change render
void PrintAbsyn::render(Char c) void PrintAbsyn::render(Char c)
{ {
if (c == '{') if (c == '{')
{ {
bufAppend('\n'); bufAppend('\n');
indent(); indent();
bufAppend(c); bufAppend(c);
_n_ = _n_ + INDENT_WIDTH; _n_ = _n_ + INDENT_WIDTH;
bufAppend('\n'); bufAppend('\n');
indent(); indent();
} }
else if (c == '(' || c == '[') else if (c == '(' || c == '[')
bufAppend(c); bufAppend(c);
else if (c == ')' || c == ']') else if (c == ')' || c == ']')
{ {
backup(); backup();
bufAppend(c); bufAppend(c);
} }
else if (c == '}') else if (c == '}')
{ {
int t; int t;
_n_ = _n_ - INDENT_WIDTH; _n_ = _n_ - INDENT_WIDTH;
for (t=0; t<INDENT_WIDTH; t++) { for (t=0; t<INDENT_WIDTH; t++) {
backup(); backup();
} }
bufAppend(c); bufAppend(c);
bufAppend('\n'); bufAppend('\n');
indent(); indent();
} }
else if (c == ',') else if (c == ',')
{ {
backup(); backup();
bufAppend(c); bufAppend(c);
bufAppend(' '); bufAppend(' ');
} }
else if (c == ';') else if (c == ';')
{ {
backup(); backup();
bufAppend(c); bufAppend(c);
bufAppend('\n'); bufAppend('\n');
indent(); indent();
} }
else if (c == 0) return; else if (c == 0) return;
else else
{ {
bufAppend(' '); bufAppend(' ');
bufAppend(c); bufAppend(c);
bufAppend(' '); bufAppend(' ');
} }
} }
void PrintAbsyn::render(String s_) void PrintAbsyn::render(String s_)
{ {
const char *s = s_.c_str() ; const char *s = s_.c_str() ;
if(strlen(s) > 0) if(strlen(s) > 0)
{ {
bufAppend(s); bufAppend(s);
bufAppend(' '); bufAppend(' ');
} }
} }
void PrintAbsyn::render(const char *s) void PrintAbsyn::render(const char *s)
{ {
if(strlen(s) > 0) if(strlen(s) > 0)
{ {
bufAppend(s); bufAppend(s);
bufAppend(' '); bufAppend(' ');
} }
} }
void PrintAbsyn::indent() void PrintAbsyn::indent()
{ {
int n = _n_; int n = _n_;
while (n > 0) while (n > 0)
{ {
bufAppend(' '); bufAppend(' ');
n--; n--;
} }
} }
void PrintAbsyn::backup() void PrintAbsyn::backup()
{ {
if (buf_[cur_ - 1] == ' ') if (buf_[cur_ - 1] == ' ')
{ {
buf_[cur_ - 1] = 0; buf_[cur_ - 1] = 0;
cur_--; cur_--;
} }
} }
PrintAbsyn::PrintAbsyn(void) PrintAbsyn::PrintAbsyn(void)
{ {
_i_ = 0; _n_ = 0; _i_ = 0; _n_ = 0;
buf_ = 0; buf_ = 0;
bufReset(); bufReset();
} }
PrintAbsyn::~PrintAbsyn(void) PrintAbsyn::~PrintAbsyn(void)
...@@ -107,1053 +107,1053 @@ PrintAbsyn::~PrintAbsyn(void) ...@@ -107,1053 +107,1053 @@ PrintAbsyn::~PrintAbsyn(void)
char *PrintAbsyn::print(Visitable *v) char *PrintAbsyn::print(Visitable *v)
{ {
_i_ = 0; _n_ = 0; _i_ = 0; _n_ = 0;
bufReset(); bufReset();
v->accept(this); v->accept(this);
return buf_; return buf_;
} }
void PrintAbsyn::visitPIdent(PIdent *p) void PrintAbsyn::visitPIdent(PIdent *p)
{ {
visitIdent(p->string_); visitIdent(p->string_);
} }
void PrintAbsyn::visitProgram(Program *p) {} //abstract class void PrintAbsyn::visitProgram(Program *p) {} //abstract class
void PrintAbsyn::visitProg(Prog *p) void PrintAbsyn::visitProg(Prog *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
if(p->listtopdef_) {_i_ = 0; p->listtopdef_->accept(this);} if(p->listtopdef_) {_i_ = 0; p->listtopdef_->accept(this);}
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitTopDef(TopDef *p) {} //abstract class void PrintAbsyn::visitTopDef(TopDef *p) {} //abstract class
void PrintAbsyn::visitFnDef(FnDef *p) void PrintAbsyn::visitFnDef(FnDef *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->fundef_->accept(this); _i_ = 0; p->fundef_->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitClDef(ClDef *p) void PrintAbsyn::visitClDef(ClDef *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->classdef_->accept(this); _i_ = 0; p->classdef_->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitListTopDef(ListTopDef *listtopdef) void PrintAbsyn::visitListTopDef(ListTopDef *listtopdef)
{ {
for (ListTopDef::const_iterator i = listtopdef->begin() ; i != listtopdef->end() ; ++i) for (ListTopDef::const_iterator i = listtopdef->begin() ; i != listtopdef->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (i != listtopdef->end() - 1) render(""); if (i != listtopdef->end() - 1) render("");
} }
}void PrintAbsyn::visitFunDef(FunDef *p) {} //abstract class }void PrintAbsyn::visitFunDef(FunDef *p) {} //abstract class
void PrintAbsyn::visitFuncDef(FuncDef *p) void PrintAbsyn::visitFuncDef(FuncDef *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->type_->accept(this); _i_ = 0; p->type_->accept(this);
visitPIdent(p->pident_); visitPIdent(p->pident_);
render('('); render('(');
if(p->listarg_) {_i_ = 0; p->listarg_->accept(this);} if(p->listarg_) {_i_ = 0; p->listarg_->accept(this);}
render(')'); render(')');
_i_ = 0; p->block_->accept(this); _i_ = 0; p->block_->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitArg(Arg *p) {} //abstract class void PrintAbsyn::visitArg(Arg *p) {} //abstract class
void PrintAbsyn::visitAr(Ar *p) void PrintAbsyn::visitAr(Ar *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->type_->accept(this); _i_ = 0; p->type_->accept(this);
visitPIdent(p->pident_); visitPIdent(p->pident_);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitListArg(ListArg *listarg) void PrintAbsyn::visitListArg(ListArg *listarg)
{ {
for (ListArg::const_iterator i = listarg->begin() ; i != listarg->end() ; ++i) for (ListArg::const_iterator i = listarg->begin() ; i != listarg->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (i != listarg->end() - 1) render(','); if (i != listarg->end() - 1) render(',');
} }
}void PrintAbsyn::visitClassDef(ClassDef *p) {} //abstract class }void PrintAbsyn::visitClassDef(ClassDef *p) {} //abstract class
void PrintAbsyn::visitClassDefN(ClassDefN *p) void PrintAbsyn::visitClassDefN(ClassDefN *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("class"); render("class");
visitPIdent(p->pident_); visitPIdent(p->pident_);
_i_ = 0; p->classblock_->accept(this); _i_ = 0; p->classblock_->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitClassDefE(ClassDefE *p) void PrintAbsyn::visitClassDefE(ClassDefE *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("class"); render("class");
visitPIdent(p->pident_1); visitPIdent(p->pident_1);
render("extends"); render("extends");
visitPIdent(p->pident_2); visitPIdent(p->pident_2);
_i_ = 0; p->classblock_->accept(this); _i_ = 0; p->classblock_->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitClassBlock(ClassBlock *p) {} //abstract class void PrintAbsyn::visitClassBlock(ClassBlock *p) {} //abstract class
void PrintAbsyn::visitClassBl(ClassBl *p) void PrintAbsyn::visitClassBl(ClassBl *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render('{'); render('{');
if(p->listclassblockdef_) {_i_ = 0; p->listclassblockdef_->accept(this);} if(p->listclassblockdef_) {_i_ = 0; p->listclassblockdef_->accept(this);}
render('}'); render('}');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitClassBlockDef(ClassBlockDef *p) {} //abstract class void PrintAbsyn::visitClassBlockDef(ClassBlockDef *p) {} //abstract class
void PrintAbsyn::visitClassMthd(ClassMthd *p) void PrintAbsyn::visitClassMthd(ClassMthd *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->fundef_->accept(this); _i_ = 0; p->fundef_->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitClassFld(ClassFld *p) void PrintAbsyn::visitClassFld(ClassFld *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->type_->accept(this); _i_ = 0; p->type_->accept(this);
if(p->listitem_) {_i_ = 0; p->listitem_->accept(this);} if(p->listitem_) {_i_ = 0; p->listitem_->accept(this);}
render(';'); render(';');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitListClassBlockDef(ListClassBlockDef *listclassblockdef) void PrintAbsyn::visitListClassBlockDef(ListClassBlockDef *listclassblockdef)
{ {
for (ListClassBlockDef::const_iterator i = listclassblockdef->begin() ; i != listclassblockdef->end() ; ++i) for (ListClassBlockDef::const_iterator i = listclassblockdef->begin() ; i != listclassblockdef->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
render(""); render("");
} }
}void PrintAbsyn::visitBlock(Block *p) {} //abstract class }void PrintAbsyn::visitBlock(Block *p) {} //abstract class
void PrintAbsyn::visitBlk(Blk *p) void PrintAbsyn::visitBlk(Blk *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render('{'); render('{');
if(p->liststmt_) {_i_ = 0; p->liststmt_->accept(this);} if(p->liststmt_) {_i_ = 0; p->liststmt_->accept(this);}
render('}'); render('}');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitListStmt(ListStmt *liststmt) void PrintAbsyn::visitListStmt(ListStmt *liststmt)
{ {
for (ListStmt::const_iterator i = liststmt->begin() ; i != liststmt->end() ; ++i) for (ListStmt::const_iterator i = liststmt->begin() ; i != liststmt->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
render(""); render("");
} }
}void PrintAbsyn::visitStmt(Stmt *p) {} //abstract class }void PrintAbsyn::visitStmt(Stmt *p) {} //abstract class
void PrintAbsyn::visitEmpty(Empty *p) void PrintAbsyn::visitEmpty(Empty *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render(';'); render(';');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitBStmt(BStmt *p) void PrintAbsyn::visitBStmt(BStmt *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->block_->accept(this); _i_ = 0; p->block_->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitDecl(Decl *p) void PrintAbsyn::visitDecl(Decl *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->type_->accept(this); _i_ = 0; p->type_->accept(this);
if(p->listitem_) {_i_ = 0; p->listitem_->accept(this);} if(p->listitem_) {_i_ = 0; p->listitem_->accept(this);}
render(';'); render(';');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitAss(Ass *p) void PrintAbsyn::visitAss(Ass *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->expr_1->accept(this); _i_ = 0; p->expr_1->accept(this);
render('='); render('=');
_i_ = 0; p->expr_2->accept(this); _i_ = 0; p->expr_2->accept(this);
render(';'); render(';');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitTableAss(TableAss *p) void PrintAbsyn::visitTableAss(TableAss *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_); visitPIdent(p->pident_);
render('['); render('[');
_i_ = 0; p->expr_1->accept(this); _i_ = 0; p->expr_1->accept(this);
render(']'); render(']');
render('='); render('=');
_i_ = 0; p->expr_2->accept(this); _i_ = 0; p->expr_2->accept(this);
render(';'); render(';');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitTableIncr(TableIncr *p) void PrintAbsyn::visitTableIncr(TableIncr *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_); visitPIdent(p->pident_);
render('['); render('[');
_i_ = 0; p->expr_->accept(this); _i_ = 0; p->expr_->accept(this);
render(']'); render(']');
render("++"); render("++");
render(';'); render(';');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitTableDecr(TableDecr *p) void PrintAbsyn::visitTableDecr(TableDecr *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_); visitPIdent(p->pident_);
render('['); render('[');
_i_ = 0; p->expr_->accept(this); _i_ = 0; p->expr_->accept(this);
render(']'); render(']');
render("--"); render("--");
render(';'); render(';');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitIncr(Incr *p) void PrintAbsyn::visitIncr(Incr *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_); visitPIdent(p->pident_);
render("++"); render("++");
render(';'); render(';');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitDecr(Decr *p) void PrintAbsyn::visitDecr(Decr *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_); visitPIdent(p->pident_);
render("--"); render("--");
render(';'); render(';');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitRet(Ret *p) void PrintAbsyn::visitRet(Ret *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("return"); render("return");
_i_ = 0; p->expr_->accept(this); _i_ = 0; p->expr_->accept(this);
render(';'); render(';');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitVRet(VRet *p) void PrintAbsyn::visitVRet(VRet *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("return"); render("return");
render(';'); render(';');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitCond(Cond *p) void PrintAbsyn::visitCond(Cond *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("if"); render("if");
render('('); render('(');
_i_ = 0; p->expr_->accept(this); _i_ = 0; p->expr_->accept(this);
render(')'); render(')');
_i_ = 0; p->stmt_->accept(this); _i_ = 0; p->stmt_->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitCondElse(CondElse *p) void PrintAbsyn::visitCondElse(CondElse *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("if"); render("if");
render('('); render('(');
_i_ = 0; p->expr_->accept(this); _i_ = 0; p->expr_->accept(this);
render(')'); render(')');
_i_ = 0; p->stmt_1->accept(this); _i_ = 0; p->stmt_1->accept(this);
render("else"); render("else");
_i_ = 0; p->stmt_2->accept(this); _i_ = 0; p->stmt_2->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitWhile(While *p) void PrintAbsyn::visitWhile(While *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("while"); render("while");
render('('); render('(');
_i_ = 0; p->expr_->accept(this); _i_ = 0; p->expr_->accept(this);
render(')'); render(')');
_i_ = 0; p->stmt_->accept(this); _i_ = 0; p->stmt_->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitSExp(SExp *p) void PrintAbsyn::visitSExp(SExp *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->expr_->accept(this); _i_ = 0; p->expr_->accept(this);
render(';'); render(';');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitForEach(ForEach *p) void PrintAbsyn::visitForEach(ForEach *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("for"); render("for");
render('('); render('(');
_i_ = 0; p->type_->accept(this); _i_ = 0; p->type_->accept(this);
visitPIdent(p->pident_); visitPIdent(p->pident_);
render(':'); render(':');
_i_ = 0; p->expr_->accept(this); _i_ = 0; p->expr_->accept(this);
render(')'); render(')');
_i_ = 0; p->stmt_->accept(this); _i_ = 0; p->stmt_->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitItem(Item *p) {} //abstract class void PrintAbsyn::visitItem(Item *p) {} //abstract class
void PrintAbsyn::visitNoInit(NoInit *p) void PrintAbsyn::visitNoInit(NoInit *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_); visitPIdent(p->pident_);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitInit(Init *p) void PrintAbsyn::visitInit(Init *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_); visitPIdent(p->pident_);
render('='); render('=');
_i_ = 0; p->expr_->accept(this); _i_ = 0; p->expr_->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitListItem(ListItem *listitem) void PrintAbsyn::visitListItem(ListItem *listitem)
{ {
for (ListItem::const_iterator i = listitem->begin() ; i != listitem->end() ; ++i) for (ListItem::const_iterator i = listitem->begin() ; i != listitem->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (i != listitem->end() - 1) render(','); if (i != listitem->end() - 1) render(',');
} }
}void PrintAbsyn::visitType(Type *p) {} //abstract class }void PrintAbsyn::visitType(Type *p) {} //abstract class
void PrintAbsyn::visitInt(Int *p) void PrintAbsyn::visitInt(Int *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("int"); render("int");
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitStr(Str *p) void PrintAbsyn::visitStr(Str *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("string"); render("string");
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitBool(Bool *p) void PrintAbsyn::visitBool(Bool *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("boolean"); render("boolean");
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitVoid(Void *p) void PrintAbsyn::visitVoid(Void *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("void"); render("void");
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitArray(Array *p) void PrintAbsyn::visitArray(Array *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->type_->accept(this); _i_ = 0; p->type_->accept(this);
render('['); render('[');
render(']'); render(']');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitClassT(ClassT *p) void PrintAbsyn::visitClassT(ClassT *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_); visitPIdent(p->pident_);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitFun(Fun *p) void PrintAbsyn::visitFun(Fun *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
/* Internal Category */ /* Internal Category */
_i_ = 0; p->type_->accept(this); _i_ = 0; p->type_->accept(this);
render('('); render('(');
if(p->listtype_) {_i_ = 0; p->listtype_->accept(this);} if(p->listtype_) {_i_ = 0; p->listtype_->accept(this);}
render(')'); render(')');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitListType(ListType *listtype) void PrintAbsyn::visitListType(ListType *listtype)
{ {
for (ListType::const_iterator i = listtype->begin() ; i != listtype->end() ; ++i) for (ListType::const_iterator i = listtype->begin() ; i != listtype->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (i != listtype->end() - 1) render(','); if (i != listtype->end() - 1) render(',');
} }
}void PrintAbsyn::visitExpr(Expr *p) {} //abstract class }void PrintAbsyn::visitExpr(Expr *p) {} //abstract class
void PrintAbsyn::visitEVar(EVar *p) void PrintAbsyn::visitEVar(EVar *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 6) render(_L_PAREN); if (oldi > 6) render(_L_PAREN);
visitPIdent(p->pident_); visitPIdent(p->pident_);
if (oldi > 6) render(_R_PAREN); if (oldi > 6) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitELitInt(ELitInt *p) void PrintAbsyn::visitELitInt(ELitInt *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 6) render(_L_PAREN); if (oldi > 6) render(_L_PAREN);
visitInteger(p->integer_); visitInteger(p->integer_);
if (oldi > 6) render(_R_PAREN); if (oldi > 6) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitELitTrue(ELitTrue *p) void PrintAbsyn::visitELitTrue(ELitTrue *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 6) render(_L_PAREN); if (oldi > 6) render(_L_PAREN);
render("true"); render("true");
if (oldi > 6) render(_R_PAREN); if (oldi > 6) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitELitFalse(ELitFalse *p) void PrintAbsyn::visitELitFalse(ELitFalse *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 6) render(_L_PAREN); if (oldi > 6) render(_L_PAREN);
render("false"); render("false");
if (oldi > 6) render(_R_PAREN); if (oldi > 6) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitEApp(EApp *p) void PrintAbsyn::visitEApp(EApp *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 6) render(_L_PAREN); if (oldi > 6) render(_L_PAREN);
visitPIdent(p->pident_); visitPIdent(p->pident_);
render('('); render('(');
if(p->listexpr_) {_i_ = 0; p->listexpr_->accept(this);} if(p->listexpr_) {_i_ = 0; p->listexpr_->accept(this);}
render(')'); render(')');
if (oldi > 6) render(_R_PAREN); if (oldi > 6) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitEString(EString *p) void PrintAbsyn::visitEString(EString *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 6) render(_L_PAREN); if (oldi > 6) render(_L_PAREN);
visitString(p->string_); visitString(p->string_);
if (oldi > 6) render(_R_PAREN); if (oldi > 6) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitENewArray(ENewArray *p) void PrintAbsyn::visitENewArray(ENewArray *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 6) render(_L_PAREN); if (oldi > 6) render(_L_PAREN);
render("new"); render("new");
_i_ = 0; p->type_->accept(this); _i_ = 0; p->type_->accept(this);
render('['); render('[');
_i_ = 0; p->expr_->accept(this); _i_ = 0; p->expr_->accept(this);
render(']'); render(']');
if (oldi > 6) render(_R_PAREN); if (oldi > 6) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitENewClass(ENewClass *p) void PrintAbsyn::visitENewClass(ENewClass *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 6) render(_L_PAREN); if (oldi > 6) render(_L_PAREN);
render("new"); render("new");
visitPIdent(p->pident_); visitPIdent(p->pident_);
if (oldi > 6) render(_R_PAREN); if (oldi > 6) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitEClsMmbr(EClsMmbr *p) void PrintAbsyn::visitEClsMmbr(EClsMmbr *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 6) render(_L_PAREN); if (oldi > 6) render(_L_PAREN);
_i_ = 6; p->expr_->accept(this); _i_ = 6; p->expr_->accept(this);
render('.'); render('.');
visitPIdent(p->pident_); visitPIdent(p->pident_);
if (oldi > 6) render(_R_PAREN); if (oldi > 6) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitEClsMthd(EClsMthd *p) void PrintAbsyn::visitEClsMthd(EClsMthd *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 6) render(_L_PAREN); if (oldi > 6) render(_L_PAREN);
_i_ = 6; p->expr_->accept(this); _i_ = 6; p->expr_->accept(this);
render('.'); render('.');
visitPIdent(p->pident_); visitPIdent(p->pident_);
render('('); render('(');
if(p->listexpr_) {_i_ = 0; p->listexpr_->accept(this);} if(p->listexpr_) {_i_ = 0; p->listexpr_->accept(this);}
render(')'); render(')');
if (oldi > 6) render(_R_PAREN); if (oldi > 6) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitNull(Null *p) void PrintAbsyn::visitNull(Null *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 6) render(_L_PAREN); if (oldi > 6) render(_L_PAREN);
render("null"); render("null");
if (oldi > 6) render(_R_PAREN); if (oldi > 6) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitEIndexAcc(EIndexAcc *p) void PrintAbsyn::visitEIndexAcc(EIndexAcc *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 6) render(_L_PAREN); if (oldi > 6) render(_L_PAREN);
visitPIdent(p->pident_); visitPIdent(p->pident_);
render('['); render('[');
_i_ = 0; p->expr_->accept(this); _i_ = 0; p->expr_->accept(this);
render(']'); render(']');
if (oldi > 6) render(_R_PAREN); if (oldi > 6) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitECast(ECast *p) void PrintAbsyn::visitECast(ECast *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 5) render(_L_PAREN); if (oldi > 5) render(_L_PAREN);
render('('); render('(');
visitPIdent(p->pident_); visitPIdent(p->pident_);
render(')'); render(')');
_i_ = 5; p->expr_->accept(this); _i_ = 5; p->expr_->accept(this);
if (oldi > 5) render(_R_PAREN); if (oldi > 5) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitNeg(Neg *p) void PrintAbsyn::visitNeg(Neg *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 5) render(_L_PAREN); if (oldi > 5) render(_L_PAREN);
render('-'); render('-');
_i_ = 6; p->expr_->accept(this); _i_ = 6; p->expr_->accept(this);
if (oldi > 5) render(_R_PAREN); if (oldi > 5) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitNot(Not *p) void PrintAbsyn::visitNot(Not *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 5) render(_L_PAREN); if (oldi > 5) render(_L_PAREN);
render('!'); render('!');
_i_ = 6; p->expr_->accept(this); _i_ = 6; p->expr_->accept(this);
if (oldi > 5) render(_R_PAREN); if (oldi > 5) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitEMul(EMul *p) void PrintAbsyn::visitEMul(EMul *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 4) render(_L_PAREN); if (oldi > 4) render(_L_PAREN);
_i_ = 4; p->expr_1->accept(this); _i_ = 4; p->expr_1->accept(this);
_i_ = 0; p->mulop_->accept(this); _i_ = 0; p->mulop_->accept(this);
_i_ = 5; p->expr_2->accept(this); _i_ = 5; p->expr_2->accept(this);
if (oldi > 4) render(_R_PAREN); if (oldi > 4) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitEAdd(EAdd *p) void PrintAbsyn::visitEAdd(EAdd *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 3) render(_L_PAREN); if (oldi > 3) render(_L_PAREN);
_i_ = 3; p->expr_1->accept(this); _i_ = 3; p->expr_1->accept(this);
_i_ = 0; p->addop_->accept(this); _i_ = 0; p->addop_->accept(this);
_i_ = 4; p->expr_2->accept(this); _i_ = 4; p->expr_2->accept(this);
if (oldi > 3) render(_R_PAREN); if (oldi > 3) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitERel(ERel *p) void PrintAbsyn::visitERel(ERel *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 2) render(_L_PAREN); if (oldi > 2) render(_L_PAREN);
_i_ = 2; p->expr_1->accept(this); _i_ = 2; p->expr_1->accept(this);
_i_ = 0; p->relop_->accept(this); _i_ = 0; p->relop_->accept(this);
_i_ = 3; p->expr_2->accept(this); _i_ = 3; p->expr_2->accept(this);
if (oldi > 2) render(_R_PAREN); if (oldi > 2) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitEAnd(EAnd *p) void PrintAbsyn::visitEAnd(EAnd *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 1) render(_L_PAREN); if (oldi > 1) render(_L_PAREN);
_i_ = 2; p->expr_1->accept(this); _i_ = 2; p->expr_1->accept(this);
render("&&"); render("&&");
_i_ = 1; p->expr_2->accept(this); _i_ = 1; p->expr_2->accept(this);
if (oldi > 1) render(_R_PAREN); if (oldi > 1) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitEOr(EOr *p) void PrintAbsyn::visitEOr(EOr *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
_i_ = 1; p->expr_1->accept(this); _i_ = 1; p->expr_1->accept(this);
render("||"); render("||");
_i_ = 0; p->expr_2->accept(this); _i_ = 0; p->expr_2->accept(this);
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitListExpr(ListExpr *listexpr) void PrintAbsyn::visitListExpr(ListExpr *listexpr)
{ {
for (ListExpr::const_iterator i = listexpr->begin() ; i != listexpr->end() ; ++i) for (ListExpr::const_iterator i = listexpr->begin() ; i != listexpr->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (i != listexpr->end() - 1) render(','); if (i != listexpr->end() - 1) render(',');
} }
}void PrintAbsyn::visitAddOp(AddOp *p) {} //abstract class }void PrintAbsyn::visitAddOp(AddOp *p) {} //abstract class
void PrintAbsyn::visitPlus(Plus *p) void PrintAbsyn::visitPlus(Plus *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render('+'); render('+');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitMinus(Minus *p) void PrintAbsyn::visitMinus(Minus *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render('-'); render('-');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitMulOp(MulOp *p) {} //abstract class void PrintAbsyn::visitMulOp(MulOp *p) {} //abstract class
void PrintAbsyn::visitTimes(Times *p) void PrintAbsyn::visitTimes(Times *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render('*'); render('*');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitDiv(Div *p) void PrintAbsyn::visitDiv(Div *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render('/'); render('/');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitMod(Mod *p) void PrintAbsyn::visitMod(Mod *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render('%'); render('%');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitRelOp(RelOp *p) {} //abstract class void PrintAbsyn::visitRelOp(RelOp *p) {} //abstract class
void PrintAbsyn::visitLTH(LTH *p) void PrintAbsyn::visitLTH(LTH *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render('<'); render('<');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitLE(LE *p) void PrintAbsyn::visitLE(LE *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("<="); render("<=");
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitGTH(GTH *p) void PrintAbsyn::visitGTH(GTH *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render('>'); render('>');
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitGE(GE *p) void PrintAbsyn::visitGE(GE *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render(">="); render(">=");
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitEQU(EQU *p) void PrintAbsyn::visitEQU(EQU *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("=="); render("==");
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitNE(NE *p) void PrintAbsyn::visitNE(NE *p)
{ {
int oldi = _i_; int oldi = _i_;
if (oldi > 0) render(_L_PAREN); if (oldi > 0) render(_L_PAREN);
render("!="); render("!=");
if (oldi > 0) render(_R_PAREN); if (oldi > 0) render(_R_PAREN);
_i_ = oldi; _i_ = oldi;
} }
void PrintAbsyn::visitInteger(Integer i) void PrintAbsyn::visitInteger(Integer i)
{ {
char tmp[16]; char tmp[16];
sprintf(tmp, "%d", i); sprintf(tmp, "%d", i);
bufAppend(tmp); bufAppend(tmp);
} }
void PrintAbsyn::visitDouble(Double d) void PrintAbsyn::visitDouble(Double d)
{ {
char tmp[16]; char tmp[16];
sprintf(tmp, "%g", d); sprintf(tmp, "%g", d);
bufAppend(tmp); bufAppend(tmp);
} }
void PrintAbsyn::visitChar(Char c) void PrintAbsyn::visitChar(Char c)
{ {
bufAppend('\''); bufAppend('\'');
bufAppend(c); bufAppend(c);
bufAppend('\''); bufAppend('\'');
} }
void PrintAbsyn::visitString(String s) void PrintAbsyn::visitString(String s)
{ {
bufAppend('\"'); bufAppend('\"');
bufAppend(s); bufAppend(s);
bufAppend('\"'); bufAppend('\"');
} }
void PrintAbsyn::visitIdent(String s) void PrintAbsyn::visitIdent(String s)
{ {
render(s); render(s);
} }
void PrintAbsyn::visitPIdent(String s) void PrintAbsyn::visitPIdent(String s)
{ {
render(s); render(s);
} }
ShowAbsyn::ShowAbsyn(void) ShowAbsyn::ShowAbsyn(void)
{ {
buf_ = 0; buf_ = 0;
bufReset(); bufReset();
} }
ShowAbsyn::~ShowAbsyn(void) ShowAbsyn::~ShowAbsyn(void)
...@@ -1162,794 +1162,794 @@ ShowAbsyn::~ShowAbsyn(void) ...@@ -1162,794 +1162,794 @@ ShowAbsyn::~ShowAbsyn(void)
char *ShowAbsyn::show(Visitable *v) char *ShowAbsyn::show(Visitable *v)
{ {
bufReset(); bufReset();
v->accept(this); v->accept(this);
return buf_; return buf_;
} }
void ShowAbsyn::visitPIdent(PIdent *p) void ShowAbsyn::visitPIdent(PIdent *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("PIdent"); bufAppend("PIdent");
bufAppend(' '); bufAppend(' ');
visitString(p->string_); visitString(p->string_);
bufAppend(' '); bufAppend(' ');
visitInteger(p->integer_); visitInteger(p->integer_);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitProgram(Program *p) {} //abstract class void ShowAbsyn::visitProgram(Program *p) {} //abstract class
void ShowAbsyn::visitProg(Prog *p) void ShowAbsyn::visitProg(Prog *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Prog"); bufAppend("Prog");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->listtopdef_) p->listtopdef_->accept(this); if (p->listtopdef_) p->listtopdef_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitTopDef(TopDef *p) {} //abstract class void ShowAbsyn::visitTopDef(TopDef *p) {} //abstract class
void ShowAbsyn::visitFnDef(FnDef *p) void ShowAbsyn::visitFnDef(FnDef *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("FnDef"); bufAppend("FnDef");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->fundef_) p->fundef_->accept(this); if (p->fundef_) p->fundef_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitClDef(ClDef *p) void ShowAbsyn::visitClDef(ClDef *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ClDef"); bufAppend("ClDef");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->classdef_) p->classdef_->accept(this); if (p->classdef_) p->classdef_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitListTopDef(ListTopDef *listtopdef) void ShowAbsyn::visitListTopDef(ListTopDef *listtopdef)
{ {
for (ListTopDef::const_iterator i = listtopdef->begin() ; i != listtopdef->end() ; ++i) for (ListTopDef::const_iterator i = listtopdef->begin() ; i != listtopdef->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (i != listtopdef->end() - 1) bufAppend(", "); if (i != listtopdef->end() - 1) bufAppend(", ");
} }
} }
void ShowAbsyn::visitFunDef(FunDef *p) {} //abstract class void ShowAbsyn::visitFunDef(FunDef *p) {} //abstract class
void ShowAbsyn::visitFuncDef(FuncDef *p) void ShowAbsyn::visitFuncDef(FuncDef *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("FuncDef"); bufAppend("FuncDef");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->type_) p->type_->accept(this); if (p->type_) p->type_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->listarg_) p->listarg_->accept(this); if (p->listarg_) p->listarg_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->block_) p->block_->accept(this); if (p->block_) p->block_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitArg(Arg *p) {} //abstract class void ShowAbsyn::visitArg(Arg *p) {} //abstract class
void ShowAbsyn::visitAr(Ar *p) void ShowAbsyn::visitAr(Ar *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Ar"); bufAppend("Ar");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->type_) p->type_->accept(this); if (p->type_) p->type_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitListArg(ListArg *listarg) void ShowAbsyn::visitListArg(ListArg *listarg)
{ {
for (ListArg::const_iterator i = listarg->begin() ; i != listarg->end() ; ++i) for (ListArg::const_iterator i = listarg->begin() ; i != listarg->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (i != listarg->end() - 1) bufAppend(", "); if (i != listarg->end() - 1) bufAppend(", ");
} }
} }
void ShowAbsyn::visitClassDef(ClassDef *p) {} //abstract class void ShowAbsyn::visitClassDef(ClassDef *p) {} //abstract class
void ShowAbsyn::visitClassDefN(ClassDefN *p) void ShowAbsyn::visitClassDefN(ClassDefN *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ClassDefN"); bufAppend("ClassDefN");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->classblock_) p->classblock_->accept(this); if (p->classblock_) p->classblock_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitClassDefE(ClassDefE *p) void ShowAbsyn::visitClassDefE(ClassDefE *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ClassDefE"); bufAppend("ClassDefE");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_1); visitPIdent(p->pident_1);
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_2); visitPIdent(p->pident_2);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->classblock_) p->classblock_->accept(this); if (p->classblock_) p->classblock_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitClassBlock(ClassBlock *p) {} //abstract class void ShowAbsyn::visitClassBlock(ClassBlock *p) {} //abstract class
void ShowAbsyn::visitClassBl(ClassBl *p) void ShowAbsyn::visitClassBl(ClassBl *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ClassBl"); bufAppend("ClassBl");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->listclassblockdef_) p->listclassblockdef_->accept(this); if (p->listclassblockdef_) p->listclassblockdef_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitClassBlockDef(ClassBlockDef *p) {} //abstract class void ShowAbsyn::visitClassBlockDef(ClassBlockDef *p) {} //abstract class
void ShowAbsyn::visitClassMthd(ClassMthd *p) void ShowAbsyn::visitClassMthd(ClassMthd *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ClassMthd"); bufAppend("ClassMthd");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->fundef_) p->fundef_->accept(this); if (p->fundef_) p->fundef_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitClassFld(ClassFld *p) void ShowAbsyn::visitClassFld(ClassFld *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ClassFld"); bufAppend("ClassFld");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->type_) p->type_->accept(this); if (p->type_) p->type_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->listitem_) p->listitem_->accept(this); if (p->listitem_) p->listitem_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitListClassBlockDef(ListClassBlockDef *listclassblockdef) void ShowAbsyn::visitListClassBlockDef(ListClassBlockDef *listclassblockdef)
{ {
for (ListClassBlockDef::const_iterator i = listclassblockdef->begin() ; i != listclassblockdef->end() ; ++i) for (ListClassBlockDef::const_iterator i = listclassblockdef->begin() ; i != listclassblockdef->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (i != listclassblockdef->end() - 1) bufAppend(", "); if (i != listclassblockdef->end() - 1) bufAppend(", ");
} }
} }
void ShowAbsyn::visitBlock(Block *p) {} //abstract class void ShowAbsyn::visitBlock(Block *p) {} //abstract class
void ShowAbsyn::visitBlk(Blk *p) void ShowAbsyn::visitBlk(Blk *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Blk"); bufAppend("Blk");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->liststmt_) p->liststmt_->accept(this); if (p->liststmt_) p->liststmt_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitListStmt(ListStmt *liststmt) void ShowAbsyn::visitListStmt(ListStmt *liststmt)
{ {
for (ListStmt::const_iterator i = liststmt->begin() ; i != liststmt->end() ; ++i) for (ListStmt::const_iterator i = liststmt->begin() ; i != liststmt->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (i != liststmt->end() - 1) bufAppend(", "); if (i != liststmt->end() - 1) bufAppend(", ");
} }
} }
void ShowAbsyn::visitStmt(Stmt *p) {} //abstract class void ShowAbsyn::visitStmt(Stmt *p) {} //abstract class
void ShowAbsyn::visitEmpty(Empty *p) void ShowAbsyn::visitEmpty(Empty *p)
{ {
bufAppend("Empty"); bufAppend("Empty");
} }
void ShowAbsyn::visitBStmt(BStmt *p) void ShowAbsyn::visitBStmt(BStmt *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("BStmt"); bufAppend("BStmt");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->block_) p->block_->accept(this); if (p->block_) p->block_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitDecl(Decl *p) void ShowAbsyn::visitDecl(Decl *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Decl"); bufAppend("Decl");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->type_) p->type_->accept(this); if (p->type_) p->type_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->listitem_) p->listitem_->accept(this); if (p->listitem_) p->listitem_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitAss(Ass *p) void ShowAbsyn::visitAss(Ass *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Ass"); bufAppend("Ass");
bufAppend(' '); bufAppend(' ');
p->expr_1->accept(this); p->expr_1->accept(this);
bufAppend(' '); bufAppend(' ');
p->expr_2->accept(this); p->expr_2->accept(this);
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitTableAss(TableAss *p) void ShowAbsyn::visitTableAss(TableAss *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("TableAss"); bufAppend("TableAss");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
p->expr_1->accept(this); p->expr_1->accept(this);
bufAppend(' '); bufAppend(' ');
p->expr_2->accept(this); p->expr_2->accept(this);
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitTableIncr(TableIncr *p) void ShowAbsyn::visitTableIncr(TableIncr *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("TableIncr"); bufAppend("TableIncr");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitTableDecr(TableDecr *p) void ShowAbsyn::visitTableDecr(TableDecr *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("TableDecr"); bufAppend("TableDecr");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitIncr(Incr *p) void ShowAbsyn::visitIncr(Incr *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Incr"); bufAppend("Incr");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitDecr(Decr *p) void ShowAbsyn::visitDecr(Decr *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Decr"); bufAppend("Decr");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitRet(Ret *p) void ShowAbsyn::visitRet(Ret *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Ret"); bufAppend("Ret");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitVRet(VRet *p) void ShowAbsyn::visitVRet(VRet *p)
{ {
bufAppend("VRet"); bufAppend("VRet");
} }
void ShowAbsyn::visitCond(Cond *p) void ShowAbsyn::visitCond(Cond *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Cond"); bufAppend("Cond");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->stmt_) p->stmt_->accept(this); if (p->stmt_) p->stmt_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitCondElse(CondElse *p) void ShowAbsyn::visitCondElse(CondElse *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("CondElse"); bufAppend("CondElse");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
p->stmt_1->accept(this); p->stmt_1->accept(this);
bufAppend(' '); bufAppend(' ');
p->stmt_2->accept(this); p->stmt_2->accept(this);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitWhile(While *p) void ShowAbsyn::visitWhile(While *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("While"); bufAppend("While");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->stmt_) p->stmt_->accept(this); if (p->stmt_) p->stmt_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitSExp(SExp *p) void ShowAbsyn::visitSExp(SExp *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("SExp"); bufAppend("SExp");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitForEach(ForEach *p) void ShowAbsyn::visitForEach(ForEach *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ForEa.h"); bufAppend("ForEa.h");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->type_) p->type_->accept(this); if (p->type_) p->type_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->stmt_) p->stmt_->accept(this); if (p->stmt_) p->stmt_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitItem(Item *p) {} //abstract class void ShowAbsyn::visitItem(Item *p) {} //abstract class
void ShowAbsyn::visitNoInit(NoInit *p) void ShowAbsyn::visitNoInit(NoInit *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("NoInit"); bufAppend("NoInit");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitInit(Init *p) void ShowAbsyn::visitInit(Init *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Init"); bufAppend("Init");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitListItem(ListItem *listitem) void ShowAbsyn::visitListItem(ListItem *listitem)
{ {
for (ListItem::const_iterator i = listitem->begin() ; i != listitem->end() ; ++i) for (ListItem::const_iterator i = listitem->begin() ; i != listitem->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (i != listitem->end() - 1) bufAppend(", "); if (i != listitem->end() - 1) bufAppend(", ");
} }
} }
void ShowAbsyn::visitType(Type *p) {} //abstract class void ShowAbsyn::visitType(Type *p) {} //abstract class
void ShowAbsyn::visitInt(Int *p) void ShowAbsyn::visitInt(Int *p)
{ {
bufAppend("Int"); bufAppend("Int");
} }
void ShowAbsyn::visitStr(Str *p) void ShowAbsyn::visitStr(Str *p)
{ {
bufAppend("Str"); bufAppend("Str");
} }
void ShowAbsyn::visitBool(Bool *p) void ShowAbsyn::visitBool(Bool *p)
{ {
bufAppend("Bool"); bufAppend("Bool");
} }
void ShowAbsyn::visitVoid(Void *p) void ShowAbsyn::visitVoid(Void *p)
{ {
bufAppend("Void"); bufAppend("Void");
} }
void ShowAbsyn::visitArray(Array *p) void ShowAbsyn::visitArray(Array *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Array"); bufAppend("Array");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->type_) p->type_->accept(this); if (p->type_) p->type_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitClassT(ClassT *p) void ShowAbsyn::visitClassT(ClassT *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ClassT"); bufAppend("ClassT");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitFun(Fun *p) void ShowAbsyn::visitFun(Fun *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Fun"); bufAppend("Fun");
bufAppend(' '); bufAppend(' ');
/* Internal Category */ /* Internal Category */
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->type_) p->type_->accept(this); if (p->type_) p->type_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->listtype_) p->listtype_->accept(this); if (p->listtype_) p->listtype_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitListType(ListType *listtype) void ShowAbsyn::visitListType(ListType *listtype)
{ {
for (ListType::const_iterator i = listtype->begin() ; i != listtype->end() ; ++i) for (ListType::const_iterator i = listtype->begin() ; i != listtype->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (i != listtype->end() - 1) bufAppend(", "); if (i != listtype->end() - 1) bufAppend(", ");
} }
} }
void ShowAbsyn::visitExpr(Expr *p) {} //abstract class void ShowAbsyn::visitExpr(Expr *p) {} //abstract class
void ShowAbsyn::visitEVar(EVar *p) void ShowAbsyn::visitEVar(EVar *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("EVar"); bufAppend("EVar");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitELitInt(ELitInt *p) void ShowAbsyn::visitELitInt(ELitInt *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ELitInt"); bufAppend("ELitInt");
bufAppend(' '); bufAppend(' ');
visitInteger(p->integer_); visitInteger(p->integer_);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitELitTrue(ELitTrue *p) void ShowAbsyn::visitELitTrue(ELitTrue *p)
{ {
bufAppend("ELitTrue"); bufAppend("ELitTrue");
} }
void ShowAbsyn::visitELitFalse(ELitFalse *p) void ShowAbsyn::visitELitFalse(ELitFalse *p)
{ {
bufAppend("ELitFalse"); bufAppend("ELitFalse");
} }
void ShowAbsyn::visitEApp(EApp *p) void ShowAbsyn::visitEApp(EApp *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("EApp"); bufAppend("EApp");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->listexpr_) p->listexpr_->accept(this); if (p->listexpr_) p->listexpr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitEString(EString *p) void ShowAbsyn::visitEString(EString *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("EString"); bufAppend("EString");
bufAppend(' '); bufAppend(' ');
visitString(p->string_); visitString(p->string_);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitENewArray(ENewArray *p) void ShowAbsyn::visitENewArray(ENewArray *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ENewArray"); bufAppend("ENewArray");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->type_) p->type_->accept(this); if (p->type_) p->type_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitENewClass(ENewClass *p) void ShowAbsyn::visitENewClass(ENewClass *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ENewClass"); bufAppend("ENewClass");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitEClsMmbr(EClsMmbr *p) void ShowAbsyn::visitEClsMmbr(EClsMmbr *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("EClsMmbr"); bufAppend("EClsMmbr");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitEClsMthd(EClsMthd *p) void ShowAbsyn::visitEClsMthd(EClsMthd *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("EClsMthd"); bufAppend("EClsMthd");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->listexpr_) p->listexpr_->accept(this); if (p->listexpr_) p->listexpr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitNull(Null *p) void ShowAbsyn::visitNull(Null *p)
{ {
bufAppend("Null"); bufAppend("Null");
} }
void ShowAbsyn::visitEIndexAcc(EIndexAcc *p) void ShowAbsyn::visitEIndexAcc(EIndexAcc *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("EIndexAcc"); bufAppend("EIndexAcc");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitECast(ECast *p) void ShowAbsyn::visitECast(ECast *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ECast"); bufAppend("ECast");
bufAppend(' '); bufAppend(' ');
visitPIdent(p->pident_); visitPIdent(p->pident_);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitNeg(Neg *p) void ShowAbsyn::visitNeg(Neg *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Neg"); bufAppend("Neg");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitNot(Not *p) void ShowAbsyn::visitNot(Not *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("Not"); bufAppend("Not");
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->expr_) p->expr_->accept(this); if (p->expr_) p->expr_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitEMul(EMul *p) void ShowAbsyn::visitEMul(EMul *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("EMul"); bufAppend("EMul");
bufAppend(' '); bufAppend(' ');
p->expr_1->accept(this); p->expr_1->accept(this);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->mulop_) p->mulop_->accept(this); if (p->mulop_) p->mulop_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
p->expr_2->accept(this); p->expr_2->accept(this);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitEAdd(EAdd *p) void ShowAbsyn::visitEAdd(EAdd *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("EAdd"); bufAppend("EAdd");
bufAppend(' '); bufAppend(' ');
p->expr_1->accept(this); p->expr_1->accept(this);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->addop_) p->addop_->accept(this); if (p->addop_) p->addop_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
p->expr_2->accept(this); p->expr_2->accept(this);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitERel(ERel *p) void ShowAbsyn::visitERel(ERel *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("ERel"); bufAppend("ERel");
bufAppend(' '); bufAppend(' ');
p->expr_1->accept(this); p->expr_1->accept(this);
bufAppend(' '); bufAppend(' ');
bufAppend('['); bufAppend('[');
if (p->relop_) p->relop_->accept(this); if (p->relop_) p->relop_->accept(this);
bufAppend(']'); bufAppend(']');
bufAppend(' '); bufAppend(' ');
p->expr_2->accept(this); p->expr_2->accept(this);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitEAnd(EAnd *p) void ShowAbsyn::visitEAnd(EAnd *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("EAnd"); bufAppend("EAnd");
bufAppend(' '); bufAppend(' ');
p->expr_1->accept(this); p->expr_1->accept(this);
bufAppend(' '); bufAppend(' ');
p->expr_2->accept(this); p->expr_2->accept(this);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitEOr(EOr *p) void ShowAbsyn::visitEOr(EOr *p)
{ {
bufAppend('('); bufAppend('(');
bufAppend("EOr"); bufAppend("EOr");
bufAppend(' '); bufAppend(' ');
p->expr_1->accept(this); p->expr_1->accept(this);
bufAppend(' '); bufAppend(' ');
p->expr_2->accept(this); p->expr_2->accept(this);
bufAppend(')'); bufAppend(')');
} }
void ShowAbsyn::visitListExpr(ListExpr *listexpr) void ShowAbsyn::visitListExpr(ListExpr *listexpr)
{ {
for (ListExpr::const_iterator i = listexpr->begin() ; i != listexpr->end() ; ++i) for (ListExpr::const_iterator i = listexpr->begin() ; i != listexpr->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (i != listexpr->end() - 1) bufAppend(", "); if (i != listexpr->end() - 1) bufAppend(", ");
} }
} }
void ShowAbsyn::visitAddOp(AddOp *p) {} //abstract class void ShowAbsyn::visitAddOp(AddOp *p) {} //abstract class
void ShowAbsyn::visitPlus(Plus *p) void ShowAbsyn::visitPlus(Plus *p)
{ {
bufAppend("Plus"); bufAppend("Plus");
} }
void ShowAbsyn::visitMinus(Minus *p) void ShowAbsyn::visitMinus(Minus *p)
{ {
bufAppend("Minus"); bufAppend("Minus");
} }
void ShowAbsyn::visitMulOp(MulOp *p) {} //abstract class void ShowAbsyn::visitMulOp(MulOp *p) {} //abstract class
void ShowAbsyn::visitTimes(Times *p) void ShowAbsyn::visitTimes(Times *p)
{ {
bufAppend("Times"); bufAppend("Times");
} }
void ShowAbsyn::visitDiv(Div *p) void ShowAbsyn::visitDiv(Div *p)
{ {
bufAppend("Div"); bufAppend("Div");
} }
void ShowAbsyn::visitMod(Mod *p) void ShowAbsyn::visitMod(Mod *p)
{ {
bufAppend("Mod"); bufAppend("Mod");
} }
void ShowAbsyn::visitRelOp(RelOp *p) {} //abstract class void ShowAbsyn::visitRelOp(RelOp *p) {} //abstract class
void ShowAbsyn::visitLTH(LTH *p) void ShowAbsyn::visitLTH(LTH *p)
{ {
bufAppend("L.h"); bufAppend("L.h");
} }
void ShowAbsyn::visitLE(LE *p) void ShowAbsyn::visitLE(LE *p)
{ {
bufAppend("LE"); bufAppend("LE");
} }
void ShowAbsyn::visitGTH(GTH *p) void ShowAbsyn::visitGTH(GTH *p)
{ {
bufAppend("G.h"); bufAppend("G.h");
} }
void ShowAbsyn::visitGE(GE *p) void ShowAbsyn::visitGE(GE *p)
{ {
bufAppend("GE"); bufAppend("GE");
} }
void ShowAbsyn::visitEQU(EQU *p) void ShowAbsyn::visitEQU(EQU *p)
{ {
bufAppend("EQU"); bufAppend("EQU");
} }
void ShowAbsyn::visitNE(NE *p) void ShowAbsyn::visitNE(NE *p)
{ {
bufAppend("NE"); bufAppend("NE");
} }
void ShowAbsyn::visitInteger(Integer i) void ShowAbsyn::visitInteger(Integer i)
{ {
char tmp[16]; char tmp[16];
sprintf(tmp, "%d", i); sprintf(tmp, "%d", i);
bufAppend(tmp); bufAppend(tmp);
} }
void ShowAbsyn::visitDouble(Double d) void ShowAbsyn::visitDouble(Double d)
{ {
char tmp[16]; char tmp[16];
sprintf(tmp, "%g", d); sprintf(tmp, "%g", d);
bufAppend(tmp); bufAppend(tmp);
} }
void ShowAbsyn::visitChar(Char c) void ShowAbsyn::visitChar(Char c)
{ {
bufAppend('\''); bufAppend('\'');
bufAppend(c); bufAppend(c);
bufAppend('\''); bufAppend('\'');
} }
void ShowAbsyn::visitString(String s) void ShowAbsyn::visitString(String s)
{ {
bufAppend('\"'); bufAppend('\"');
bufAppend(s); bufAppend(s);
bufAppend('\"'); bufAppend('\"');
} }
void ShowAbsyn::visitIdent(String s) void ShowAbsyn::visitIdent(String s)
{ {
bufAppend('\"'); bufAppend('\"');
bufAppend(s); bufAppend(s);
bufAppend('\"'); bufAppend('\"');
} }
void ShowAbsyn::visitPIdent(String s) void ShowAbsyn::visitPIdent(String s)
{ {
bufAppend('\"'); bufAppend('\"');
bufAppend(s); bufAppend(s);
bufAppend('\"'); bufAppend('\"');
} }
......
...@@ -16,181 +16,181 @@ ...@@ -16,181 +16,181 @@
class PrintAbsyn : public Visitor class PrintAbsyn : public Visitor
{ {
protected: protected:
int _n_, _i_; int _n_, _i_;
/* The following are simple heuristics for rendering terminals */ /* The following are simple heuristics for rendering terminals */
/* You may wish to change them */ /* You may wish to change them */
void render(Char c); void render(Char c);
void render(String s); void render(String s);
void render(const char *s); void render(const char *s);
void indent(void); void indent(void);
void backup(void); void backup(void);
public: public:
PrintAbsyn(void); PrintAbsyn(void);
~PrintAbsyn(void); ~PrintAbsyn(void);
char *print(Visitable *v); char *print(Visitable *v);
void visitPIdent(PIdent *p); void visitPIdent(PIdent *p);
void visitProgram(Program *p); /* abstract class */ void visitProgram(Program *p); /* abstract class */
void visitProg(Prog *p); void visitProg(Prog *p);
void visitTopDef(TopDef *p); /* abstract class */ void visitTopDef(TopDef *p); /* abstract class */
void visitFnDef(FnDef *p); void visitFnDef(FnDef *p);
void visitClDef(ClDef *p); void visitClDef(ClDef *p);
void visitListTopDef(ListTopDef *p); void visitListTopDef(ListTopDef *p);
void visitFunDef(FunDef *p); /* abstract class */ void visitFunDef(FunDef *p); /* abstract class */
void visitFuncDef(FuncDef *p); void visitFuncDef(FuncDef *p);
void visitArg(Arg *p); /* abstract class */ void visitArg(Arg *p); /* abstract class */
void visitAr(Ar *p); void visitAr(Ar *p);
void visitListArg(ListArg *p); void visitListArg(ListArg *p);
void visitClassDef(ClassDef *p); /* abstract class */ void visitClassDef(ClassDef *p); /* abstract class */
void visitClassDefN(ClassDefN *p); void visitClassDefN(ClassDefN *p);
void visitClassDefE(ClassDefE *p); void visitClassDefE(ClassDefE *p);
void visitClassBlock(ClassBlock *p); /* abstract class */ void visitClassBlock(ClassBlock *p); /* abstract class */
void visitClassBl(ClassBl *p); void visitClassBl(ClassBl *p);
void visitClassBlockDef(ClassBlockDef *p); /* abstract class */ void visitClassBlockDef(ClassBlockDef *p); /* abstract class */
void visitClassMthd(ClassMthd *p); void visitClassMthd(ClassMthd *p);
void visitClassFld(ClassFld *p); void visitClassFld(ClassFld *p);
void visitListClassBlockDef(ListClassBlockDef *p); void visitListClassBlockDef(ListClassBlockDef *p);
void visitBlock(Block *p); /* abstract class */ void visitBlock(Block *p); /* abstract class */
void visitBlk(Blk *p); void visitBlk(Blk *p);
void visitListStmt(ListStmt *p); void visitListStmt(ListStmt *p);
void visitStmt(Stmt *p); /* abstract class */ void visitStmt(Stmt *p); /* abstract class */
void visitEmpty(Empty *p); void visitEmpty(Empty *p);
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 visitTableAss(TableAss *p);
void visitTableIncr(TableIncr *p); void visitTableIncr(TableIncr *p);
void visitTableDecr(TableDecr *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);
void visitVRet(VRet *p); void visitVRet(VRet *p);
void visitCond(Cond *p); void visitCond(Cond *p);
void visitCondElse(CondElse *p); void visitCondElse(CondElse *p);
void visitWhile(While *p); void visitWhile(While *p);
void visitSExp(SExp *p); void visitSExp(SExp *p);
void visitForEach(ForEach *p); void visitForEach(ForEach *p);
void visitItem(Item *p); /* abstract class */ void visitItem(Item *p); /* abstract class */
void visitNoInit(NoInit *p); void visitNoInit(NoInit *p);
void visitInit(Init *p); void visitInit(Init *p);
void visitListItem(ListItem *p); void visitListItem(ListItem *p);
void visitType(Type *p); /* abstract class */ void visitType(Type *p); /* abstract class */
void visitInt(Int *p); void visitInt(Int *p);
void visitStr(Str *p); void visitStr(Str *p);
void visitBool(Bool *p); void visitBool(Bool *p);
void visitVoid(Void *p); void visitVoid(Void *p);
void visitArray(Array *p); void visitArray(Array *p);
void visitClassT(ClassT *p); void visitClassT(ClassT *p);
void visitFun(Fun *p); void visitFun(Fun *p);
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 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 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 visitEClsMmbr(EClsMmbr *p);
void visitEClsMthd(EClsMthd *p); void visitEClsMthd(EClsMthd *p);
void visitNull(Null *p); void visitNull(Null *p);
void visitEIndexAcc(EIndexAcc *p); void visitEIndexAcc(EIndexAcc *p);
void visitECast(ECast *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);
void visitEAdd(EAdd *p); void visitEAdd(EAdd *p);
void visitERel(ERel *p); void visitERel(ERel *p);
void visitEAnd(EAnd *p); void visitEAnd(EAnd *p);
void visitEOr(EOr *p); void visitEOr(EOr *p);
void visitListExpr(ListExpr *p); void visitListExpr(ListExpr *p);
void visitAddOp(AddOp *p); /* abstract class */ void visitAddOp(AddOp *p); /* abstract class */
void visitPlus(Plus *p); void visitPlus(Plus *p);
void visitMinus(Minus *p); void visitMinus(Minus *p);
void visitMulOp(MulOp *p); /* abstract class */ void visitMulOp(MulOp *p); /* abstract class */
void visitTimes(Times *p); void visitTimes(Times *p);
void visitDiv(Div *p); void visitDiv(Div *p);
void visitMod(Mod *p); void visitMod(Mod *p);
void visitRelOp(RelOp *p); /* abstract class */ void visitRelOp(RelOp *p); /* abstract class */
void visitLTH(LTH *p); void visitLTH(LTH *p);
void visitLE(LE *p); void visitLE(LE *p);
void visitGTH(GTH *p); void visitGTH(GTH *p);
void visitGE(GE *p); void visitGE(GE *p);
void visitEQU(EQU *p); void visitEQU(EQU *p);
void visitNE(NE *p); void visitNE(NE *p);
void visitInteger(Integer i); void visitInteger(Integer i);
void visitDouble(Double d); void visitDouble(Double d);
void visitChar(Char c); void visitChar(Char c);
void visitString(String s); void visitString(String s);
void visitIdent(String s); void visitIdent(String s);
void visitPIdent(String s); void visitPIdent(String s);
protected: protected:
char *buf_; char *buf_;
int cur_, buf_size; int cur_, buf_size;
void inline bufAppend(const char *s) void inline bufAppend(const char *s)
{ {
int len = strlen(s); int len = strlen(s);
while (cur_ + len >= buf_size) while (cur_ + len >= buf_size)
{ {
buf_size *= 2; /* Double the buffer size */ buf_size *= 2; /* Double the buffer size */
} }
resizeBuffer(); resizeBuffer();
for(int n = 0; n < len; n++) for(int n = 0; n < len; n++)
{ {
buf_[cur_ + n] = s[n]; buf_[cur_ + n] = s[n];
} }
cur_ += len; cur_ += len;
buf_[cur_] = 0; buf_[cur_] = 0;
} }
void inline bufAppend(const char c) void inline bufAppend(const char c)
{ {
if (cur_ >= buf_size) if (cur_ >= buf_size)
{ {
buf_size *= 2; /* Double the buffer size */ buf_size *= 2; /* Double the buffer size */
resizeBuffer(); resizeBuffer();
} }
buf_[cur_] = c; buf_[cur_] = c;
cur_++; cur_++;
buf_[cur_] = 0; buf_[cur_] = 0;
} }
void inline bufAppend(String str) void inline bufAppend(String str)
{ {
const char *s = str.c_str(); const char *s = str.c_str();
bufAppend(s); bufAppend(s);
} }
void inline bufReset(void) void inline bufReset(void)
{ {
if (buf_) free(buf_); if (buf_) free(buf_);
buf_size = BUFFER_INITIAL; buf_size = BUFFER_INITIAL;
buf_ = (char *) malloc(buf_size); buf_ = (char *) malloc(buf_size);
if (!buf_) { if (!buf_) {
fprintf(stderr, "Error: Out of memory while allocating buffer!\n"); fprintf(stderr, "Error: Out of memory while allocating buffer!\n");
exit(1); exit(1);
} }
memset(buf_, 0, buf_size); memset(buf_, 0, buf_size);
cur_ = 0; cur_ = 0;
} }
void inline resizeBuffer(void) void inline resizeBuffer(void)
{ {
char *temp = (char *) malloc(buf_size); char *temp = (char *) malloc(buf_size);
if (!temp) if (!temp)
{ {
fprintf(stderr, "Error: Out of memory while attempting to grow buffer!\n"); fprintf(stderr, "Error: Out of memory while attempting to grow buffer!\n");
exit(1); exit(1);
} }
if (buf_) if (buf_)
{ {
strcpy(temp, buf_); strcpy(temp, buf_);
free(buf_); free(buf_);
} }
buf_ = temp; buf_ = temp;
} }
}; };
...@@ -198,172 +198,172 @@ class PrintAbsyn : public Visitor ...@@ -198,172 +198,172 @@ class PrintAbsyn : public Visitor
class ShowAbsyn : public Visitor class ShowAbsyn : public Visitor
{ {
public: public:
ShowAbsyn(void); ShowAbsyn(void);
~ShowAbsyn(void); ~ShowAbsyn(void);
char *show(Visitable *v); char *show(Visitable *v);
void visitPIdent(PIdent *p); void visitPIdent(PIdent *p);
void visitProgram(Program *p); /* abstract class */ void visitProgram(Program *p); /* abstract class */
void visitProg(Prog *p); void visitProg(Prog *p);
void visitTopDef(TopDef *p); /* abstract class */ void visitTopDef(TopDef *p); /* abstract class */
void visitFnDef(FnDef *p); void visitFnDef(FnDef *p);
void visitClDef(ClDef *p); void visitClDef(ClDef *p);
void visitListTopDef(ListTopDef *p); void visitListTopDef(ListTopDef *p);
void visitFunDef(FunDef *p); /* abstract class */ void visitFunDef(FunDef *p); /* abstract class */
void visitFuncDef(FuncDef *p); void visitFuncDef(FuncDef *p);
void visitArg(Arg *p); /* abstract class */ void visitArg(Arg *p); /* abstract class */
void visitAr(Ar *p); void visitAr(Ar *p);
void visitListArg(ListArg *p); void visitListArg(ListArg *p);
void visitClassDef(ClassDef *p); /* abstract class */ void visitClassDef(ClassDef *p); /* abstract class */
void visitClassDefN(ClassDefN *p); void visitClassDefN(ClassDefN *p);
void visitClassDefE(ClassDefE *p); void visitClassDefE(ClassDefE *p);
void visitClassBlock(ClassBlock *p); /* abstract class */ void visitClassBlock(ClassBlock *p); /* abstract class */
void visitClassBl(ClassBl *p); void visitClassBl(ClassBl *p);
void visitClassBlockDef(ClassBlockDef *p); /* abstract class */ void visitClassBlockDef(ClassBlockDef *p); /* abstract class */
void visitClassMthd(ClassMthd *p); void visitClassMthd(ClassMthd *p);
void visitClassFld(ClassFld *p); void visitClassFld(ClassFld *p);
void visitListClassBlockDef(ListClassBlockDef *p); void visitListClassBlockDef(ListClassBlockDef *p);
void visitBlock(Block *p); /* abstract class */ void visitBlock(Block *p); /* abstract class */
void visitBlk(Blk *p); void visitBlk(Blk *p);
void visitListStmt(ListStmt *p); void visitListStmt(ListStmt *p);
void visitStmt(Stmt *p); /* abstract class */ void visitStmt(Stmt *p); /* abstract class */
void visitEmpty(Empty *p); void visitEmpty(Empty *p);
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 visitTableAss(TableAss *p);
void visitTableIncr(TableIncr *p); void visitTableIncr(TableIncr *p);
void visitTableDecr(TableDecr *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);
void visitVRet(VRet *p); void visitVRet(VRet *p);
void visitCond(Cond *p); void visitCond(Cond *p);
void visitCondElse(CondElse *p); void visitCondElse(CondElse *p);
void visitWhile(While *p); void visitWhile(While *p);
void visitSExp(SExp *p); void visitSExp(SExp *p);
void visitForEach(ForEach *p); void visitForEach(ForEach *p);
void visitItem(Item *p); /* abstract class */ void visitItem(Item *p); /* abstract class */
void visitNoInit(NoInit *p); void visitNoInit(NoInit *p);
void visitInit(Init *p); void visitInit(Init *p);
void visitListItem(ListItem *p); void visitListItem(ListItem *p);
void visitType(Type *p); /* abstract class */ void visitType(Type *p); /* abstract class */
void visitInt(Int *p); void visitInt(Int *p);
void visitStr(Str *p); void visitStr(Str *p);
void visitBool(Bool *p); void visitBool(Bool *p);
void visitVoid(Void *p); void visitVoid(Void *p);
void visitArray(Array *p); void visitArray(Array *p);
void visitClassT(ClassT *p); void visitClassT(ClassT *p);
void visitFun(Fun *p); void visitFun(Fun *p);
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 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 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 visitEClsMmbr(EClsMmbr *p);
void visitEClsMthd(EClsMthd *p); void visitEClsMthd(EClsMthd *p);
void visitNull(Null *p); void visitNull(Null *p);
void visitEIndexAcc(EIndexAcc *p); void visitEIndexAcc(EIndexAcc *p);
void visitECast(ECast *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);
void visitEAdd(EAdd *p); void visitEAdd(EAdd *p);
void visitERel(ERel *p); void visitERel(ERel *p);
void visitEAnd(EAnd *p); void visitEAnd(EAnd *p);
void visitEOr(EOr *p); void visitEOr(EOr *p);
void visitListExpr(ListExpr *p); void visitListExpr(ListExpr *p);
void visitAddOp(AddOp *p); /* abstract class */ void visitAddOp(AddOp *p); /* abstract class */
void visitPlus(Plus *p); void visitPlus(Plus *p);
void visitMinus(Minus *p); void visitMinus(Minus *p);
void visitMulOp(MulOp *p); /* abstract class */ void visitMulOp(MulOp *p); /* abstract class */
void visitTimes(Times *p); void visitTimes(Times *p);
void visitDiv(Div *p); void visitDiv(Div *p);
void visitMod(Mod *p); void visitMod(Mod *p);
void visitRelOp(RelOp *p); /* abstract class */ void visitRelOp(RelOp *p); /* abstract class */
void visitLTH(LTH *p); void visitLTH(LTH *p);
void visitLE(LE *p); void visitLE(LE *p);
void visitGTH(GTH *p); void visitGTH(GTH *p);
void visitGE(GE *p); void visitGE(GE *p);
void visitEQU(EQU *p); void visitEQU(EQU *p);
void visitNE(NE *p); void visitNE(NE *p);
void visitInteger(Integer i); void visitInteger(Integer i);
void visitDouble(Double d); void visitDouble(Double d);
void visitChar(Char c); void visitChar(Char c);
void visitString(String s); void visitString(String s);
void visitIdent(String s); void visitIdent(String s);
void visitPIdent(String s); void visitPIdent(String s);
protected: protected:
char *buf_; char *buf_;
int cur_, buf_size; int cur_, buf_size;
void inline bufAppend(const char *s) void inline bufAppend(const char *s)
{ {
int len = strlen(s); int len = strlen(s);
while (cur_ + len >= buf_size) while (cur_ + len >= buf_size)
{ {
buf_size *= 2; /* Double the buffer size */ buf_size *= 2; /* Double the buffer size */
} }
resizeBuffer(); resizeBuffer();
for(int n = 0; n < len; n++) for(int n = 0; n < len; n++)
{ {
buf_[cur_ + n] = s[n]; buf_[cur_ + n] = s[n];
} }
cur_ += len; cur_ += len;
buf_[cur_] = 0; buf_[cur_] = 0;
} }
void inline bufAppend(const char c) void inline bufAppend(const char c)
{ {
if (cur_ >= buf_size) if (cur_ >= buf_size)
{ {
buf_size *= 2; /* Double the buffer size */ buf_size *= 2; /* Double the buffer size */
resizeBuffer(); resizeBuffer();
} }
buf_[cur_] = c; buf_[cur_] = c;
cur_++; cur_++;
buf_[cur_] = 0; buf_[cur_] = 0;
} }
void inline bufAppend(String str) void inline bufAppend(String str)
{ {
const char *s = str.c_str(); const char *s = str.c_str();
bufAppend(s); bufAppend(s);
} }
void inline bufReset(void) void inline bufReset(void)
{ {
if (buf_) free(buf_); if (buf_) free(buf_);
buf_size = BUFFER_INITIAL; buf_size = BUFFER_INITIAL;
buf_ = (char *) malloc(buf_size); buf_ = (char *) malloc(buf_size);
if (!buf_) { if (!buf_) {
fprintf(stderr, "Error: Out of memory while allocating buffer!\n"); fprintf(stderr, "Error: Out of memory while allocating buffer!\n");
exit(1); exit(1);
} }
memset(buf_, 0, buf_size); memset(buf_, 0, buf_size);
cur_ = 0; cur_ = 0;
} }
void inline resizeBuffer(void) void inline resizeBuffer(void)
{ {
char *temp = (char *) malloc(buf_size); char *temp = (char *) malloc(buf_size);
if (!temp) if (!temp)
{ {
fprintf(stderr, "Error: Out of memory while attempting to grow buffer!\n"); fprintf(stderr, "Error: Out of memory while attempting to grow buffer!\n");
exit(1); exit(1);
} }
if (buf_) if (buf_)
{ {
strcpy(temp, buf_); strcpy(temp, buf_);
free(buf_); free(buf_);
} }
buf_ = temp; buf_ = temp;
} }
}; };
......
/*** BNFC-Generated Visitor Design Pattern Skeleton. ***/ /*** BNFC-Generated Visitor Design Pattern Skeleton. ***/
/* This implements the common visitor design pattern. /* This implements the common visitor design pattern.
Note that this method uses Visitor-traversal of lists, so Note that this method uses Visitor-traversal of lists, so
List->accept() does NOT traverse the list. This allows different List->accept() does NOT traverse the list. This allows different
algorithms to use context information differently. */ algorithms to use context information differently. */
#include "Skeleton.h" #include "Skeleton.h"
...@@ -26,563 +26,563 @@ void Skeleton::visitRelOp(RelOp *t) {} //abstract class ...@@ -26,563 +26,563 @@ void Skeleton::visitRelOp(RelOp *t) {} //abstract class
void Skeleton::visitPIdent(PIdent *p_ident) void Skeleton::visitPIdent(PIdent *p_ident)
{ {
/* Code For PIdent Goes Here */ /* Code For PIdent Goes Here */
visitString(p_ident->string_); visitString(p_ident->string_);
visitInteger(p_ident->integer_); visitInteger(p_ident->integer_);
} }
void Skeleton::visitProg(Prog *prog) void Skeleton::visitProg(Prog *prog)
{ {
/* Code For Prog Goes Here */ /* Code For Prog Goes Here */
prog->listtopdef_->accept(this); prog->listtopdef_->accept(this);
} }
void Skeleton::visitFnDef(FnDef *fn_def) void Skeleton::visitFnDef(FnDef *fn_def)
{ {
/* Code For FnDef Goes Here */ /* Code For FnDef Goes Here */
fn_def->fundef_->accept(this); fn_def->fundef_->accept(this);
} }
void Skeleton::visitClDef(ClDef *cl_def) void Skeleton::visitClDef(ClDef *cl_def)
{ {
/* Code For ClDef Goes Here */ /* Code For ClDef Goes Here */
cl_def->classdef_->accept(this); cl_def->classdef_->accept(this);
} }
void Skeleton::visitFuncDef(FuncDef *func_def) void Skeleton::visitFuncDef(FuncDef *func_def)
{ {
/* Code For FuncDef Goes Here */ /* Code For FuncDef Goes Here */
func_def->type_->accept(this); func_def->type_->accept(this);
func_def->pident_->accept(this); func_def->pident_->accept(this);
func_def->listarg_->accept(this); func_def->listarg_->accept(this);
func_def->block_->accept(this); func_def->block_->accept(this);
} }
void Skeleton::visitAr(Ar *ar) void Skeleton::visitAr(Ar *ar)
{ {
/* Code For Ar Goes Here */ /* Code For Ar Goes Here */
ar->type_->accept(this); ar->type_->accept(this);
ar->pident_->accept(this); ar->pident_->accept(this);
} }
void Skeleton::visitClassDefN(ClassDefN *class_def_n) void Skeleton::visitClassDefN(ClassDefN *class_def_n)
{ {
/* Code For ClassDefN Goes Here */ /* Code For ClassDefN Goes Here */
class_def_n->pident_->accept(this); class_def_n->pident_->accept(this);
class_def_n->classblock_->accept(this); class_def_n->classblock_->accept(this);
} }
void Skeleton::visitClassDefE(ClassDefE *class_def_e) void Skeleton::visitClassDefE(ClassDefE *class_def_e)
{ {
/* Code For ClassDefE Goes Here */ /* Code For ClassDefE Goes Here */
class_def_e->pident_1->accept(this); class_def_e->pident_1->accept(this);
class_def_e->pident_2->accept(this); class_def_e->pident_2->accept(this);
class_def_e->classblock_->accept(this); class_def_e->classblock_->accept(this);
} }
void Skeleton::visitClassBl(ClassBl *class_bl) void Skeleton::visitClassBl(ClassBl *class_bl)
{ {
/* Code For ClassBl Goes Here */ /* Code For ClassBl Goes Here */
class_bl->listclassblockdef_->accept(this); class_bl->listclassblockdef_->accept(this);
} }
void Skeleton::visitClassMthd(ClassMthd *class_mthd) void Skeleton::visitClassMthd(ClassMthd *class_mthd)
{ {
/* Code For ClassMthd Goes Here */ /* Code For ClassMthd Goes Here */
class_mthd->fundef_->accept(this); class_mthd->fundef_->accept(this);
} }
void Skeleton::visitClassFld(ClassFld *class_fld) void Skeleton::visitClassFld(ClassFld *class_fld)
{ {
/* Code For ClassFld Goes Here */ /* Code For ClassFld Goes Here */
class_fld->type_->accept(this); class_fld->type_->accept(this);
class_fld->listitem_->accept(this); class_fld->listitem_->accept(this);
} }
void Skeleton::visitBlk(Blk *blk) void Skeleton::visitBlk(Blk *blk)
{ {
/* Code For Blk Goes Here */ /* Code For Blk Goes Here */
blk->liststmt_->accept(this); blk->liststmt_->accept(this);
} }
void Skeleton::visitEmpty(Empty *empty) void Skeleton::visitEmpty(Empty *empty)
{ {
/* Code For Empty Goes Here */ /* Code For Empty Goes Here */
} }
void Skeleton::visitBStmt(BStmt *b_stmt) void Skeleton::visitBStmt(BStmt *b_stmt)
{ {
/* Code For BStmt Goes Here */ /* Code For BStmt Goes Here */
b_stmt->block_->accept(this); b_stmt->block_->accept(this);
} }
void Skeleton::visitDecl(Decl *decl) void Skeleton::visitDecl(Decl *decl)
{ {
/* Code For Decl Goes Here */ /* Code For Decl Goes Here */
decl->type_->accept(this); decl->type_->accept(this);
decl->listitem_->accept(this); decl->listitem_->accept(this);
} }
void Skeleton::visitAss(Ass *ass) void Skeleton::visitAss(Ass *ass)
{ {
/* Code For Ass Goes Here */ /* Code For Ass Goes Here */
ass->expr_1->accept(this); ass->expr_1->accept(this);
ass->expr_2->accept(this); ass->expr_2->accept(this);
} }
void Skeleton::visitTableAss(TableAss *table_ass) void Skeleton::visitTableAss(TableAss *table_ass)
{ {
/* Code For TableAss Goes Here */ /* Code For TableAss Goes Here */
table_ass->pident_->accept(this); table_ass->pident_->accept(this);
table_ass->expr_1->accept(this); table_ass->expr_1->accept(this);
table_ass->expr_2->accept(this); table_ass->expr_2->accept(this);
} }
void Skeleton::visitTableIncr(TableIncr *table_incr) void Skeleton::visitTableIncr(TableIncr *table_incr)
{ {
/* Code For TableIncr Goes Here */ /* Code For TableIncr Goes Here */
table_incr->pident_->accept(this); table_incr->pident_->accept(this);
table_incr->expr_->accept(this); table_incr->expr_->accept(this);
} }
void Skeleton::visitTableDecr(TableDecr *table_decr) void Skeleton::visitTableDecr(TableDecr *table_decr)
{ {
/* Code For TableDecr Goes Here */ /* Code For TableDecr Goes Here */
table_decr->pident_->accept(this); table_decr->pident_->accept(this);
table_decr->expr_->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->pident_->accept(this);
} }
void Skeleton::visitDecr(Decr *decr) void Skeleton::visitDecr(Decr *decr)
{ {
/* Code For Decr Goes Here */ /* Code For Decr Goes Here */
decr->pident_->accept(this); decr->pident_->accept(this);
} }
void Skeleton::visitRet(Ret *ret) void Skeleton::visitRet(Ret *ret)
{ {
/* Code For Ret Goes Here */ /* Code For Ret Goes Here */
ret->expr_->accept(this); ret->expr_->accept(this);
} }
void Skeleton::visitVRet(VRet *v_ret) void Skeleton::visitVRet(VRet *v_ret)
{ {
/* Code For VRet Goes Here */ /* Code For VRet Goes Here */
} }
void Skeleton::visitCond(Cond *cond) void Skeleton::visitCond(Cond *cond)
{ {
/* Code For Cond Goes Here */ /* Code For Cond Goes Here */
cond->expr_->accept(this); cond->expr_->accept(this);
cond->stmt_->accept(this); cond->stmt_->accept(this);
} }
void Skeleton::visitCondElse(CondElse *cond_else) void Skeleton::visitCondElse(CondElse *cond_else)
{ {
/* Code For CondElse Goes Here */ /* Code For CondElse Goes Here */
cond_else->expr_->accept(this); cond_else->expr_->accept(this);
cond_else->stmt_1->accept(this); cond_else->stmt_1->accept(this);
cond_else->stmt_2->accept(this); cond_else->stmt_2->accept(this);
} }
void Skeleton::visitWhile(While *while_) void Skeleton::visitWhile(While *while_)
{ {
/* Code For While Goes Here */ /* Code For While Goes Here */
while_->expr_->accept(this); while_->expr_->accept(this);
while_->stmt_->accept(this); while_->stmt_->accept(this);
} }
void Skeleton::visitSExp(SExp *s_exp) void Skeleton::visitSExp(SExp *s_exp)
{ {
/* Code For SExp Goes Here */ /* Code For SExp Goes Here */
s_exp->expr_->accept(this); s_exp->expr_->accept(this);
} }
void Skeleton::visitForEach(ForEach *for_each) void Skeleton::visitForEach(ForEach *for_each)
{ {
/* Code For ForEach Goes Here */ /* Code For ForEach Goes Here */
for_each->type_->accept(this); for_each->type_->accept(this);
for_each->pident_->accept(this); for_each->pident_->accept(this);
for_each->expr_->accept(this); for_each->expr_->accept(this);
for_each->stmt_->accept(this); for_each->stmt_->accept(this);
} }
void Skeleton::visitNoInit(NoInit *no_init) void Skeleton::visitNoInit(NoInit *no_init)
{ {
/* Code For NoInit Goes Here */ /* Code For NoInit Goes Here */
no_init->pident_->accept(this); no_init->pident_->accept(this);
} }
void Skeleton::visitInit(Init *init) void Skeleton::visitInit(Init *init)
{ {
/* Code For Init Goes Here */ /* Code For Init Goes Here */
init->pident_->accept(this); init->pident_->accept(this);
init->expr_->accept(this); init->expr_->accept(this);
} }
void Skeleton::visitInt(Int *int_) void Skeleton::visitInt(Int *int_)
{ {
/* Code For Int Goes Here */ /* Code For Int Goes Here */
} }
void Skeleton::visitStr(Str *str) void Skeleton::visitStr(Str *str)
{ {
/* Code For Str Goes Here */ /* Code For Str Goes Here */
} }
void Skeleton::visitBool(Bool *bool_) void Skeleton::visitBool(Bool *bool_)
{ {
/* Code For Bool Goes Here */ /* Code For Bool Goes Here */
} }
void Skeleton::visitVoid(Void *void_) void Skeleton::visitVoid(Void *void_)
{ {
/* Code For Void Goes Here */ /* Code For Void Goes Here */
} }
void Skeleton::visitArray(Array *array) void Skeleton::visitArray(Array *array)
{ {
/* Code For Array Goes Here */ /* Code For Array Goes Here */
array->type_->accept(this); array->type_->accept(this);
} }
void Skeleton::visitClassT(ClassT *class_t) void Skeleton::visitClassT(ClassT *class_t)
{ {
/* Code For ClassT Goes Here */ /* Code For ClassT Goes Here */
class_t->pident_->accept(this); class_t->pident_->accept(this);
} }
void Skeleton::visitFun(Fun *fun) void Skeleton::visitFun(Fun *fun)
{ {
/* Code For Fun Goes Here */ /* Code For Fun Goes Here */
fun->type_->accept(this); fun->type_->accept(this);
fun->listtype_->accept(this); fun->listtype_->accept(this);
} }
void Skeleton::visitEVar(EVar *e_var) void Skeleton::visitEVar(EVar *e_var)
{ {
/* Code For EVar Goes Here */ /* Code For EVar Goes Here */
e_var->pident_->accept(this); e_var->pident_->accept(this);
} }
void Skeleton::visitELitInt(ELitInt *e_lit_int) void Skeleton::visitELitInt(ELitInt *e_lit_int)
{ {
/* Code For ELitInt Goes Here */ /* Code For ELitInt Goes Here */
visitInteger(e_lit_int->integer_); visitInteger(e_lit_int->integer_);
} }
void Skeleton::visitELitTrue(ELitTrue *e_lit_true) void Skeleton::visitELitTrue(ELitTrue *e_lit_true)
{ {
/* Code For ELitTrue Goes Here */ /* Code For ELitTrue Goes Here */
} }
void Skeleton::visitELitFalse(ELitFalse *e_lit_false) void Skeleton::visitELitFalse(ELitFalse *e_lit_false)
{ {
/* Code For ELitFalse Goes Here */ /* Code For ELitFalse Goes Here */
} }
void Skeleton::visitEApp(EApp *e_app) void Skeleton::visitEApp(EApp *e_app)
{ {
/* Code For EApp Goes Here */ /* Code For EApp Goes Here */
e_app->pident_->accept(this); e_app->pident_->accept(this);
e_app->listexpr_->accept(this); e_app->listexpr_->accept(this);
} }
void Skeleton::visitEString(EString *e_string) void Skeleton::visitEString(EString *e_string)
{ {
/* Code For EString Goes Here */ /* Code For EString Goes Here */
visitString(e_string->string_); visitString(e_string->string_);
} }
void Skeleton::visitENewArray(ENewArray *e_new_array) void Skeleton::visitENewArray(ENewArray *e_new_array)
{ {
/* Code For ENewArray Goes Here */ /* Code For ENewArray Goes Here */
e_new_array->type_->accept(this); e_new_array->type_->accept(this);
e_new_array->expr_->accept(this); e_new_array->expr_->accept(this);
} }
void Skeleton::visitENewClass(ENewClass *e_new_class) void Skeleton::visitENewClass(ENewClass *e_new_class)
{ {
/* Code For ENewClass Goes Here */ /* Code For ENewClass Goes Here */
e_new_class->pident_->accept(this); e_new_class->pident_->accept(this);
} }
void Skeleton::visitEClsMmbr(EClsMmbr *e_cls_mmbr) void Skeleton::visitEClsMmbr(EClsMmbr *e_cls_mmbr)
{ {
/* Code For EClsMmbr Goes Here */ /* Code For EClsMmbr Goes Here */
e_cls_mmbr->expr_->accept(this); e_cls_mmbr->expr_->accept(this);
e_cls_mmbr->pident_->accept(this); e_cls_mmbr->pident_->accept(this);
} }
void Skeleton::visitEClsMthd(EClsMthd *e_cls_mthd) void Skeleton::visitEClsMthd(EClsMthd *e_cls_mthd)
{ {
/* Code For EClsMthd Goes Here */ /* Code For EClsMthd Goes Here */
e_cls_mthd->expr_->accept(this); e_cls_mthd->expr_->accept(this);
e_cls_mthd->pident_->accept(this); e_cls_mthd->pident_->accept(this);
e_cls_mthd->listexpr_->accept(this); e_cls_mthd->listexpr_->accept(this);
} }
void Skeleton::visitNull(Null *null) void Skeleton::visitNull(Null *null)
{ {
/* Code For Null Goes Here */ /* Code For Null Goes Here */
} }
void Skeleton::visitEIndexAcc(EIndexAcc *e_index_acc) void Skeleton::visitEIndexAcc(EIndexAcc *e_index_acc)
{ {
/* Code For EIndexAcc Goes Here */ /* Code For EIndexAcc Goes Here */
e_index_acc->pident_->accept(this); e_index_acc->pident_->accept(this);
e_index_acc->expr_->accept(this); e_index_acc->expr_->accept(this);
} }
void Skeleton::visitECast(ECast *e_cast) void Skeleton::visitECast(ECast *e_cast)
{ {
/* Code For ECast Goes Here */ /* Code For ECast Goes Here */
e_cast->pident_->accept(this); e_cast->pident_->accept(this);
e_cast->expr_->accept(this); e_cast->expr_->accept(this);
} }
void Skeleton::visitNeg(Neg *neg) void Skeleton::visitNeg(Neg *neg)
{ {
/* Code For Neg Goes Here */ /* Code For Neg Goes Here */
neg->expr_->accept(this); neg->expr_->accept(this);
} }
void Skeleton::visitNot(Not *not_) void Skeleton::visitNot(Not *not_)
{ {
/* Code For Not Goes Here */ /* Code For Not Goes Here */
not_->expr_->accept(this); not_->expr_->accept(this);
} }
void Skeleton::visitEMul(EMul *e_mul) void Skeleton::visitEMul(EMul *e_mul)
{ {
/* Code For EMul Goes Here */ /* Code For EMul Goes Here */
e_mul->expr_1->accept(this); e_mul->expr_1->accept(this);
e_mul->mulop_->accept(this); e_mul->mulop_->accept(this);
e_mul->expr_2->accept(this); e_mul->expr_2->accept(this);
} }
void Skeleton::visitEAdd(EAdd *e_add) void Skeleton::visitEAdd(EAdd *e_add)
{ {
/* Code For EAdd Goes Here */ /* Code For EAdd Goes Here */
e_add->expr_1->accept(this); e_add->expr_1->accept(this);
e_add->addop_->accept(this); e_add->addop_->accept(this);
e_add->expr_2->accept(this); e_add->expr_2->accept(this);
} }
void Skeleton::visitERel(ERel *e_rel) void Skeleton::visitERel(ERel *e_rel)
{ {
/* Code For ERel Goes Here */ /* Code For ERel Goes Here */
e_rel->expr_1->accept(this); e_rel->expr_1->accept(this);
e_rel->relop_->accept(this); e_rel->relop_->accept(this);
e_rel->expr_2->accept(this); e_rel->expr_2->accept(this);
} }
void Skeleton::visitEAnd(EAnd *e_and) void Skeleton::visitEAnd(EAnd *e_and)
{ {
/* Code For EAnd Goes Here */ /* Code For EAnd Goes Here */
e_and->expr_1->accept(this); e_and->expr_1->accept(this);
e_and->expr_2->accept(this); e_and->expr_2->accept(this);
} }
void Skeleton::visitEOr(EOr *e_or) void Skeleton::visitEOr(EOr *e_or)
{ {
/* Code For EOr Goes Here */ /* Code For EOr Goes Here */
e_or->expr_1->accept(this); e_or->expr_1->accept(this);
e_or->expr_2->accept(this); e_or->expr_2->accept(this);
} }
void Skeleton::visitPlus(Plus *plus) void Skeleton::visitPlus(Plus *plus)
{ {
/* Code For Plus Goes Here */ /* Code For Plus Goes Here */
} }
void Skeleton::visitMinus(Minus *minus) void Skeleton::visitMinus(Minus *minus)
{ {
/* Code For Minus Goes Here */ /* Code For Minus Goes Here */
} }
void Skeleton::visitTimes(Times *times) void Skeleton::visitTimes(Times *times)
{ {
/* Code For Times Goes Here */ /* Code For Times Goes Here */
} }
void Skeleton::visitDiv(Div *div) void Skeleton::visitDiv(Div *div)
{ {
/* Code For Div Goes Here */ /* Code For Div Goes Here */
} }
void Skeleton::visitMod(Mod *mod) void Skeleton::visitMod(Mod *mod)
{ {
/* Code For Mod Goes Here */ /* Code For Mod Goes Here */
} }
void Skeleton::visitLTH(LTH *lth) void Skeleton::visitLTH(LTH *lth)
{ {
/* Code For LTH Goes Here */ /* Code For LTH Goes Here */
} }
void Skeleton::visitLE(LE *le) void Skeleton::visitLE(LE *le)
{ {
/* Code For LE Goes Here */ /* Code For LE Goes Here */
} }
void Skeleton::visitGTH(GTH *gth) void Skeleton::visitGTH(GTH *gth)
{ {
/* Code For GTH Goes Here */ /* Code For GTH Goes Here */
} }
void Skeleton::visitGE(GE *ge) void Skeleton::visitGE(GE *ge)
{ {
/* Code For GE Goes Here */ /* Code For GE Goes Here */
} }
void Skeleton::visitEQU(EQU *equ) void Skeleton::visitEQU(EQU *equ)
{ {
/* Code For EQU Goes Here */ /* Code For EQU Goes Here */
} }
void Skeleton::visitNE(NE *ne) void Skeleton::visitNE(NE *ne)
{ {
/* Code For NE Goes Here */ /* Code For NE Goes Here */
} }
...@@ -590,84 +590,84 @@ void Skeleton::visitNE(NE *ne) ...@@ -590,84 +590,84 @@ void Skeleton::visitNE(NE *ne)
void Skeleton::visitListTopDef(ListTopDef *list_top_def) void Skeleton::visitListTopDef(ListTopDef *list_top_def)
{ {
for (ListTopDef::iterator i = list_top_def->begin() ; i != list_top_def->end() ; ++i) for (ListTopDef::iterator i = list_top_def->begin() ; i != list_top_def->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void Skeleton::visitListArg(ListArg *list_arg) void Skeleton::visitListArg(ListArg *list_arg)
{ {
for (ListArg::iterator i = list_arg->begin() ; i != list_arg->end() ; ++i) for (ListArg::iterator i = list_arg->begin() ; i != list_arg->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void Skeleton::visitListClassBlockDef(ListClassBlockDef *list_class_block_def) void Skeleton::visitListClassBlockDef(ListClassBlockDef *list_class_block_def)
{ {
for (ListClassBlockDef::iterator i = list_class_block_def->begin() ; i != list_class_block_def->end() ; ++i) for (ListClassBlockDef::iterator i = list_class_block_def->begin() ; i != list_class_block_def->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void Skeleton::visitListStmt(ListStmt *list_stmt) void Skeleton::visitListStmt(ListStmt *list_stmt)
{ {
for (ListStmt::iterator i = list_stmt->begin() ; i != list_stmt->end() ; ++i) for (ListStmt::iterator i = list_stmt->begin() ; i != list_stmt->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void Skeleton::visitListItem(ListItem *list_item) void Skeleton::visitListItem(ListItem *list_item)
{ {
for (ListItem::iterator i = list_item->begin() ; i != list_item->end() ; ++i) for (ListItem::iterator i = list_item->begin() ; i != list_item->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void Skeleton::visitListType(ListType *list_type) void Skeleton::visitListType(ListType *list_type)
{ {
for (ListType::iterator i = list_type->begin() ; i != list_type->end() ; ++i) for (ListType::iterator i = list_type->begin() ; i != list_type->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void Skeleton::visitListExpr(ListExpr *list_expr) void Skeleton::visitListExpr(ListExpr *list_expr)
{ {
for (ListExpr::iterator i = list_expr->begin() ; i != list_expr->end() ; ++i) for (ListExpr::iterator i = list_expr->begin() ; i != list_expr->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void Skeleton::visitInteger(Integer x) void Skeleton::visitInteger(Integer x)
{ {
/* Code for Integer Goes Here */ /* Code for Integer Goes Here */
} }
void Skeleton::visitChar(Char x) void Skeleton::visitChar(Char x)
{ {
/* Code for Char Goes Here */ /* Code for Char Goes Here */
} }
void Skeleton::visitDouble(Double x) void Skeleton::visitDouble(Double x)
{ {
/* Code for Double Goes Here */ /* Code for Double Goes Here */
} }
void Skeleton::visitString(String x) void Skeleton::visitString(String x)
{ {
/* Code for String Goes Here */ /* Code for String Goes Here */
} }
void Skeleton::visitIdent(Ident x) void Skeleton::visitIdent(Ident x)
{ {
/* Code for Ident Goes Here */ /* Code for Ident Goes Here */
} }
......
...@@ -8,102 +8,102 @@ ...@@ -8,102 +8,102 @@
class Skeleton : public Visitor class Skeleton : public Visitor
{ {
public: public:
void visitProgram(Program *p); void visitProgram(Program *p);
void visitTopDef(TopDef *p); void visitTopDef(TopDef *p);
void visitFunDef(FunDef *p); void visitFunDef(FunDef *p);
void visitArg(Arg *p); void visitArg(Arg *p);
void visitClassDef(ClassDef *p); void visitClassDef(ClassDef *p);
void visitClassBlock(ClassBlock *p); void visitClassBlock(ClassBlock *p);
void visitClassBlockDef(ClassBlockDef *p); void visitClassBlockDef(ClassBlockDef *p);
void visitBlock(Block *p); void visitBlock(Block *p);
void visitStmt(Stmt *p); void visitStmt(Stmt *p);
void visitItem(Item *p); void visitItem(Item *p);
void visitType(Type *p); void visitType(Type *p);
void visitExpr(Expr *p); void visitExpr(Expr *p);
void visitAddOp(AddOp *p); void visitAddOp(AddOp *p);
void visitMulOp(MulOp *p); void visitMulOp(MulOp *p);
void visitRelOp(RelOp *p); void visitRelOp(RelOp *p);
void visitProg(Prog *p); void visitProg(Prog *p);
void visitFnDef(FnDef *p); void visitFnDef(FnDef *p);
void visitClDef(ClDef *p); void visitClDef(ClDef *p);
void visitFuncDef(FuncDef *p); void visitFuncDef(FuncDef *p);
void visitAr(Ar *p); void visitAr(Ar *p);
void visitClassDefN(ClassDefN *p); void visitClassDefN(ClassDefN *p);
void visitClassDefE(ClassDefE *p); void visitClassDefE(ClassDefE *p);
void visitClassBl(ClassBl *p); void visitClassBl(ClassBl *p);
void visitClassMthd(ClassMthd *p); void visitClassMthd(ClassMthd *p);
void visitClassFld(ClassFld *p); void visitClassFld(ClassFld *p);
void visitBlk(Blk *p); void visitBlk(Blk *p);
void visitEmpty(Empty *p); void visitEmpty(Empty *p);
void visitBStmt(BStmt *p); void visitBStmt(BStmt *p);
void visitDecl(Decl *p); void visitDecl(Decl *p);
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 visitTableAss(TableAss *p);
void visitTableIncr(TableIncr *p); void visitTableIncr(TableIncr *p);
void visitTableDecr(TableDecr *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);
void visitVRet(VRet *p); void visitVRet(VRet *p);
void visitCond(Cond *p); void visitCond(Cond *p);
void visitCondElse(CondElse *p); void visitCondElse(CondElse *p);
void visitWhile(While *p); void visitWhile(While *p);
void visitSExp(SExp *p); void visitSExp(SExp *p);
void visitForEach(ForEach *p); void visitForEach(ForEach *p);
void visitInt(Int *p); void visitInt(Int *p);
void visitStr(Str *p); void visitStr(Str *p);
void visitBool(Bool *p); void visitBool(Bool *p);
void visitVoid(Void *p); void visitVoid(Void *p);
void visitArray(Array *p); void visitArray(Array *p);
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 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 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 visitEClsMmbr(EClsMmbr *p);
void visitEClsMthd(EClsMthd *p); void visitEClsMthd(EClsMthd *p);
void visitNull(Null *p); void visitNull(Null *p);
void visitEIndexAcc(EIndexAcc *p); void visitEIndexAcc(EIndexAcc *p);
void visitECast(ECast *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);
void visitEAdd(EAdd *p); void visitEAdd(EAdd *p);
void visitERel(ERel *p); void visitERel(ERel *p);
void visitEAnd(EAnd *p); void visitEAnd(EAnd *p);
void visitEOr(EOr *p); void visitEOr(EOr *p);
void visitPlus(Plus *p); void visitPlus(Plus *p);
void visitMinus(Minus *p); void visitMinus(Minus *p);
void visitTimes(Times *p); void visitTimes(Times *p);
void visitDiv(Div *p); void visitDiv(Div *p);
void visitMod(Mod *p); void visitMod(Mod *p);
void visitLTH(LTH *p); void visitLTH(LTH *p);
void visitLE(LE *p); void visitLE(LE *p);
void visitGTH(GTH *p); void visitGTH(GTH *p);
void visitGE(GE *p); void visitGE(GE *p);
void visitEQU(EQU *p); void visitEQU(EQU *p);
void visitNE(NE *p); void visitNE(NE *p);
void visitListTopDef(ListTopDef *p); void visitListTopDef(ListTopDef *p);
void visitListArg(ListArg *p); void visitListArg(ListArg *p);
void visitListClassBlockDef(ListClassBlockDef *p); void visitListClassBlockDef(ListClassBlockDef *p);
void visitListStmt(ListStmt *p); void visitListStmt(ListStmt *p);
void visitListItem(ListItem *p); void visitListItem(ListItem *p);
void visitListType(ListType *p); void visitListType(ListType *p);
void visitListExpr(ListExpr *p); void visitListExpr(ListExpr *p);
void visitPIdent(PIdent *p); void visitPIdent(PIdent *p);
void visitInteger(Integer x); void visitInteger(Integer x);
void visitChar(Char x); void visitChar(Char x);
void visitDouble(Double x); void visitDouble(Double x);
void visitString(String x); void visitString(String x);
void visitIdent(Ident x); void visitIdent(Ident x);
}; };
......
...@@ -6,10 +6,10 @@ void TypeCheck::visitTopDef(TopDef *t) {} //abstract class ...@@ -6,10 +6,10 @@ void TypeCheck::visitTopDef(TopDef *t) {} //abstract class
void TypeCheck::visitFunDef(FunDef *t) {} //abstract class void TypeCheck::visitFunDef(FunDef *t) {} //abstract class
void TypeCheck::visitArg(Arg *t) {} //abstract class void TypeCheck::visitArg(Arg *t) {} //abstract class
void TypeCheck::visitClassDef(ClassDef *t) { void TypeCheck::visitClassDef(ClassDef *t) {
t->getName()->accept(this); t->getName()->accept(this);
if (t->getParent()) if (t->getParent())
t->getParent()->accept(this); t->getParent()->accept(this);
t->getBlock()->accept(this); t->getBlock()->accept(this);
} }
void TypeCheck::visitClassBlock(ClassBlock *t) {} //abstract class void TypeCheck::visitClassBlock(ClassBlock *t) {} //abstract class
...@@ -25,554 +25,554 @@ void TypeCheck::visitRelOp(RelOp *t) {} //abstract class ...@@ -25,554 +25,554 @@ void TypeCheck::visitRelOp(RelOp *t) {} //abstract class
void TypeCheck::visitPIdent(PIdent *p_ident) void TypeCheck::visitPIdent(PIdent *p_ident)
{ {
/* Code For PIdent Goes Here */ /* Code For PIdent Goes Here */
visitString(p_ident->string_); visitString(p_ident->string_);
visitInteger(p_ident->integer_); visitInteger(p_ident->integer_);
} }
void TypeCheck::visitProg(Prog *prog) void TypeCheck::visitProg(Prog *prog)
{ {
/* Code For Prog Goes Here */ /* Code For Prog Goes Here */
prog->listtopdef_->accept(this); prog->listtopdef_->accept(this);
} }
void TypeCheck::visitFnDef(FnDef *fn_def) void TypeCheck::visitFnDef(FnDef *fn_def)
{ {
/* Code For FnDef Goes Here */ /* Code For FnDef Goes Here */
fn_def->fundef_->accept(this); fn_def->fundef_->accept(this);
} }
void TypeCheck::visitClDef(ClDef *cl_def) void TypeCheck::visitClDef(ClDef *cl_def)
{ {
/* Code For ClDef Goes Here */ /* Code For ClDef Goes Here */
cl_def->classdef_->accept(this); cl_def->classdef_->accept(this);
} }
void TypeCheck::visitFuncDef(FuncDef *func_def) void TypeCheck::visitFuncDef(FuncDef *func_def)
{ {
/* Code For FuncDef Goes Here */ /* Code For FuncDef Goes Here */
func_def->type_->accept(this); func_def->type_->accept(this);
func_def->pident_->accept(this); func_def->pident_->accept(this);
func_def->listarg_->accept(this); func_def->listarg_->accept(this);
func_def->block_->accept(this); func_def->block_->accept(this);
} }
void TypeCheck::visitAr(Ar *ar) void TypeCheck::visitAr(Ar *ar)
{ {
/* Code For Ar Goes Here */ /* Code For Ar Goes Here */
ar->type_->accept(this); ar->type_->accept(this);
ar->pident_->accept(this); ar->pident_->accept(this);
} }
void TypeCheck::visitClassDefN(ClassDefN *class_def_n) void TypeCheck::visitClassDefN(ClassDefN *class_def_n)
{ {
visitClassDef(class_def_n); visitClassDef(class_def_n);
} }
void TypeCheck::visitClassDefE(ClassDefE *class_def_e) void TypeCheck::visitClassDefE(ClassDefE *class_def_e)
{ {
visitClassDef(class_def_e); visitClassDef(class_def_e);
} }
void TypeCheck::visitClassBl(ClassBl *class_bl) void TypeCheck::visitClassBl(ClassBl *class_bl)
{ {
/* Code For ClassBl Goes Here */ /* Code For ClassBl Goes Here */
class_bl->listclassblockdef_->accept(this); class_bl->listclassblockdef_->accept(this);
} }
void TypeCheck::visitClassMthd(ClassMthd *class_mthd) void TypeCheck::visitClassMthd(ClassMthd *class_mthd)
{ {
/* Code For ClassMthd Goes Here */ /* Code For ClassMthd Goes Here */
class_mthd->fundef_->accept(this); class_mthd->fundef_->accept(this);
} }
void TypeCheck::visitClassFld(ClassFld *class_fld) void TypeCheck::visitClassFld(ClassFld *class_fld)
{ {
/* Code For ClassFld Goes Here */ /* Code For ClassFld Goes Here */
class_fld->type_->accept(this); class_fld->type_->accept(this);
class_fld->listitem_->accept(this); class_fld->listitem_->accept(this);
} }
void TypeCheck::visitBlk(Blk *blk) void TypeCheck::visitBlk(Blk *blk)
{ {
/* Code For Blk Goes Here */ /* Code For Blk Goes Here */
blk->liststmt_->accept(this); blk->liststmt_->accept(this);
} }
void TypeCheck::visitEmpty(Empty *empty) void TypeCheck::visitEmpty(Empty *empty)
{ {
/* Code For Empty Goes Here */ /* Code For Empty Goes Here */
} }
void TypeCheck::visitBStmt(BStmt *b_stmt) void TypeCheck::visitBStmt(BStmt *b_stmt)
{ {
/* Code For BStmt Goes Here */ /* Code For BStmt Goes Here */
b_stmt->block_->accept(this); b_stmt->block_->accept(this);
} }
void TypeCheck::visitDecl(Decl *decl) void TypeCheck::visitDecl(Decl *decl)
{ {
/* Code For Decl Goes Here */ /* Code For Decl Goes Here */
decl->type_->accept(this); decl->type_->accept(this);
decl->listitem_->accept(this); decl->listitem_->accept(this);
} }
void TypeCheck::visitAss(Ass *ass) void TypeCheck::visitAss(Ass *ass)
{ {
/* Code For Ass Goes Here */ /* Code For Ass Goes Here */
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) void TypeCheck::visitTableAss(TableAss *table_ass)
{ {
/* Code For TableAss Goes Here */ /* Code For TableAss Goes Here */
table_ass->pident_->accept(this); table_ass->pident_->accept(this);
table_ass->expr_1->accept(this); table_ass->expr_1->accept(this);
table_ass->expr_2->accept(this); table_ass->expr_2->accept(this);
} }
void TypeCheck::visitTableIncr(TableIncr *table_incr) void TypeCheck::visitTableIncr(TableIncr *table_incr)
{ {
/* Code For TableIncr Goes Here */ /* Code For TableIncr Goes Here */
table_incr->pident_->accept(this); table_incr->pident_->accept(this);
table_incr->expr_->accept(this); table_incr->expr_->accept(this);
} }
void TypeCheck::visitTableDecr(TableDecr *table_decr) void TypeCheck::visitTableDecr(TableDecr *table_decr)
{ {
/* Code For TableDecr Goes Here */ /* Code For TableDecr Goes Here */
table_decr->pident_->accept(this); table_decr->pident_->accept(this);
table_decr->expr_->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->pident_->accept(this);
} }
void TypeCheck::visitDecr(Decr *decr) void TypeCheck::visitDecr(Decr *decr)
{ {
/* Code For Decr Goes Here */ /* Code For Decr Goes Here */
decr->pident_->accept(this); decr->pident_->accept(this);
} }
void TypeCheck::visitRet(Ret *ret) void TypeCheck::visitRet(Ret *ret)
{ {
/* Code For Ret Goes Here */ /* Code For Ret Goes Here */
ret->expr_->accept(this); ret->expr_->accept(this);
} }
void TypeCheck::visitVRet(VRet *v_ret) void TypeCheck::visitVRet(VRet *v_ret)
{ {
/* Code For VRet Goes Here */ /* Code For VRet Goes Here */
} }
void TypeCheck::visitCond(Cond *cond) void TypeCheck::visitCond(Cond *cond)
{ {
/* Code For Cond Goes Here */ /* Code For Cond Goes Here */
cond->expr_->accept(this); cond->expr_->accept(this);
cond->stmt_->accept(this); cond->stmt_->accept(this);
} }
void TypeCheck::visitCondElse(CondElse *cond_else) void TypeCheck::visitCondElse(CondElse *cond_else)
{ {
/* Code For CondElse Goes Here */ /* Code For CondElse Goes Here */
cond_else->expr_->accept(this); cond_else->expr_->accept(this);
cond_else->stmt_1->accept(this); cond_else->stmt_1->accept(this);
cond_else->stmt_2->accept(this); cond_else->stmt_2->accept(this);
} }
void TypeCheck::visitWhile(While *while_) void TypeCheck::visitWhile(While *while_)
{ {
/* Code For While Goes Here */ /* Code For While Goes Here */
while_->expr_->accept(this); while_->expr_->accept(this);
while_->stmt_->accept(this); while_->stmt_->accept(this);
} }
void TypeCheck::visitSExp(SExp *s_exp) void TypeCheck::visitSExp(SExp *s_exp)
{ {
/* Code For SExp Goes Here */ /* Code For SExp Goes Here */
s_exp->expr_->accept(this); s_exp->expr_->accept(this);
} }
void TypeCheck::visitForEach(ForEach *for_each) void TypeCheck::visitForEach(ForEach *for_each)
{ {
/* Code For ForEach Goes Here */ /* Code For ForEach Goes Here */
for_each->type_->accept(this); for_each->type_->accept(this);
for_each->pident_->accept(this); for_each->pident_->accept(this);
for_each->expr_->accept(this); for_each->expr_->accept(this);
for_each->stmt_->accept(this); for_each->stmt_->accept(this);
} }
void TypeCheck::visitNoInit(NoInit *no_init) void TypeCheck::visitNoInit(NoInit *no_init)
{ {
/* Code For NoInit Goes Here */ /* Code For NoInit Goes Here */
no_init->pident_->accept(this); no_init->pident_->accept(this);
} }
void TypeCheck::visitInit(Init *init) void TypeCheck::visitInit(Init *init)
{ {
/* Code For Init Goes Here */ /* Code For Init Goes Here */
init->pident_->accept(this); init->pident_->accept(this);
init->expr_->accept(this); init->expr_->accept(this);
} }
void TypeCheck::visitInt(Int *int_) void TypeCheck::visitInt(Int *int_)
{ {
/* Code For Int Goes Here */ /* Code For Int Goes Here */
} }
void TypeCheck::visitStr(Str *str) void TypeCheck::visitStr(Str *str)
{ {
/* Code For Str Goes Here */ /* Code For Str Goes Here */
} }
void TypeCheck::visitBool(Bool *bool_) void TypeCheck::visitBool(Bool *bool_)
{ {
/* Code For Bool Goes Here */ /* Code For Bool Goes Here */
} }
void TypeCheck::visitVoid(Void *void_) void TypeCheck::visitVoid(Void *void_)
{ {
/* Code For Void Goes Here */ /* Code For Void Goes Here */
} }
void TypeCheck::visitArray(Array *array) void TypeCheck::visitArray(Array *array)
{ {
/* Code For Array Goes Here */ /* Code For Array Goes Here */
array->type_->accept(this); array->type_->accept(this);
} }
void TypeCheck::visitClassT(ClassT *class_t) void TypeCheck::visitClassT(ClassT *class_t)
{ {
/* Code For ClassT Goes Here */ /* Code For ClassT Goes Here */
class_t->pident_->accept(this); class_t->pident_->accept(this);
} }
void TypeCheck::visitFun(Fun *fun) void TypeCheck::visitFun(Fun *fun)
{ {
/* Code For Fun Goes Here */ /* Code For Fun Goes Here */
fun->type_->accept(this); fun->type_->accept(this);
fun->listtype_->accept(this); fun->listtype_->accept(this);
} }
void TypeCheck::visitEVar(EVar *e_var) void TypeCheck::visitEVar(EVar *e_var)
{ {
/* Code For EVar Goes Here */ /* Code For EVar Goes Here */
e_var->pident_->accept(this); e_var->pident_->accept(this);
} }
void TypeCheck::visitELitInt(ELitInt *e_lit_int) void TypeCheck::visitELitInt(ELitInt *e_lit_int)
{ {
/* Code For ELitInt Goes Here */ /* Code For ELitInt Goes Here */
visitInteger(e_lit_int->integer_); visitInteger(e_lit_int->integer_);
} }
void TypeCheck::visitELitTrue(ELitTrue *e_lit_true) void TypeCheck::visitELitTrue(ELitTrue *e_lit_true)
{ {
/* Code For ELitTrue Goes Here */ /* Code For ELitTrue Goes Here */
} }
void TypeCheck::visitELitFalse(ELitFalse *e_lit_false) void TypeCheck::visitELitFalse(ELitFalse *e_lit_false)
{ {
/* Code For ELitFalse Goes Here */ /* Code For ELitFalse Goes Here */
} }
void TypeCheck::visitEApp(EApp *e_app) void TypeCheck::visitEApp(EApp *e_app)
{ {
/* Code For EApp Goes Here */ /* Code For EApp Goes Here */
e_app->pident_->accept(this); e_app->pident_->accept(this);
e_app->listexpr_->accept(this); e_app->listexpr_->accept(this);
} }
void TypeCheck::visitEString(EString *e_string) void TypeCheck::visitEString(EString *e_string)
{ {
/* Code For EString Goes Here */ /* Code For EString Goes Here */
visitString(e_string->string_); visitString(e_string->string_);
} }
void TypeCheck::visitENewArray(ENewArray *e_new_array) void TypeCheck::visitENewArray(ENewArray *e_new_array)
{ {
/* Code For ENewArray Goes Here */ /* Code For ENewArray Goes Here */
e_new_array->type_->accept(this); e_new_array->type_->accept(this);
e_new_array->expr_->accept(this); e_new_array->expr_->accept(this);
} }
void TypeCheck::visitENewClass(ENewClass *e_new_class) void TypeCheck::visitENewClass(ENewClass *e_new_class)
{ {
/* Code For ENewClass Goes Here */ /* Code For ENewClass Goes Here */
e_new_class->pident_->accept(this); e_new_class->pident_->accept(this);
} }
void TypeCheck::visitEClsMmbr(EClsMmbr *e_cls_mmbr) void TypeCheck::visitEClsMmbr(EClsMmbr *e_cls_mmbr)
{ {
/* Code For EClsMmbr Goes Here */ /* Code For EClsMmbr Goes Here */
e_cls_mmbr->expr_->accept(this); e_cls_mmbr->expr_->accept(this);
e_cls_mmbr->pident_->accept(this); e_cls_mmbr->pident_->accept(this);
} }
void TypeCheck::visitEClsMthd(EClsMthd *e_cls_mthd) void TypeCheck::visitEClsMthd(EClsMthd *e_cls_mthd)
{ {
/* Code For EClsMthd Goes Here */ /* Code For EClsMthd Goes Here */
e_cls_mthd->expr_->accept(this); e_cls_mthd->expr_->accept(this);
e_cls_mthd->pident_->accept(this); e_cls_mthd->pident_->accept(this);
e_cls_mthd->listexpr_->accept(this); e_cls_mthd->listexpr_->accept(this);
} }
void TypeCheck::visitNull(Null *null) void TypeCheck::visitNull(Null *null)
{ {
/* Code For Null Goes Here */ /* Code For Null Goes Here */
} }
void TypeCheck::visitEIndexAcc(EIndexAcc *e_index_acc) void TypeCheck::visitEIndexAcc(EIndexAcc *e_index_acc)
{ {
/* Code For EIndexAcc Goes Here */ /* Code For EIndexAcc Goes Here */
e_index_acc->pident_->accept(this); e_index_acc->pident_->accept(this);
e_index_acc->expr_->accept(this); e_index_acc->expr_->accept(this);
} }
void TypeCheck::visitECast(ECast *e_cast) void TypeCheck::visitECast(ECast *e_cast)
{ {
/* Code For ECast Goes Here */ /* Code For ECast Goes Here */
e_cast->pident_->accept(this); e_cast->pident_->accept(this);
e_cast->expr_->accept(this); e_cast->expr_->accept(this);
} }
void TypeCheck::visitNeg(Neg *neg) void TypeCheck::visitNeg(Neg *neg)
{ {
/* Code For Neg Goes Here */ /* Code For Neg Goes Here */
neg->expr_->accept(this); neg->expr_->accept(this);
} }
void TypeCheck::visitNot(Not *not_) void TypeCheck::visitNot(Not *not_)
{ {
/* Code For Not Goes Here */ /* Code For Not Goes Here */
not_->expr_->accept(this); not_->expr_->accept(this);
} }
void TypeCheck::visitEMul(EMul *e_mul) void TypeCheck::visitEMul(EMul *e_mul)
{ {
/* Code For EMul Goes Here */ /* Code For EMul Goes Here */
e_mul->expr_1->accept(this); e_mul->expr_1->accept(this);
e_mul->mulop_->accept(this); e_mul->mulop_->accept(this);
e_mul->expr_2->accept(this); e_mul->expr_2->accept(this);
} }
void TypeCheck::visitEAdd(EAdd *e_add) void TypeCheck::visitEAdd(EAdd *e_add)
{ {
/* Code For EAdd Goes Here */ /* Code For EAdd Goes Here */
e_add->expr_1->accept(this); e_add->expr_1->accept(this);
e_add->addop_->accept(this); e_add->addop_->accept(this);
e_add->expr_2->accept(this); e_add->expr_2->accept(this);
} }
void TypeCheck::visitERel(ERel *e_rel) void TypeCheck::visitERel(ERel *e_rel)
{ {
/* Code For ERel Goes Here */ /* Code For ERel Goes Here */
e_rel->expr_1->accept(this); e_rel->expr_1->accept(this);
e_rel->relop_->accept(this); e_rel->relop_->accept(this);
e_rel->expr_2->accept(this); e_rel->expr_2->accept(this);
} }
void TypeCheck::visitEAnd(EAnd *e_and) void TypeCheck::visitEAnd(EAnd *e_and)
{ {
/* Code For EAnd Goes Here */ /* Code For EAnd Goes Here */
e_and->expr_1->accept(this); e_and->expr_1->accept(this);
e_and->expr_2->accept(this); e_and->expr_2->accept(this);
} }
void TypeCheck::visitEOr(EOr *e_or) void TypeCheck::visitEOr(EOr *e_or)
{ {
/* Code For EOr Goes Here */ /* Code For EOr Goes Here */
e_or->expr_1->accept(this); e_or->expr_1->accept(this);
e_or->expr_2->accept(this); e_or->expr_2->accept(this);
} }
void TypeCheck::visitPlus(Plus *plus) void TypeCheck::visitPlus(Plus *plus)
{ {
/* Code For Plus Goes Here */ /* Code For Plus Goes Here */
} }
void TypeCheck::visitMinus(Minus *minus) void TypeCheck::visitMinus(Minus *minus)
{ {
/* Code For Minus Goes Here */ /* Code For Minus Goes Here */
} }
void TypeCheck::visitTimes(Times *times) void TypeCheck::visitTimes(Times *times)
{ {
/* Code For Times Goes Here */ /* Code For Times Goes Here */
} }
void TypeCheck::visitDiv(Div *div) void TypeCheck::visitDiv(Div *div)
{ {
/* Code For Div Goes Here */ /* Code For Div Goes Here */
} }
void TypeCheck::visitMod(Mod *mod) void TypeCheck::visitMod(Mod *mod)
{ {
/* Code For Mod Goes Here */ /* Code For Mod Goes Here */
} }
void TypeCheck::visitLTH(LTH *lth) void TypeCheck::visitLTH(LTH *lth)
{ {
/* Code For LTH Goes Here */ /* Code For LTH Goes Here */
} }
void TypeCheck::visitLE(LE *le) void TypeCheck::visitLE(LE *le)
{ {
/* Code For LE Goes Here */ /* Code For LE Goes Here */
} }
void TypeCheck::visitGTH(GTH *gth) void TypeCheck::visitGTH(GTH *gth)
{ {
/* Code For GTH Goes Here */ /* Code For GTH Goes Here */
} }
void TypeCheck::visitGE(GE *ge) void TypeCheck::visitGE(GE *ge)
{ {
/* Code For GE Goes Here */ /* Code For GE Goes Here */
} }
void TypeCheck::visitEQU(EQU *equ) void TypeCheck::visitEQU(EQU *equ)
{ {
/* Code For EQU Goes Here */ /* Code For EQU Goes Here */
} }
void TypeCheck::visitNE(NE *ne) void TypeCheck::visitNE(NE *ne)
{ {
/* Code For NE Goes Here */ /* Code For NE Goes Here */
} }
...@@ -580,84 +580,84 @@ void TypeCheck::visitNE(NE *ne) ...@@ -580,84 +580,84 @@ void TypeCheck::visitNE(NE *ne)
void TypeCheck::visitListTopDef(ListTopDef *list_top_def) void TypeCheck::visitListTopDef(ListTopDef *list_top_def)
{ {
for (ListTopDef::iterator i = list_top_def->begin() ; i != list_top_def->end() ; ++i) for (ListTopDef::iterator i = list_top_def->begin() ; i != list_top_def->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void TypeCheck::visitListArg(ListArg *list_arg) void TypeCheck::visitListArg(ListArg *list_arg)
{ {
for (ListArg::iterator i = list_arg->begin() ; i != list_arg->end() ; ++i) for (ListArg::iterator i = list_arg->begin() ; i != list_arg->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void TypeCheck::visitListClassBlockDef(ListClassBlockDef *list_class_block_def) void TypeCheck::visitListClassBlockDef(ListClassBlockDef *list_class_block_def)
{ {
for (ListClassBlockDef::iterator i = list_class_block_def->begin() ; i != list_class_block_def->end() ; ++i) for (ListClassBlockDef::iterator i = list_class_block_def->begin() ; i != list_class_block_def->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void TypeCheck::visitListStmt(ListStmt *list_stmt) void TypeCheck::visitListStmt(ListStmt *list_stmt)
{ {
for (ListStmt::iterator i = list_stmt->begin() ; i != list_stmt->end() ; ++i) for (ListStmt::iterator i = list_stmt->begin() ; i != list_stmt->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void TypeCheck::visitListItem(ListItem *list_item) void TypeCheck::visitListItem(ListItem *list_item)
{ {
for (ListItem::iterator i = list_item->begin() ; i != list_item->end() ; ++i) for (ListItem::iterator i = list_item->begin() ; i != list_item->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void TypeCheck::visitListType(ListType *list_type) void TypeCheck::visitListType(ListType *list_type)
{ {
for (ListType::iterator i = list_type->begin() ; i != list_type->end() ; ++i) for (ListType::iterator i = list_type->begin() ; i != list_type->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void TypeCheck::visitListExpr(ListExpr *list_expr) void TypeCheck::visitListExpr(ListExpr *list_expr)
{ {
for (ListExpr::iterator i = list_expr->begin() ; i != list_expr->end() ; ++i) for (ListExpr::iterator i = list_expr->begin() ; i != list_expr->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
} }
} }
void TypeCheck::visitInteger(Integer x) void TypeCheck::visitInteger(Integer x)
{ {
/* Code for Integer Goes Here */ /* Code for Integer Goes Here */
} }
void TypeCheck::visitChar(Char x) void TypeCheck::visitChar(Char x)
{ {
/* Code for Char Goes Here */ /* Code for Char Goes Here */
} }
void TypeCheck::visitDouble(Double x) void TypeCheck::visitDouble(Double x)
{ {
/* Code for Double Goes Here */ /* Code for Double Goes Here */
} }
void TypeCheck::visitString(String x) void TypeCheck::visitString(String x)
{ {
/* Code for String Goes Here */ /* Code for String Goes Here */
} }
void TypeCheck::visitIdent(Ident x) void TypeCheck::visitIdent(Ident x)
{ {
/* Code for Ident Goes Here */ /* Code for Ident Goes Here */
} }
......
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