Commit f5cf7cdc authored by zygzagZ's avatar zygzagZ

init

parents
*.o
*.l
*.y
/lat/
/TestGrammar
\ No newline at end of file
//C++ Abstract Syntax Implementation generated by the BNF Converter.
#include <algorithm>
#include <string>
#include <vector>
#include "Absyn.h"
/******************** PIdent ********************/
PIdent::PIdent(String p1, Integer p2)
{
string_ = p1;
integer_ = p2;
}
PIdent::PIdent(const PIdent & other)
{
string_ = other.string_;
integer_ = other.integer_;
}
PIdent &PIdent::operator=(const PIdent & other)
{
PIdent tmp(other);
swap(tmp);
return *this;
}
void PIdent::swap(PIdent & other)
{
std::swap(string_, other.string_);
std::swap(integer_, other.integer_);
}
PIdent::~PIdent()
{
}
void PIdent::accept(Visitor *v)
{
v->visitPIdent(this);
}
PIdent *PIdent::clone() const
{
return new PIdent(*this);
}
/******************** Prog ********************/
Prog::Prog(ListTopDef *p1)
{
listtopdef_ = p1;
}
Prog::Prog(const Prog & other)
{
listtopdef_ = other.listtopdef_->clone();
}
Prog &Prog::operator=(const Prog & other)
{
Prog tmp(other);
swap(tmp);
return *this;
}
void Prog::swap(Prog & other)
{
std::swap(listtopdef_, other.listtopdef_);
}
Prog::~Prog()
{
delete(listtopdef_);
}
void Prog::accept(Visitor *v)
{
v->visitProg(this);
}
Prog *Prog::clone() const
{
return new Prog(*this);
}
/******************** FnDef ********************/
FnDef::FnDef(FunDef *p1)
{
fundef_ = p1;
}
FnDef::FnDef(const FnDef & other)
{
fundef_ = other.fundef_->clone();
}
FnDef &FnDef::operator=(const FnDef & other)
{
FnDef tmp(other);
swap(tmp);
return *this;
}
void FnDef::swap(FnDef & other)
{
std::swap(fundef_, other.fundef_);
}
FnDef::~FnDef()
{
delete(fundef_);
}
void FnDef::accept(Visitor *v)
{
v->visitFnDef(this);
}
FnDef *FnDef::clone() const
{
return new FnDef(*this);
}
/******************** ClDef ********************/
ClDef::ClDef(ClassDef *p1)
{
classdef_ = p1;
}
ClDef::ClDef(const ClDef & other)
{
classdef_ = other.classdef_->clone();
}
ClDef &ClDef::operator=(const ClDef & other)
{
ClDef tmp(other);
swap(tmp);
return *this;
}
void ClDef::swap(ClDef & other)
{
std::swap(classdef_, other.classdef_);
}
ClDef::~ClDef()
{
delete(classdef_);
}
void ClDef::accept(Visitor *v)
{
v->visitClDef(this);
}
ClDef *ClDef::clone() const
{
return new ClDef(*this);
}
/******************** FuncDef ********************/
FuncDef::FuncDef(Type *p1, PIdent *p2, ListArg *p3, Block *p4)
{
type_ = p1;
pident_ = p2;
listarg_ = p3;
block_ = p4;
}
FuncDef::FuncDef(const FuncDef & other)
{
type_ = other.type_->clone();
pident_ = other.pident_->clone();
listarg_ = other.listarg_->clone();
block_ = other.block_->clone();
}
FuncDef &FuncDef::operator=(const FuncDef & other)
{
FuncDef tmp(other);
swap(tmp);
return *this;
}
void FuncDef::swap(FuncDef & other)
{
std::swap(type_, other.type_);
std::swap(pident_, other.pident_);
std::swap(listarg_, other.listarg_);
std::swap(block_, other.block_);
}
FuncDef::~FuncDef()
{
delete(type_);
delete(pident_);
delete(listarg_);
delete(block_);
}
void FuncDef::accept(Visitor *v)
{
v->visitFuncDef(this);
}
FuncDef *FuncDef::clone() const
{
return new FuncDef(*this);
}
/******************** Ar ********************/
Ar::Ar(Type *p1, PIdent *p2)
{
type_ = p1;
pident_ = p2;
}
Ar::Ar(const Ar & other)
{
type_ = other.type_->clone();
pident_ = other.pident_->clone();
}
Ar &Ar::operator=(const Ar & other)
{
Ar tmp(other);
swap(tmp);
return *this;
}
void Ar::swap(Ar & other)
{
std::swap(type_, other.type_);
std::swap(pident_, other.pident_);
}
Ar::~Ar()
{
delete(type_);
delete(pident_);
}
void Ar::accept(Visitor *v)
{
v->visitAr(this);
}
Ar *Ar::clone() const
{
return new Ar(*this);
}
/******************** ClassDefN ********************/
ClassDefN::ClassDefN(PIdent *p1, ClassBlock *p2)
{
pident_ = p1;
classblock_ = p2;
}
ClassDefN::ClassDefN(const ClassDefN & other)
{
pident_ = other.pident_->clone();
classblock_ = other.classblock_->clone();
}
ClassDefN &ClassDefN::operator=(const ClassDefN & other)
{
ClassDefN tmp(other);
swap(tmp);
return *this;
}
void ClassDefN::swap(ClassDefN & other)
{
std::swap(pident_, other.pident_);
std::swap(classblock_, other.classblock_);
}
ClassDefN::~ClassDefN()
{
delete(pident_);
delete(classblock_);
}
void ClassDefN::accept(Visitor *v)
{
v->visitClassDefN(this);
}
ClassDefN *ClassDefN::clone() const
{
return new ClassDefN(*this);
}
/******************** ClassDefE ********************/
ClassDefE::ClassDefE(PIdent *p1, PIdent *p2, ClassBlock *p3)
{
pident_1 = p1;
pident_2 = p2;
classblock_ = p3;
}
ClassDefE::ClassDefE(const ClassDefE & other)
{
pident_1 = other.pident_1->clone();
pident_2 = other.pident_2->clone();
classblock_ = other.classblock_->clone();
}
ClassDefE &ClassDefE::operator=(const ClassDefE & other)
{
ClassDefE tmp(other);
swap(tmp);
return *this;
}
void ClassDefE::swap(ClassDefE & other)
{
std::swap(pident_1, other.pident_1);
std::swap(pident_2, other.pident_2);
std::swap(classblock_, other.classblock_);
}
ClassDefE::~ClassDefE()
{
delete(pident_1);
delete(pident_2);
delete(classblock_);
}
void ClassDefE::accept(Visitor *v)
{
v->visitClassDefE(this);
}
ClassDefE *ClassDefE::clone() const
{
return new ClassDefE(*this);
}
/******************** ClassBl ********************/
ClassBl::ClassBl(ListClassBlockDef *p1)
{
listclassblockdef_ = p1;
}
ClassBl::ClassBl(const ClassBl & other)
{
listclassblockdef_ = other.listclassblockdef_->clone();
}
ClassBl &ClassBl::operator=(const ClassBl & other)
{
ClassBl tmp(other);
swap(tmp);
return *this;
}
void ClassBl::swap(ClassBl & other)
{
std::swap(listclassblockdef_, other.listclassblockdef_);
}
ClassBl::~ClassBl()
{
delete(listclassblockdef_);
}
void ClassBl::accept(Visitor *v)
{
v->visitClassBl(this);
}
ClassBl *ClassBl::clone() const
{
return new ClassBl(*this);
}
/******************** ClassMthd ********************/
ClassMthd::ClassMthd(FunDef *p1)
{
fundef_ = p1;
}
ClassMthd::ClassMthd(const ClassMthd & other)
{
fundef_ = other.fundef_->clone();
}
ClassMthd &ClassMthd::operator=(const ClassMthd & other)
{
ClassMthd tmp(other);
swap(tmp);
return *this;
}
void ClassMthd::swap(ClassMthd & other)
{
std::swap(fundef_, other.fundef_);
}
ClassMthd::~ClassMthd()
{
delete(fundef_);
}
void ClassMthd::accept(Visitor *v)
{
v->visitClassMthd(this);
}
ClassMthd *ClassMthd::clone() const
{
return new ClassMthd(*this);
}
/******************** ClassFld ********************/
ClassFld::ClassFld(Type *p1, ListItem *p2)
{
type_ = p1;
listitem_ = p2;
}
ClassFld::ClassFld(const ClassFld & other)
{
type_ = other.type_->clone();
listitem_ = other.listitem_->clone();
}
ClassFld &ClassFld::operator=(const ClassFld & other)
{
ClassFld tmp(other);
swap(tmp);
return *this;
}
void ClassFld::swap(ClassFld & other)
{
std::swap(type_, other.type_);
std::swap(listitem_, other.listitem_);
}
ClassFld::~ClassFld()
{
delete(type_);
delete(listitem_);
}
void ClassFld::accept(Visitor *v)
{
v->visitClassFld(this);
}
ClassFld *ClassFld::clone() const
{
return new ClassFld(*this);
}
/******************** Blk ********************/
Blk::Blk(ListStmt *p1)
{
liststmt_ = p1;
}
Blk::Blk(const Blk & other)
{
liststmt_ = other.liststmt_->clone();
}
Blk &Blk::operator=(const Blk & other)
{
Blk tmp(other);
swap(tmp);
return *this;
}
void Blk::swap(Blk & other)
{
std::swap(liststmt_, other.liststmt_);
}
Blk::~Blk()
{
delete(liststmt_);
}
void Blk::accept(Visitor *v)
{
v->visitBlk(this);
}
Blk *Blk::clone() const
{
return new Blk(*this);
}
/******************** Empty ********************/
Empty::Empty()
{
}
Empty::Empty(const Empty & other)
{
}
Empty &Empty::operator=(const Empty & other)
{
Empty tmp(other);
swap(tmp);
return *this;
}
void Empty::swap(Empty & other)
{
}
Empty::~Empty()
{
}
void Empty::accept(Visitor *v)
{
v->visitEmpty(this);
}
Empty *Empty::clone() const
{
return new Empty(*this);
}
/******************** BStmt ********************/
BStmt::BStmt(Block *p1)
{
block_ = p1;
}
BStmt::BStmt(const BStmt & other)
{
block_ = other.block_->clone();
}
BStmt &BStmt::operator=(const BStmt & other)
{
BStmt tmp(other);
swap(tmp);
return *this;
}
void BStmt::swap(BStmt & other)
{
std::swap(block_, other.block_);
}
BStmt::~BStmt()
{
delete(block_);
}
void BStmt::accept(Visitor *v)
{
v->visitBStmt(this);
}
BStmt *BStmt::clone() const
{
return new BStmt(*this);
}
/******************** Decl ********************/
Decl::Decl(Type *p1, ListItem *p2)
{
type_ = p1;
listitem_ = p2;
}
Decl::Decl(const Decl & other)
{
type_ = other.type_->clone();
listitem_ = other.listitem_->clone();
}
Decl &Decl::operator=(const Decl & other)
{
Decl tmp(other);
swap(tmp);
return *this;
}
void Decl::swap(Decl & other)
{
std::swap(type_, other.type_);
std::swap(listitem_, other.listitem_);
}
Decl::~Decl()
{
delete(type_);
delete(listitem_);
}
void Decl::accept(Visitor *v)
{
v->visitDecl(this);
}
Decl *Decl::clone() const
{
return new Decl(*this);
}
/******************** Ass ********************/
Ass::Ass(Expr *p1, Expr *p2)
{
expr_1 = p1;
expr_2 = p2;
}
Ass::Ass(const Ass & other)
{
expr_1 = other.expr_1->clone();
expr_2 = other.expr_2->clone();
}
Ass &Ass::operator=(const Ass & other)
{
Ass tmp(other);
swap(tmp);
return *this;
}
void Ass::swap(Ass & other)
{
std::swap(expr_1, other.expr_1);
std::swap(expr_2, other.expr_2);
}
Ass::~Ass()
{
delete(expr_1);
delete(expr_2);
}
void Ass::accept(Visitor *v)
{
v->visitAss(this);
}
Ass *Ass::clone() const
{
return new Ass(*this);
}
/******************** TableAss ********************/
TableAss::TableAss(PIdent *p1, Expr *p2, Expr *p3)
{
pident_ = p1;
expr_1 = p2;
expr_2 = p3;
}
TableAss::TableAss(const TableAss & other)
{
pident_ = other.pident_->clone();
expr_1 = other.expr_1->clone();
expr_2 = other.expr_2->clone();
}
TableAss &TableAss::operator=(const TableAss & other)
{
TableAss tmp(other);
swap(tmp);
return *this;
}
void TableAss::swap(TableAss & other)
{
std::swap(pident_, other.pident_);
std::swap(expr_1, other.expr_1);
std::swap(expr_2, other.expr_2);
}
TableAss::~TableAss()
{
delete(pident_);
delete(expr_1);
delete(expr_2);
}
void TableAss::accept(Visitor *v)
{
v->visitTableAss(this);
}
TableAss *TableAss::clone() const
{
return new TableAss(*this);
}
/******************** TableIncr ********************/
TableIncr::TableIncr(PIdent *p1, Expr *p2)
{
pident_ = p1;
expr_ = p2;
}
TableIncr::TableIncr(const TableIncr & other)
{
pident_ = other.pident_->clone();
expr_ = other.expr_->clone();
}
TableIncr &TableIncr::operator=(const TableIncr & other)
{
TableIncr tmp(other);
swap(tmp);
return *this;
}
void TableIncr::swap(TableIncr & other)
{
std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_);
}
TableIncr::~TableIncr()
{
delete(pident_);
delete(expr_);
}
void TableIncr::accept(Visitor *v)
{
v->visitTableIncr(this);
}
TableIncr *TableIncr::clone() const
{
return new TableIncr(*this);
}
/******************** TableDecr ********************/
TableDecr::TableDecr(PIdent *p1, Expr *p2)
{
pident_ = p1;
expr_ = p2;
}
TableDecr::TableDecr(const TableDecr & other)
{
pident_ = other.pident_->clone();
expr_ = other.expr_->clone();
}
TableDecr &TableDecr::operator=(const TableDecr & other)
{
TableDecr tmp(other);
swap(tmp);
return *this;
}
void TableDecr::swap(TableDecr & other)
{
std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_);
}
TableDecr::~TableDecr()
{
delete(pident_);
delete(expr_);
}
void TableDecr::accept(Visitor *v)
{
v->visitTableDecr(this);
}
TableDecr *TableDecr::clone() const
{
return new TableDecr(*this);
}
/******************** Incr ********************/
Incr::Incr(PIdent *p1)
{
pident_ = p1;
}
Incr::Incr(const Incr & other)
{
pident_ = other.pident_->clone();
}
Incr &Incr::operator=(const Incr & other)
{
Incr tmp(other);
swap(tmp);
return *this;
}
void Incr::swap(Incr & other)
{
std::swap(pident_, other.pident_);
}
Incr::~Incr()
{
delete(pident_);
}
void Incr::accept(Visitor *v)
{
v->visitIncr(this);
}
Incr *Incr::clone() const
{
return new Incr(*this);
}
/******************** Decr ********************/
Decr::Decr(PIdent *p1)
{
pident_ = p1;
}
Decr::Decr(const Decr & other)
{
pident_ = other.pident_->clone();
}
Decr &Decr::operator=(const Decr & other)
{
Decr tmp(other);
swap(tmp);
return *this;
}
void Decr::swap(Decr & other)
{
std::swap(pident_, other.pident_);
}
Decr::~Decr()
{
delete(pident_);
}
void Decr::accept(Visitor *v)
{
v->visitDecr(this);
}
Decr *Decr::clone() const
{
return new Decr(*this);
}
/******************** Ret ********************/
Ret::Ret(Expr *p1)
{
expr_ = p1;
}
Ret::Ret(const Ret & other)
{
expr_ = other.expr_->clone();
}
Ret &Ret::operator=(const Ret & other)
{
Ret tmp(other);
swap(tmp);
return *this;
}
void Ret::swap(Ret & other)
{
std::swap(expr_, other.expr_);
}
Ret::~Ret()
{
delete(expr_);
}
void Ret::accept(Visitor *v)
{
v->visitRet(this);
}
Ret *Ret::clone() const
{
return new Ret(*this);
}
/******************** VRet ********************/
VRet::VRet()
{
}
VRet::VRet(const VRet & other)
{
}
VRet &VRet::operator=(const VRet & other)
{
VRet tmp(other);
swap(tmp);
return *this;
}
void VRet::swap(VRet & other)
{
}
VRet::~VRet()
{
}
void VRet::accept(Visitor *v)
{
v->visitVRet(this);
}
VRet *VRet::clone() const
{
return new VRet(*this);
}
/******************** Cond ********************/
Cond::Cond(Expr *p1, Stmt *p2)
{
expr_ = p1;
stmt_ = p2;
}
Cond::Cond(const Cond & other)
{
expr_ = other.expr_->clone();
stmt_ = other.stmt_->clone();
}
Cond &Cond::operator=(const Cond & other)
{
Cond tmp(other);
swap(tmp);
return *this;
}
void Cond::swap(Cond & other)
{
std::swap(expr_, other.expr_);
std::swap(stmt_, other.stmt_);
}
Cond::~Cond()
{
delete(expr_);
delete(stmt_);
}
void Cond::accept(Visitor *v)
{
v->visitCond(this);
}
Cond *Cond::clone() const
{
return new Cond(*this);
}
/******************** CondElse ********************/
CondElse::CondElse(Expr *p1, Stmt *p2, Stmt *p3)
{
expr_ = p1;
stmt_1 = p2;
stmt_2 = p3;
}
CondElse::CondElse(const CondElse & other)
{
expr_ = other.expr_->clone();
stmt_1 = other.stmt_1->clone();
stmt_2 = other.stmt_2->clone();
}
CondElse &CondElse::operator=(const CondElse & other)
{
CondElse tmp(other);
swap(tmp);
return *this;
}
void CondElse::swap(CondElse & other)
{
std::swap(expr_, other.expr_);
std::swap(stmt_1, other.stmt_1);
std::swap(stmt_2, other.stmt_2);
}
CondElse::~CondElse()
{
delete(expr_);
delete(stmt_1);
delete(stmt_2);
}
void CondElse::accept(Visitor *v)
{
v->visitCondElse(this);
}
CondElse *CondElse::clone() const
{
return new CondElse(*this);
}
/******************** While ********************/
While::While(Expr *p1, Stmt *p2)
{
expr_ = p1;
stmt_ = p2;
}
While::While(const While & other)
{
expr_ = other.expr_->clone();
stmt_ = other.stmt_->clone();
}
While &While::operator=(const While & other)
{
While tmp(other);
swap(tmp);
return *this;
}
void While::swap(While & other)
{
std::swap(expr_, other.expr_);
std::swap(stmt_, other.stmt_);
}
While::~While()
{
delete(expr_);
delete(stmt_);
}
void While::accept(Visitor *v)
{
v->visitWhile(this);
}
While *While::clone() const
{
return new While(*this);
}
/******************** SExp ********************/
SExp::SExp(Expr *p1)
{
expr_ = p1;
}
SExp::SExp(const SExp & other)
{
expr_ = other.expr_->clone();
}
SExp &SExp::operator=(const SExp & other)
{
SExp tmp(other);
swap(tmp);
return *this;
}
void SExp::swap(SExp & other)
{
std::swap(expr_, other.expr_);
}
SExp::~SExp()
{
delete(expr_);
}
void SExp::accept(Visitor *v)
{
v->visitSExp(this);
}
SExp *SExp::clone() const
{
return new SExp(*this);
}
/******************** ForEach ********************/
ForEach::ForEach(Type *p1, PIdent *p2, Expr *p3, Stmt *p4)
{
type_ = p1;
pident_ = p2;
expr_ = p3;
stmt_ = p4;
}
ForEach::ForEach(const ForEach & other)
{
type_ = other.type_->clone();
pident_ = other.pident_->clone();
expr_ = other.expr_->clone();
stmt_ = other.stmt_->clone();
}
ForEach &ForEach::operator=(const ForEach & other)
{
ForEach tmp(other);
swap(tmp);
return *this;
}
void ForEach::swap(ForEach & other)
{
std::swap(type_, other.type_);
std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_);
std::swap(stmt_, other.stmt_);
}
ForEach::~ForEach()
{
delete(type_);
delete(pident_);
delete(expr_);
delete(stmt_);
}
void ForEach::accept(Visitor *v)
{
v->visitForEach(this);
}
ForEach *ForEach::clone() const
{
return new ForEach(*this);
}
/******************** NoInit ********************/
NoInit::NoInit(PIdent *p1)
{
pident_ = p1;
}
NoInit::NoInit(const NoInit & other)
{
pident_ = other.pident_->clone();
}
NoInit &NoInit::operator=(const NoInit & other)
{
NoInit tmp(other);
swap(tmp);
return *this;
}
void NoInit::swap(NoInit & other)
{
std::swap(pident_, other.pident_);
}
NoInit::~NoInit()
{
delete(pident_);
}
void NoInit::accept(Visitor *v)
{
v->visitNoInit(this);
}
NoInit *NoInit::clone() const
{
return new NoInit(*this);
}
/******************** Init ********************/
Init::Init(PIdent *p1, Expr *p2)
{
pident_ = p1;
expr_ = p2;
}
Init::Init(const Init & other)
{
pident_ = other.pident_->clone();
expr_ = other.expr_->clone();
}
Init &Init::operator=(const Init & other)
{
Init tmp(other);
swap(tmp);
return *this;
}
void Init::swap(Init & other)
{
std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_);
}
Init::~Init()
{
delete(pident_);
delete(expr_);
}
void Init::accept(Visitor *v)
{
v->visitInit(this);
}
Init *Init::clone() const
{
return new Init(*this);
}
/******************** Int ********************/
Int::Int()
{
}
Int::Int(const Int & other)
{
}
Int &Int::operator=(const Int & other)
{
Int tmp(other);
swap(tmp);
return *this;
}
void Int::swap(Int & other)
{
}
Int::~Int()
{
}
void Int::accept(Visitor *v)
{
v->visitInt(this);
}
Int *Int::clone() const
{
return new Int(*this);
}
/******************** Str ********************/
Str::Str()
{
}
Str::Str(const Str & other)
{
}
Str &Str::operator=(const Str & other)
{
Str tmp(other);
swap(tmp);
return *this;
}
void Str::swap(Str & other)
{
}
Str::~Str()
{
}
void Str::accept(Visitor *v)
{
v->visitStr(this);
}
Str *Str::clone() const
{
return new Str(*this);
}
/******************** Bool ********************/
Bool::Bool()
{
}
Bool::Bool(const Bool & other)
{
}
Bool &Bool::operator=(const Bool & other)
{
Bool tmp(other);
swap(tmp);
return *this;
}
void Bool::swap(Bool & other)
{
}
Bool::~Bool()
{
}
void Bool::accept(Visitor *v)
{
v->visitBool(this);
}
Bool *Bool::clone() const
{
return new Bool(*this);
}
/******************** Void ********************/
Void::Void()
{
}
Void::Void(const Void & other)
{
}
Void &Void::operator=(const Void & other)
{
Void tmp(other);
swap(tmp);
return *this;
}
void Void::swap(Void & other)
{
}
Void::~Void()
{
}
void Void::accept(Visitor *v)
{
v->visitVoid(this);
}
Void *Void::clone() const
{
return new Void(*this);
}
/******************** Array ********************/
Array::Array(Type *p1)
{
type_ = p1;
}
Array::Array(const Array & other)
{
type_ = other.type_->clone();
}
Array &Array::operator=(const Array & other)
{
Array tmp(other);
swap(tmp);
return *this;
}
void Array::swap(Array & other)
{
std::swap(type_, other.type_);
}
Array::~Array()
{
delete(type_);
}
void Array::accept(Visitor *v)
{
v->visitArray(this);
}
Array *Array::clone() const
{
return new Array(*this);
}
/******************** ClassT ********************/
ClassT::ClassT(PIdent *p1)
{
pident_ = p1;
}
ClassT::ClassT(const ClassT & other)
{
pident_ = other.pident_->clone();
}
ClassT &ClassT::operator=(const ClassT & other)
{
ClassT tmp(other);
swap(tmp);
return *this;
}
void ClassT::swap(ClassT & other)
{
std::swap(pident_, other.pident_);
}
ClassT::~ClassT()
{
delete(pident_);
}
void ClassT::accept(Visitor *v)
{
v->visitClassT(this);
}
ClassT *ClassT::clone() const
{
return new ClassT(*this);
}
/******************** Fun ********************/
Fun::Fun(Type *p1, ListType *p2)
{
type_ = p1;
listtype_ = p2;
}
Fun::Fun(const Fun & other)
{
type_ = other.type_->clone();
listtype_ = other.listtype_->clone();
}
Fun &Fun::operator=(const Fun & other)
{
Fun tmp(other);
swap(tmp);
return *this;
}
void Fun::swap(Fun & other)
{
std::swap(type_, other.type_);
std::swap(listtype_, other.listtype_);
}
Fun::~Fun()
{
delete(type_);
delete(listtype_);
}
void Fun::accept(Visitor *v)
{
v->visitFun(this);
}
Fun *Fun::clone() const
{
return new Fun(*this);
}
/******************** EVar ********************/
EVar::EVar(PIdent *p1)
{
pident_ = p1;
}
EVar::EVar(const EVar & other)
{
pident_ = other.pident_->clone();
}
EVar &EVar::operator=(const EVar & other)
{
EVar tmp(other);
swap(tmp);
return *this;
}
void EVar::swap(EVar & other)
{
std::swap(pident_, other.pident_);
}
EVar::~EVar()
{
delete(pident_);
}
void EVar::accept(Visitor *v)
{
v->visitEVar(this);
}
EVar *EVar::clone() const
{
return new EVar(*this);
}
/******************** ELitInt ********************/
ELitInt::ELitInt(Integer p1)
{
integer_ = p1;
}
ELitInt::ELitInt(const ELitInt & other)
{
integer_ = other.integer_;
}
ELitInt &ELitInt::operator=(const ELitInt & other)
{
ELitInt tmp(other);
swap(tmp);
return *this;
}
void ELitInt::swap(ELitInt & other)
{
std::swap(integer_, other.integer_);
}
ELitInt::~ELitInt()
{
}
void ELitInt::accept(Visitor *v)
{
v->visitELitInt(this);
}
ELitInt *ELitInt::clone() const
{
return new ELitInt(*this);
}
/******************** ELitTrue ********************/
ELitTrue::ELitTrue()
{
}
ELitTrue::ELitTrue(const ELitTrue & other)
{
}
ELitTrue &ELitTrue::operator=(const ELitTrue & other)
{
ELitTrue tmp(other);
swap(tmp);
return *this;
}
void ELitTrue::swap(ELitTrue & other)
{
}
ELitTrue::~ELitTrue()
{
}
void ELitTrue::accept(Visitor *v)
{
v->visitELitTrue(this);
}
ELitTrue *ELitTrue::clone() const
{
return new ELitTrue(*this);
}
/******************** ELitFalse ********************/
ELitFalse::ELitFalse()
{
}
ELitFalse::ELitFalse(const ELitFalse & other)
{
}
ELitFalse &ELitFalse::operator=(const ELitFalse & other)
{
ELitFalse tmp(other);
swap(tmp);
return *this;
}
void ELitFalse::swap(ELitFalse & other)
{
}
ELitFalse::~ELitFalse()
{
}
void ELitFalse::accept(Visitor *v)
{
v->visitELitFalse(this);
}
ELitFalse *ELitFalse::clone() const
{
return new ELitFalse(*this);
}
/******************** EApp ********************/
EApp::EApp(PIdent *p1, ListExpr *p2)
{
pident_ = p1;
listexpr_ = p2;
}
EApp::EApp(const EApp & other)
{
pident_ = other.pident_->clone();
listexpr_ = other.listexpr_->clone();
}
EApp &EApp::operator=(const EApp & other)
{
EApp tmp(other);
swap(tmp);
return *this;
}
void EApp::swap(EApp & other)
{
std::swap(pident_, other.pident_);
std::swap(listexpr_, other.listexpr_);
}
EApp::~EApp()
{
delete(pident_);
delete(listexpr_);
}
void EApp::accept(Visitor *v)
{
v->visitEApp(this);
}
EApp *EApp::clone() const
{
return new EApp(*this);
}
/******************** EString ********************/
EString::EString(String p1)
{
string_ = p1;
}
EString::EString(const EString & other)
{
string_ = other.string_;
}
EString &EString::operator=(const EString & other)
{
EString tmp(other);
swap(tmp);
return *this;
}
void EString::swap(EString & other)
{
std::swap(string_, other.string_);
}
EString::~EString()
{
}
void EString::accept(Visitor *v)
{
v->visitEString(this);
}
EString *EString::clone() const
{
return new EString(*this);
}
/******************** ENewArray ********************/
ENewArray::ENewArray(Type *p1, Expr *p2)
{
type_ = p1;
expr_ = p2;
}
ENewArray::ENewArray(const ENewArray & other)
{
type_ = other.type_->clone();
expr_ = other.expr_->clone();
}
ENewArray &ENewArray::operator=(const ENewArray & other)
{
ENewArray tmp(other);
swap(tmp);
return *this;
}
void ENewArray::swap(ENewArray & other)
{
std::swap(type_, other.type_);
std::swap(expr_, other.expr_);
}
ENewArray::~ENewArray()
{
delete(type_);
delete(expr_);
}
void ENewArray::accept(Visitor *v)
{
v->visitENewArray(this);
}
ENewArray *ENewArray::clone() const
{
return new ENewArray(*this);
}
/******************** ENewClass ********************/
ENewClass::ENewClass(PIdent *p1)
{
pident_ = p1;
}
ENewClass::ENewClass(const ENewClass & other)
{
pident_ = other.pident_->clone();
}
ENewClass &ENewClass::operator=(const ENewClass & other)
{
ENewClass tmp(other);
swap(tmp);
return *this;
}
void ENewClass::swap(ENewClass & other)
{
std::swap(pident_, other.pident_);
}
ENewClass::~ENewClass()
{
delete(pident_);
}
void ENewClass::accept(Visitor *v)
{
v->visitENewClass(this);
}
ENewClass *ENewClass::clone() const
{
return new ENewClass(*this);
}
/******************** EClsMmbr ********************/
EClsMmbr::EClsMmbr(Expr *p1, PIdent *p2)
{
expr_ = p1;
pident_ = p2;
}
EClsMmbr::EClsMmbr(const EClsMmbr & other)
{
expr_ = other.expr_->clone();
pident_ = other.pident_->clone();
}
EClsMmbr &EClsMmbr::operator=(const EClsMmbr & other)
{
EClsMmbr tmp(other);
swap(tmp);
return *this;
}
void EClsMmbr::swap(EClsMmbr & other)
{
std::swap(expr_, other.expr_);
std::swap(pident_, other.pident_);
}
EClsMmbr::~EClsMmbr()
{
delete(expr_);
delete(pident_);
}
void EClsMmbr::accept(Visitor *v)
{
v->visitEClsMmbr(this);
}
EClsMmbr *EClsMmbr::clone() const
{
return new EClsMmbr(*this);
}
/******************** EClsMthd ********************/
EClsMthd::EClsMthd(Expr *p1, PIdent *p2, ListExpr *p3)
{
expr_ = p1;
pident_ = p2;
listexpr_ = p3;
}
EClsMthd::EClsMthd(const EClsMthd & other)
{
expr_ = other.expr_->clone();
pident_ = other.pident_->clone();
listexpr_ = other.listexpr_->clone();
}
EClsMthd &EClsMthd::operator=(const EClsMthd & other)
{
EClsMthd tmp(other);
swap(tmp);
return *this;
}
void EClsMthd::swap(EClsMthd & other)
{
std::swap(expr_, other.expr_);
std::swap(pident_, other.pident_);
std::swap(listexpr_, other.listexpr_);
}
EClsMthd::~EClsMthd()
{
delete(expr_);
delete(pident_);
delete(listexpr_);
}
void EClsMthd::accept(Visitor *v)
{
v->visitEClsMthd(this);
}
EClsMthd *EClsMthd::clone() const
{
return new EClsMthd(*this);
}
/******************** Null ********************/
Null::Null()
{
}
Null::Null(const Null & other)
{
}
Null &Null::operator=(const Null & other)
{
Null tmp(other);
swap(tmp);
return *this;
}
void Null::swap(Null & other)
{
}
Null::~Null()
{
}
void Null::accept(Visitor *v)
{
v->visitNull(this);
}
Null *Null::clone() const
{
return new Null(*this);
}
/******************** EIndexAcc ********************/
EIndexAcc::EIndexAcc(PIdent *p1, Expr *p2)
{
pident_ = p1;
expr_ = p2;
}
EIndexAcc::EIndexAcc(const EIndexAcc & other)
{
pident_ = other.pident_->clone();
expr_ = other.expr_->clone();
}
EIndexAcc &EIndexAcc::operator=(const EIndexAcc & other)
{
EIndexAcc tmp(other);
swap(tmp);
return *this;
}
void EIndexAcc::swap(EIndexAcc & other)
{
std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_);
}
EIndexAcc::~EIndexAcc()
{
delete(pident_);
delete(expr_);
}
void EIndexAcc::accept(Visitor *v)
{
v->visitEIndexAcc(this);
}
EIndexAcc *EIndexAcc::clone() const
{
return new EIndexAcc(*this);
}
/******************** ECast ********************/
ECast::ECast(PIdent *p1, Expr *p2)
{
pident_ = p1;
expr_ = p2;
}
ECast::ECast(const ECast & other)
{
pident_ = other.pident_->clone();
expr_ = other.expr_->clone();
}
ECast &ECast::operator=(const ECast & other)
{
ECast tmp(other);
swap(tmp);
return *this;
}
void ECast::swap(ECast & other)
{
std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_);
}
ECast::~ECast()
{
delete(pident_);
delete(expr_);
}
void ECast::accept(Visitor *v)
{
v->visitECast(this);
}
ECast *ECast::clone() const
{
return new ECast(*this);
}
/******************** Neg ********************/
Neg::Neg(Expr *p1)
{
expr_ = p1;
}
Neg::Neg(const Neg & other)
{
expr_ = other.expr_->clone();
}
Neg &Neg::operator=(const Neg & other)
{
Neg tmp(other);
swap(tmp);
return *this;
}
void Neg::swap(Neg & other)
{
std::swap(expr_, other.expr_);
}
Neg::~Neg()
{
delete(expr_);
}
void Neg::accept(Visitor *v)
{
v->visitNeg(this);
}
Neg *Neg::clone() const
{
return new Neg(*this);
}
/******************** Not ********************/
Not::Not(Expr *p1)
{
expr_ = p1;
}
Not::Not(const Not & other)
{
expr_ = other.expr_->clone();
}
Not &Not::operator=(const Not & other)
{
Not tmp(other);
swap(tmp);
return *this;
}
void Not::swap(Not & other)
{
std::swap(expr_, other.expr_);
}
Not::~Not()
{
delete(expr_);
}
void Not::accept(Visitor *v)
{
v->visitNot(this);
}
Not *Not::clone() const
{
return new Not(*this);
}
/******************** EMul ********************/
EMul::EMul(Expr *p1, MulOp *p2, Expr *p3)
{
expr_1 = p1;
mulop_ = p2;
expr_2 = p3;
}
EMul::EMul(const EMul & other)
{
expr_1 = other.expr_1->clone();
mulop_ = other.mulop_->clone();
expr_2 = other.expr_2->clone();
}
EMul &EMul::operator=(const EMul & other)
{
EMul tmp(other);
swap(tmp);
return *this;
}
void EMul::swap(EMul & other)
{
std::swap(expr_1, other.expr_1);
std::swap(mulop_, other.mulop_);
std::swap(expr_2, other.expr_2);
}
EMul::~EMul()
{
delete(expr_1);
delete(mulop_);
delete(expr_2);
}
void EMul::accept(Visitor *v)
{
v->visitEMul(this);
}
EMul *EMul::clone() const
{
return new EMul(*this);
}
/******************** EAdd ********************/
EAdd::EAdd(Expr *p1, AddOp *p2, Expr *p3)
{
expr_1 = p1;
addop_ = p2;
expr_2 = p3;
}
EAdd::EAdd(const EAdd & other)
{
expr_1 = other.expr_1->clone();
addop_ = other.addop_->clone();
expr_2 = other.expr_2->clone();
}
EAdd &EAdd::operator=(const EAdd & other)
{
EAdd tmp(other);
swap(tmp);
return *this;
}
void EAdd::swap(EAdd & other)
{
std::swap(expr_1, other.expr_1);
std::swap(addop_, other.addop_);
std::swap(expr_2, other.expr_2);
}
EAdd::~EAdd()
{
delete(expr_1);
delete(addop_);
delete(expr_2);
}
void EAdd::accept(Visitor *v)
{
v->visitEAdd(this);
}
EAdd *EAdd::clone() const
{
return new EAdd(*this);
}
/******************** ERel ********************/
ERel::ERel(Expr *p1, RelOp *p2, Expr *p3)
{
expr_1 = p1;
relop_ = p2;
expr_2 = p3;
}
ERel::ERel(const ERel & other)
{
expr_1 = other.expr_1->clone();
relop_ = other.relop_->clone();
expr_2 = other.expr_2->clone();
}
ERel &ERel::operator=(const ERel & other)
{
ERel tmp(other);
swap(tmp);
return *this;
}
void ERel::swap(ERel & other)
{
std::swap(expr_1, other.expr_1);
std::swap(relop_, other.relop_);
std::swap(expr_2, other.expr_2);
}
ERel::~ERel()
{
delete(expr_1);
delete(relop_);
delete(expr_2);
}
void ERel::accept(Visitor *v)
{
v->visitERel(this);
}
ERel *ERel::clone() const
{
return new ERel(*this);
}
/******************** EAnd ********************/
EAnd::EAnd(Expr *p1, Expr *p2)
{
expr_1 = p1;
expr_2 = p2;
}
EAnd::EAnd(const EAnd & other)
{
expr_1 = other.expr_1->clone();
expr_2 = other.expr_2->clone();
}
EAnd &EAnd::operator=(const EAnd & other)
{
EAnd tmp(other);
swap(tmp);
return *this;
}
void EAnd::swap(EAnd & other)
{
std::swap(expr_1, other.expr_1);
std::swap(expr_2, other.expr_2);
}
EAnd::~EAnd()
{
delete(expr_1);
delete(expr_2);
}
void EAnd::accept(Visitor *v)
{
v->visitEAnd(this);
}
EAnd *EAnd::clone() const
{
return new EAnd(*this);
}
/******************** EOr ********************/
EOr::EOr(Expr *p1, Expr *p2)
{
expr_1 = p1;
expr_2 = p2;
}
EOr::EOr(const EOr & other)
{
expr_1 = other.expr_1->clone();
expr_2 = other.expr_2->clone();
}
EOr &EOr::operator=(const EOr & other)
{
EOr tmp(other);
swap(tmp);
return *this;
}
void EOr::swap(EOr & other)
{
std::swap(expr_1, other.expr_1);
std::swap(expr_2, other.expr_2);
}
EOr::~EOr()
{
delete(expr_1);
delete(expr_2);
}
void EOr::accept(Visitor *v)
{
v->visitEOr(this);
}
EOr *EOr::clone() const
{
return new EOr(*this);
}
/******************** Plus ********************/
Plus::Plus()
{
}
Plus::Plus(const Plus & other)
{
}
Plus &Plus::operator=(const Plus & other)
{
Plus tmp(other);
swap(tmp);
return *this;
}
void Plus::swap(Plus & other)
{
}
Plus::~Plus()
{
}
void Plus::accept(Visitor *v)
{
v->visitPlus(this);
}
Plus *Plus::clone() const
{
return new Plus(*this);
}
/******************** Minus ********************/
Minus::Minus()
{
}
Minus::Minus(const Minus & other)
{
}
Minus &Minus::operator=(const Minus & other)
{
Minus tmp(other);
swap(tmp);
return *this;
}
void Minus::swap(Minus & other)
{
}
Minus::~Minus()
{
}
void Minus::accept(Visitor *v)
{
v->visitMinus(this);
}
Minus *Minus::clone() const
{
return new Minus(*this);
}
/******************** Times ********************/
Times::Times()
{
}
Times::Times(const Times & other)
{
}
Times &Times::operator=(const Times & other)
{
Times tmp(other);
swap(tmp);
return *this;
}
void Times::swap(Times & other)
{
}
Times::~Times()
{
}
void Times::accept(Visitor *v)
{
v->visitTimes(this);
}
Times *Times::clone() const
{
return new Times(*this);
}
/******************** Div ********************/
Div::Div()
{
}
Div::Div(const Div & other)
{
}
Div &Div::operator=(const Div & other)
{
Div tmp(other);
swap(tmp);
return *this;
}
void Div::swap(Div & other)
{
}
Div::~Div()
{
}
void Div::accept(Visitor *v)
{
v->visitDiv(this);
}
Div *Div::clone() const
{
return new Div(*this);
}
/******************** Mod ********************/
Mod::Mod()
{
}
Mod::Mod(const Mod & other)
{
}
Mod &Mod::operator=(const Mod & other)
{
Mod tmp(other);
swap(tmp);
return *this;
}
void Mod::swap(Mod & other)
{
}
Mod::~Mod()
{
}
void Mod::accept(Visitor *v)
{
v->visitMod(this);
}
Mod *Mod::clone() const
{
return new Mod(*this);
}
/******************** LTH ********************/
LTH::LTH()
{
}
LTH::LTH(const LTH & other)
{
}
LTH &LTH::operator=(const LTH & other)
{
LTH tmp(other);
swap(tmp);
return *this;
}
void LTH::swap(LTH & other)
{
}
LTH::~LTH()
{
}
void LTH::accept(Visitor *v)
{
v->visitLTH(this);
}
LTH *LTH::clone() const
{
return new LTH(*this);
}
/******************** LE ********************/
LE::LE()
{
}
LE::LE(const LE & other)
{
}
LE &LE::operator=(const LE & other)
{
LE tmp(other);
swap(tmp);
return *this;
}
void LE::swap(LE & other)
{
}
LE::~LE()
{
}
void LE::accept(Visitor *v)
{
v->visitLE(this);
}
LE *LE::clone() const
{
return new LE(*this);
}
/******************** GTH ********************/
GTH::GTH()
{
}
GTH::GTH(const GTH & other)
{
}
GTH &GTH::operator=(const GTH & other)
{
GTH tmp(other);
swap(tmp);
return *this;
}
void GTH::swap(GTH & other)
{
}
GTH::~GTH()
{
}
void GTH::accept(Visitor *v)
{
v->visitGTH(this);
}
GTH *GTH::clone() const
{
return new GTH(*this);
}
/******************** GE ********************/
GE::GE()
{
}
GE::GE(const GE & other)
{
}
GE &GE::operator=(const GE & other)
{
GE tmp(other);
swap(tmp);
return *this;
}
void GE::swap(GE & other)
{
}
GE::~GE()
{
}
void GE::accept(Visitor *v)
{
v->visitGE(this);
}
GE *GE::clone() const
{
return new GE(*this);
}
/******************** EQU ********************/
EQU::EQU()
{
}
EQU::EQU(const EQU & other)
{
}
EQU &EQU::operator=(const EQU & other)
{
EQU tmp(other);
swap(tmp);
return *this;
}
void EQU::swap(EQU & other)
{
}
EQU::~EQU()
{
}
void EQU::accept(Visitor *v)
{
v->visitEQU(this);
}
EQU *EQU::clone() const
{
return new EQU(*this);
}
/******************** NE ********************/
NE::NE()
{
}
NE::NE(const NE & other)
{
}
NE &NE::operator=(const NE & other)
{
NE tmp(other);
swap(tmp);
return *this;
}
void NE::swap(NE & other)
{
}
NE::~NE()
{
}
void NE::accept(Visitor *v)
{
v->visitNE(this);
}
NE *NE::clone() const
{
return new NE(*this);
}
/******************** ListTopDef ********************/
void ListTopDef::accept(Visitor *v)
{
v->visitListTopDef(this);
}
ListTopDef *ListTopDef::clone() const
{
return new ListTopDef(*this);
}
/******************** ListArg ********************/
void ListArg::accept(Visitor *v)
{
v->visitListArg(this);
}
ListArg *ListArg::clone() const
{
return new ListArg(*this);
}
/******************** ListClassBlockDef ********************/
void ListClassBlockDef::accept(Visitor *v)
{
v->visitListClassBlockDef(this);
}
ListClassBlockDef *ListClassBlockDef::clone() const
{
return new ListClassBlockDef(*this);
}
/******************** ListStmt ********************/
void ListStmt::accept(Visitor *v)
{
v->visitListStmt(this);
}
ListStmt *ListStmt::clone() const
{
return new ListStmt(*this);
}
/******************** ListItem ********************/
void ListItem::accept(Visitor *v)
{
v->visitListItem(this);
}
ListItem *ListItem::clone() const
{
return new ListItem(*this);
}
/******************** ListType ********************/
void ListType::accept(Visitor *v)
{
v->visitListType(this);
}
ListType *ListType::clone() const
{
return new ListType(*this);
}
/******************** ListExpr ********************/
void ListExpr::accept(Visitor *v)
{
v->visitListExpr(this);
}
ListExpr *ListExpr::clone() const
{
return new ListExpr(*this);
}
#ifndef ABSYN_HEADER
#define ABSYN_HEADER
#include<string>
#include<vector>
//C++ Abstract Syntax Interface generated by the BNF Converter.
/******************** TypeDef Section ********************/
typedef int Integer;
typedef char Char;
typedef double Double;
typedef std::string String;
typedef std::string Ident;
/******************** Forward Declarations ********************/
class Program;
class TopDef;
class FunDef;
class Arg;
class ClassDef;
class ClassBlock;
class ClassBlockDef;
class Block;
class Stmt;
class Item;
class Type;
class Expr;
class AddOp;
class MulOp;
class RelOp;
class Prog;
class FnDef;
class ClDef;
class FuncDef;
class Ar;
class ClassDefN;
class ClassDefE;
class ClassBl;
class ClassMthd;
class ClassFld;
class Blk;
class Empty;
class BStmt;
class Decl;
class NoInit;
class Init;
class Ass;
class TableAss;
class TableIncr;
class TableDecr;
class Incr;
class Decr;
class Ret;
class VRet;
class Cond;
class CondElse;
class While;
class SExp;
class ForEach;
class Int;
class Str;
class Bool;
class Void;
class Array;
class ClassT;
class Fun;
class EVar;
class ELitInt;
class ELitTrue;
class ELitFalse;
class EApp;
class EString;
class ENewArray;
class ENewClass;
class EClsMmbr;
class EClsMthd;
class Null;
class EIndexAcc;
class ECast;
class Neg;
class Not;
class EMul;
class EAdd;
class ERel;
class EAnd;
class EOr;
class Plus;
class Minus;
class Times;
class Div;
class Mod;
class LTH;
class LE;
class GTH;
class GE;
class EQU;
class NE;
class ListTopDef;
class ListArg;
class ListClassBlockDef;
class ListStmt;
class ListItem;
class ListType;
class ListExpr;
class PIdent;
/******************** Visitor Interfaces ********************/
class Visitor
{
public:
virtual ~Visitor() {}
virtual void visitProgram(Program *p) = 0;
virtual void visitTopDef(TopDef *p) = 0;
virtual void visitFunDef(FunDef *p) = 0;
virtual void visitArg(Arg *p) = 0;
virtual void visitClassDef(ClassDef *p) = 0;
virtual void visitClassBlock(ClassBlock *p) = 0;
virtual void visitClassBlockDef(ClassBlockDef *p) = 0;
virtual void visitBlock(Block *p) = 0;
virtual void visitStmt(Stmt *p) = 0;
virtual void visitItem(Item *p) = 0;
virtual void visitType(Type *p) = 0;
virtual void visitExpr(Expr *p) = 0;
virtual void visitAddOp(AddOp *p) = 0;
virtual void visitMulOp(MulOp *p) = 0;
virtual void visitRelOp(RelOp *p) = 0;
virtual void visitProg(Prog *p) = 0;
virtual void visitFnDef(FnDef *p) = 0;
virtual void visitClDef(ClDef *p) = 0;
virtual void visitFuncDef(FuncDef *p) = 0;
virtual void visitAr(Ar *p) = 0;
virtual void visitClassDefN(ClassDefN *p) = 0;
virtual void visitClassDefE(ClassDefE *p) = 0;
virtual void visitClassBl(ClassBl *p) = 0;
virtual void visitClassMthd(ClassMthd *p) = 0;
virtual void visitClassFld(ClassFld *p) = 0;
virtual void visitBlk(Blk *p) = 0;
virtual void visitEmpty(Empty *p) = 0;
virtual void visitBStmt(BStmt *p) = 0;
virtual void visitDecl(Decl *p) = 0;
virtual void visitNoInit(NoInit *p) = 0;
virtual void visitInit(Init *p) = 0;
virtual void visitAss(Ass *p) = 0;
virtual void visitTableAss(TableAss *p) = 0;
virtual void visitTableIncr(TableIncr *p) = 0;
virtual void visitTableDecr(TableDecr *p) = 0;
virtual void visitIncr(Incr *p) = 0;
virtual void visitDecr(Decr *p) = 0;
virtual void visitRet(Ret *p) = 0;
virtual void visitVRet(VRet *p) = 0;
virtual void visitCond(Cond *p) = 0;
virtual void visitCondElse(CondElse *p) = 0;
virtual void visitWhile(While *p) = 0;
virtual void visitSExp(SExp *p) = 0;
virtual void visitForEach(ForEach *p) = 0;
virtual void visitInt(Int *p) = 0;
virtual void visitStr(Str *p) = 0;
virtual void visitBool(Bool *p) = 0;
virtual void visitVoid(Void *p) = 0;
virtual void visitArray(Array *p) = 0;
virtual void visitClassT(ClassT *p) = 0;
virtual void visitFun(Fun *p) = 0;
virtual void visitEVar(EVar *p) = 0;
virtual void visitELitInt(ELitInt *p) = 0;
virtual void visitELitTrue(ELitTrue *p) = 0;
virtual void visitELitFalse(ELitFalse *p) = 0;
virtual void visitEApp(EApp *p) = 0;
virtual void visitEString(EString *p) = 0;
virtual void visitENewArray(ENewArray *p) = 0;
virtual void visitENewClass(ENewClass *p) = 0;
virtual void visitEClsMmbr(EClsMmbr *p) = 0;
virtual void visitEClsMthd(EClsMthd *p) = 0;
virtual void visitNull(Null *p) = 0;
virtual void visitEIndexAcc(EIndexAcc *p) = 0;
virtual void visitECast(ECast *p) = 0;
virtual void visitNeg(Neg *p) = 0;
virtual void visitNot(Not *p) = 0;
virtual void visitEMul(EMul *p) = 0;
virtual void visitEAdd(EAdd *p) = 0;
virtual void visitERel(ERel *p) = 0;
virtual void visitEAnd(EAnd *p) = 0;
virtual void visitEOr(EOr *p) = 0;
virtual void visitPlus(Plus *p) = 0;
virtual void visitMinus(Minus *p) = 0;
virtual void visitTimes(Times *p) = 0;
virtual void visitDiv(Div *p) = 0;
virtual void visitMod(Mod *p) = 0;
virtual void visitLTH(LTH *p) = 0;
virtual void visitLE(LE *p) = 0;
virtual void visitGTH(GTH *p) = 0;
virtual void visitGE(GE *p) = 0;
virtual void visitEQU(EQU *p) = 0;
virtual void visitNE(NE *p) = 0;
virtual void visitListTopDef(ListTopDef *p) = 0;
virtual void visitListArg(ListArg *p) = 0;
virtual void visitListClassBlockDef(ListClassBlockDef *p) = 0;
virtual void visitListStmt(ListStmt *p) = 0;
virtual void visitListItem(ListItem *p) = 0;
virtual void visitListType(ListType *p) = 0;
virtual void visitListExpr(ListExpr *p) = 0;
virtual void visitPIdent(PIdent *p) = 0;
virtual void visitInteger(Integer x) = 0;
virtual void visitChar(Char x) = 0;
virtual void visitDouble(Double x) = 0;
virtual void visitString(String x) = 0;
virtual void visitIdent(Ident x) = 0;
};
class Visitable
{
public:
virtual ~Visitable() {}
virtual void accept(Visitor *v) = 0;
};
/******************** Abstract Syntax Classes ********************/
class Program : public Visitable
{
public:
virtual Program *clone() const = 0;
};
class TopDef : public Visitable
{
public:
virtual TopDef *clone() const = 0;
};
class FunDef : public Visitable
{
public:
virtual FunDef *clone() const = 0;
};
class Arg : public Visitable
{
public:
virtual Arg *clone() const = 0;
};
class ClassDef : public Visitable
{
public:
virtual ClassDef *clone() const = 0;
};
class ClassBlock : public Visitable
{
public:
virtual ClassBlock *clone() const = 0;
};
class ClassBlockDef : public Visitable
{
public:
virtual ClassBlockDef *clone() const = 0;
};
class Block : public Visitable
{
public:
virtual Block *clone() const = 0;
};
class Stmt : public Visitable
{
public:
virtual Stmt *clone() const = 0;
};
class Item : public Visitable
{
public:
virtual Item *clone() const = 0;
};
class Type : public Visitable
{
public:
virtual Type *clone() const = 0;
};
class Expr : public Visitable
{
public:
virtual Expr *clone() const = 0;
};
class AddOp : public Visitable
{
public:
virtual AddOp *clone() const = 0;
};
class MulOp : public Visitable
{
public:
virtual MulOp *clone() const = 0;
};
class RelOp : public Visitable
{
public:
virtual RelOp *clone() const = 0;
};
class PIdent : public Visitable
{
public:
String string_;
Integer integer_;
PIdent(const PIdent &);
PIdent &operator=(const PIdent &);
PIdent(String p1, Integer p2);
~PIdent();
virtual void accept(Visitor *v);
virtual PIdent *clone() const;
void swap(PIdent &);
};
class Prog : public Program
{
public:
ListTopDef *listtopdef_;
Prog(const Prog &);
Prog &operator=(const Prog &);
Prog(ListTopDef *p1);
~Prog();
virtual void accept(Visitor *v);
virtual Prog *clone() const;
void swap(Prog &);
};
class FnDef : public TopDef
{
public:
FunDef *fundef_;
FnDef(const FnDef &);
FnDef &operator=(const FnDef &);
FnDef(FunDef *p1);
~FnDef();
virtual void accept(Visitor *v);
virtual FnDef *clone() const;
void swap(FnDef &);
};
class ClDef : public TopDef
{
public:
ClassDef *classdef_;
ClDef(const ClDef &);
ClDef &operator=(const ClDef &);
ClDef(ClassDef *p1);
~ClDef();
virtual void accept(Visitor *v);
virtual ClDef *clone() const;
void swap(ClDef &);
};
class FuncDef : public FunDef
{
public:
Type *type_;
PIdent *pident_;
ListArg *listarg_;
Block *block_;
FuncDef(const FuncDef &);
FuncDef &operator=(const FuncDef &);
FuncDef(Type *p1, PIdent *p2, ListArg *p3, Block *p4);
~FuncDef();
virtual void accept(Visitor *v);
virtual FuncDef *clone() const;
void swap(FuncDef &);
};
class Ar : public Arg
{
public:
Type *type_;
PIdent *pident_;
Ar(const Ar &);
Ar &operator=(const Ar &);
Ar(Type *p1, PIdent *p2);
~Ar();
virtual void accept(Visitor *v);
virtual Ar *clone() const;
void swap(Ar &);
};
class ClassDefN : public ClassDef
{
public:
PIdent *pident_;
ClassBlock *classblock_;
ClassDefN(const ClassDefN &);
ClassDefN &operator=(const ClassDefN &);
ClassDefN(PIdent *p1, ClassBlock *p2);
~ClassDefN();
virtual void accept(Visitor *v);
virtual ClassDefN *clone() const;
void swap(ClassDefN &);
};
class ClassDefE : public ClassDef
{
public:
PIdent *pident_1;
PIdent *pident_2;
ClassBlock *classblock_;
ClassDefE(const ClassDefE &);
ClassDefE &operator=(const ClassDefE &);
ClassDefE(PIdent *p1, PIdent *p2, ClassBlock *p3);
~ClassDefE();
virtual void accept(Visitor *v);
virtual ClassDefE *clone() const;
void swap(ClassDefE &);
};
class ClassBl : public ClassBlock
{
public:
ListClassBlockDef *listclassblockdef_;
ClassBl(const ClassBl &);
ClassBl &operator=(const ClassBl &);
ClassBl(ListClassBlockDef *p1);
~ClassBl();
virtual void accept(Visitor *v);
virtual ClassBl *clone() const;
void swap(ClassBl &);
};
class ClassMthd : public ClassBlockDef
{
public:
FunDef *fundef_;
ClassMthd(const ClassMthd &);
ClassMthd &operator=(const ClassMthd &);
ClassMthd(FunDef *p1);
~ClassMthd();
virtual void accept(Visitor *v);
virtual ClassMthd *clone() const;
void swap(ClassMthd &);
};
class ClassFld : public ClassBlockDef
{
public:
Type *type_;
ListItem *listitem_;
ClassFld(const ClassFld &);
ClassFld &operator=(const ClassFld &);
ClassFld(Type *p1, ListItem *p2);
~ClassFld();
virtual void accept(Visitor *v);
virtual ClassFld *clone() const;
void swap(ClassFld &);
};
class Blk : public Block
{
public:
ListStmt *liststmt_;
Blk(const Blk &);
Blk &operator=(const Blk &);
Blk(ListStmt *p1);
~Blk();
virtual void accept(Visitor *v);
virtual Blk *clone() const;
void swap(Blk &);
};
class Empty : public Stmt
{
public:
Empty(const Empty &);
Empty &operator=(const Empty &);
Empty();
~Empty();
virtual void accept(Visitor *v);
virtual Empty *clone() const;
void swap(Empty &);
};
class BStmt : public Stmt
{
public:
Block *block_;
BStmt(const BStmt &);
BStmt &operator=(const BStmt &);
BStmt(Block *p1);
~BStmt();
virtual void accept(Visitor *v);
virtual BStmt *clone() const;
void swap(BStmt &);
};
class Decl : public Stmt
{
public:
Type *type_;
ListItem *listitem_;
Decl(const Decl &);
Decl &operator=(const Decl &);
Decl(Type *p1, ListItem *p2);
~Decl();
virtual void accept(Visitor *v);
virtual Decl *clone() const;
void swap(Decl &);
};
class Ass : public Stmt
{
public:
Expr *expr_1;
Expr *expr_2;
Ass(const Ass &);
Ass &operator=(const Ass &);
Ass(Expr *p1, Expr *p2);
~Ass();
virtual void accept(Visitor *v);
virtual Ass *clone() const;
void swap(Ass &);
};
class TableAss : public Stmt
{
public:
PIdent *pident_;
Expr *expr_1;
Expr *expr_2;
TableAss(const TableAss &);
TableAss &operator=(const TableAss &);
TableAss(PIdent *p1, Expr *p2, Expr *p3);
~TableAss();
virtual void accept(Visitor *v);
virtual TableAss *clone() const;
void swap(TableAss &);
};
class TableIncr : public Stmt
{
public:
PIdent *pident_;
Expr *expr_;
TableIncr(const TableIncr &);
TableIncr &operator=(const TableIncr &);
TableIncr(PIdent *p1, Expr *p2);
~TableIncr();
virtual void accept(Visitor *v);
virtual TableIncr *clone() const;
void swap(TableIncr &);
};
class TableDecr : public Stmt
{
public:
PIdent *pident_;
Expr *expr_;
TableDecr(const TableDecr &);
TableDecr &operator=(const TableDecr &);
TableDecr(PIdent *p1, Expr *p2);
~TableDecr();
virtual void accept(Visitor *v);
virtual TableDecr *clone() const;
void swap(TableDecr &);
};
class Incr : public Stmt
{
public:
PIdent *pident_;
Incr(const Incr &);
Incr &operator=(const Incr &);
Incr(PIdent *p1);
~Incr();
virtual void accept(Visitor *v);
virtual Incr *clone() const;
void swap(Incr &);
};
class Decr : public Stmt
{
public:
PIdent *pident_;
Decr(const Decr &);
Decr &operator=(const Decr &);
Decr(PIdent *p1);
~Decr();
virtual void accept(Visitor *v);
virtual Decr *clone() const;
void swap(Decr &);
};
class Ret : public Stmt
{
public:
Expr *expr_;
Ret(const Ret &);
Ret &operator=(const Ret &);
Ret(Expr *p1);
~Ret();
virtual void accept(Visitor *v);
virtual Ret *clone() const;
void swap(Ret &);
};
class VRet : public Stmt
{
public:
VRet(const VRet &);
VRet &operator=(const VRet &);
VRet();
~VRet();
virtual void accept(Visitor *v);
virtual VRet *clone() const;
void swap(VRet &);
};
class Cond : public Stmt
{
public:
Expr *expr_;
Stmt *stmt_;
Cond(const Cond &);
Cond &operator=(const Cond &);
Cond(Expr *p1, Stmt *p2);
~Cond();
virtual void accept(Visitor *v);
virtual Cond *clone() const;
void swap(Cond &);
};
class CondElse : public Stmt
{
public:
Expr *expr_;
Stmt *stmt_1;
Stmt *stmt_2;
CondElse(const CondElse &);
CondElse &operator=(const CondElse &);
CondElse(Expr *p1, Stmt *p2, Stmt *p3);
~CondElse();
virtual void accept(Visitor *v);
virtual CondElse *clone() const;
void swap(CondElse &);
};
class While : public Stmt
{
public:
Expr *expr_;
Stmt *stmt_;
While(const While &);
While &operator=(const While &);
While(Expr *p1, Stmt *p2);
~While();
virtual void accept(Visitor *v);
virtual While *clone() const;
void swap(While &);
};
class SExp : public Stmt
{
public:
Expr *expr_;
SExp(const SExp &);
SExp &operator=(const SExp &);
SExp(Expr *p1);
~SExp();
virtual void accept(Visitor *v);
virtual SExp *clone() const;
void swap(SExp &);
};
class ForEach : public Stmt
{
public:
Type *type_;
PIdent *pident_;
Expr *expr_;
Stmt *stmt_;
ForEach(const ForEach &);
ForEach &operator=(const ForEach &);
ForEach(Type *p1, PIdent *p2, Expr *p3, Stmt *p4);
~ForEach();
virtual void accept(Visitor *v);
virtual ForEach *clone() const;
void swap(ForEach &);
};
class NoInit : public Item
{
public:
PIdent *pident_;
NoInit(const NoInit &);
NoInit &operator=(const NoInit &);
NoInit(PIdent *p1);
~NoInit();
virtual void accept(Visitor *v);
virtual NoInit *clone() const;
void swap(NoInit &);
};
class Init : public Item
{
public:
PIdent *pident_;
Expr *expr_;
Init(const Init &);
Init &operator=(const Init &);
Init(PIdent *p1, Expr *p2);
~Init();
virtual void accept(Visitor *v);
virtual Init *clone() const;
void swap(Init &);
};
class Int : public Type
{
public:
Int(const Int &);
Int &operator=(const Int &);
Int();
~Int();
virtual void accept(Visitor *v);
virtual Int *clone() const;
void swap(Int &);
};
class Str : public Type
{
public:
Str(const Str &);
Str &operator=(const Str &);
Str();
~Str();
virtual void accept(Visitor *v);
virtual Str *clone() const;
void swap(Str &);
};
class Bool : public Type
{
public:
Bool(const Bool &);
Bool &operator=(const Bool &);
Bool();
~Bool();
virtual void accept(Visitor *v);
virtual Bool *clone() const;
void swap(Bool &);
};
class Void : public Type
{
public:
Void(const Void &);
Void &operator=(const Void &);
Void();
~Void();
virtual void accept(Visitor *v);
virtual Void *clone() const;
void swap(Void &);
};
class Array : public Type
{
public:
Type *type_;
Array(const Array &);
Array &operator=(const Array &);
Array(Type *p1);
~Array();
virtual void accept(Visitor *v);
virtual Array *clone() const;
void swap(Array &);
};
class ClassT : public Type
{
public:
PIdent *pident_;
ClassT(const ClassT &);
ClassT &operator=(const ClassT &);
ClassT(PIdent *p1);
~ClassT();
virtual void accept(Visitor *v);
virtual ClassT *clone() const;
void swap(ClassT &);
};
class Fun : public Type
{
public:
Type *type_;
ListType *listtype_;
Fun(const Fun &);
Fun &operator=(const Fun &);
Fun(Type *p1, ListType *p2);
~Fun();
virtual void accept(Visitor *v);
virtual Fun *clone() const;
void swap(Fun &);
};
class EVar : public Expr
{
public:
PIdent *pident_;
EVar(const EVar &);
EVar &operator=(const EVar &);
EVar(PIdent *p1);
~EVar();
virtual void accept(Visitor *v);
virtual EVar *clone() const;
void swap(EVar &);
};
class ELitInt : public Expr
{
public:
Integer integer_;
ELitInt(const ELitInt &);
ELitInt &operator=(const ELitInt &);
ELitInt(Integer p1);
~ELitInt();
virtual void accept(Visitor *v);
virtual ELitInt *clone() const;
void swap(ELitInt &);
};
class ELitTrue : public Expr
{
public:
ELitTrue(const ELitTrue &);
ELitTrue &operator=(const ELitTrue &);
ELitTrue();
~ELitTrue();
virtual void accept(Visitor *v);
virtual ELitTrue *clone() const;
void swap(ELitTrue &);
};
class ELitFalse : public Expr
{
public:
ELitFalse(const ELitFalse &);
ELitFalse &operator=(const ELitFalse &);
ELitFalse();
~ELitFalse();
virtual void accept(Visitor *v);
virtual ELitFalse *clone() const;
void swap(ELitFalse &);
};
class EApp : public Expr
{
public:
PIdent *pident_;
ListExpr *listexpr_;
EApp(const EApp &);
EApp &operator=(const EApp &);
EApp(PIdent *p1, ListExpr *p2);
~EApp();
virtual void accept(Visitor *v);
virtual EApp *clone() const;
void swap(EApp &);
};
class EString : public Expr
{
public:
String string_;
EString(const EString &);
EString &operator=(const EString &);
EString(String p1);
~EString();
virtual void accept(Visitor *v);
virtual EString *clone() const;
void swap(EString &);
};
class ENewArray : public Expr
{
public:
Type *type_;
Expr *expr_;
ENewArray(const ENewArray &);
ENewArray &operator=(const ENewArray &);
ENewArray(Type *p1, Expr *p2);
~ENewArray();
virtual void accept(Visitor *v);
virtual ENewArray *clone() const;
void swap(ENewArray &);
};
class ENewClass : public Expr
{
public:
PIdent *pident_;
ENewClass(const ENewClass &);
ENewClass &operator=(const ENewClass &);
ENewClass(PIdent *p1);
~ENewClass();
virtual void accept(Visitor *v);
virtual ENewClass *clone() const;
void swap(ENewClass &);
};
class EClsMmbr : public Expr
{
public:
Expr *expr_;
PIdent *pident_;
EClsMmbr(const EClsMmbr &);
EClsMmbr &operator=(const EClsMmbr &);
EClsMmbr(Expr *p1, PIdent *p2);
~EClsMmbr();
virtual void accept(Visitor *v);
virtual EClsMmbr *clone() const;
void swap(EClsMmbr &);
};
class EClsMthd : public Expr
{
public:
Expr *expr_;
PIdent *pident_;
ListExpr *listexpr_;
EClsMthd(const EClsMthd &);
EClsMthd &operator=(const EClsMthd &);
EClsMthd(Expr *p1, PIdent *p2, ListExpr *p3);
~EClsMthd();
virtual void accept(Visitor *v);
virtual EClsMthd *clone() const;
void swap(EClsMthd &);
};
class Null : public Expr
{
public:
Null(const Null &);
Null &operator=(const Null &);
Null();
~Null();
virtual void accept(Visitor *v);
virtual Null *clone() const;
void swap(Null &);
};
class EIndexAcc : public Expr
{
public:
PIdent *pident_;
Expr *expr_;
EIndexAcc(const EIndexAcc &);
EIndexAcc &operator=(const EIndexAcc &);
EIndexAcc(PIdent *p1, Expr *p2);
~EIndexAcc();
virtual void accept(Visitor *v);
virtual EIndexAcc *clone() const;
void swap(EIndexAcc &);
};
class ECast : public Expr
{
public:
PIdent *pident_;
Expr *expr_;
ECast(const ECast &);
ECast &operator=(const ECast &);
ECast(PIdent *p1, Expr *p2);
~ECast();
virtual void accept(Visitor *v);
virtual ECast *clone() const;
void swap(ECast &);
};
class Neg : public Expr
{
public:
Expr *expr_;
Neg(const Neg &);
Neg &operator=(const Neg &);
Neg(Expr *p1);
~Neg();
virtual void accept(Visitor *v);
virtual Neg *clone() const;
void swap(Neg &);
};
class Not : public Expr
{
public:
Expr *expr_;
Not(const Not &);
Not &operator=(const Not &);
Not(Expr *p1);
~Not();
virtual void accept(Visitor *v);
virtual Not *clone() const;
void swap(Not &);
};
class EMul : public Expr
{
public:
Expr *expr_1;
MulOp *mulop_;
Expr *expr_2;
EMul(const EMul &);
EMul &operator=(const EMul &);
EMul(Expr *p1, MulOp *p2, Expr *p3);
~EMul();
virtual void accept(Visitor *v);
virtual EMul *clone() const;
void swap(EMul &);
};
class EAdd : public Expr
{
public:
Expr *expr_1;
AddOp *addop_;
Expr *expr_2;
EAdd(const EAdd &);
EAdd &operator=(const EAdd &);
EAdd(Expr *p1, AddOp *p2, Expr *p3);
~EAdd();
virtual void accept(Visitor *v);
virtual EAdd *clone() const;
void swap(EAdd &);
};
class ERel : public Expr
{
public:
Expr *expr_1;
RelOp *relop_;
Expr *expr_2;
ERel(const ERel &);
ERel &operator=(const ERel &);
ERel(Expr *p1, RelOp *p2, Expr *p3);
~ERel();
virtual void accept(Visitor *v);
virtual ERel *clone() const;
void swap(ERel &);
};
class EAnd : public Expr
{
public:
Expr *expr_1;
Expr *expr_2;
EAnd(const EAnd &);
EAnd &operator=(const EAnd &);
EAnd(Expr *p1, Expr *p2);
~EAnd();
virtual void accept(Visitor *v);
virtual EAnd *clone() const;
void swap(EAnd &);
};
class EOr : public Expr
{
public:
Expr *expr_1;
Expr *expr_2;
EOr(const EOr &);
EOr &operator=(const EOr &);
EOr(Expr *p1, Expr *p2);
~EOr();
virtual void accept(Visitor *v);
virtual EOr *clone() const;
void swap(EOr &);
};
class Plus : public AddOp
{
public:
Plus(const Plus &);
Plus &operator=(const Plus &);
Plus();
~Plus();
virtual void accept(Visitor *v);
virtual Plus *clone() const;
void swap(Plus &);
};
class Minus : public AddOp
{
public:
Minus(const Minus &);
Minus &operator=(const Minus &);
Minus();
~Minus();
virtual void accept(Visitor *v);
virtual Minus *clone() const;
void swap(Minus &);
};
class Times : public MulOp
{
public:
Times(const Times &);
Times &operator=(const Times &);
Times();
~Times();
virtual void accept(Visitor *v);
virtual Times *clone() const;
void swap(Times &);
};
class Div : public MulOp
{
public:
Div(const Div &);
Div &operator=(const Div &);
Div();
~Div();
virtual void accept(Visitor *v);
virtual Div *clone() const;
void swap(Div &);
};
class Mod : public MulOp
{
public:
Mod(const Mod &);
Mod &operator=(const Mod &);
Mod();
~Mod();
virtual void accept(Visitor *v);
virtual Mod *clone() const;
void swap(Mod &);
};
class LTH : public RelOp
{
public:
LTH(const LTH &);
LTH &operator=(const LTH &);
LTH();
~LTH();
virtual void accept(Visitor *v);
virtual LTH *clone() const;
void swap(LTH &);
};
class LE : public RelOp
{
public:
LE(const LE &);
LE &operator=(const LE &);
LE();
~LE();
virtual void accept(Visitor *v);
virtual LE *clone() const;
void swap(LE &);
};
class GTH : public RelOp
{
public:
GTH(const GTH &);
GTH &operator=(const GTH &);
GTH();
~GTH();
virtual void accept(Visitor *v);
virtual GTH *clone() const;
void swap(GTH &);
};
class GE : public RelOp
{
public:
GE(const GE &);
GE &operator=(const GE &);
GE();
~GE();
virtual void accept(Visitor *v);
virtual GE *clone() const;
void swap(GE &);
};
class EQU : public RelOp
{
public:
EQU(const EQU &);
EQU &operator=(const EQU &);
EQU();
~EQU();
virtual void accept(Visitor *v);
virtual EQU *clone() const;
void swap(EQU &);
};
class NE : public RelOp
{
public:
NE(const NE &);
NE &operator=(const NE &);
NE();
~NE();
virtual void accept(Visitor *v);
virtual NE *clone() const;
void swap(NE &);
};
class ListTopDef : public Visitable, public std::vector<TopDef*>
{
public:
virtual void accept(Visitor *v);
virtual ListTopDef *clone() const;
};
class ListArg : public Visitable, public std::vector<Arg*>
{
public:
virtual void accept(Visitor *v);
virtual ListArg *clone() const;
};
class ListClassBlockDef : public Visitable, public std::vector<ClassBlockDef*>
{
public:
virtual void accept(Visitor *v);
virtual ListClassBlockDef *clone() const;
};
class ListStmt : public Visitable, public std::vector<Stmt*>
{
public:
virtual void accept(Visitor *v);
virtual ListStmt *clone() const;
};
class ListItem : public Visitable, public std::vector<Item*>
{
public:
virtual void accept(Visitor *v);
virtual ListItem *clone() const;
};
class ListType : public Visitable, public std::vector<Type*>
{
public:
virtual void accept(Visitor *v);
virtual ListType *clone() const;
};
class ListExpr : public Visitable, public std::vector<Expr*>
{
public:
virtual void accept(Visitor *v);
virtual ListExpr *clone() const;
};
#endif
position token PIdent (letter (letter|digit|'_'|'\'')*) ;
-- programs ------------------------------------------------
entrypoints Program ;
Prog. Program ::= [TopDef] ;
FnDef. TopDef ::= FunDef ;
ClDef. TopDef ::= ClassDef ;
separator nonempty TopDef "" ;
-- function def --------------------------------------------
FuncDef. FunDef ::= Type PIdent "(" [Arg] ")" Block ;
Ar. Arg ::= Type PIdent;
separator Arg "," ;
-- class def -----------------------------------------------
ClassDefN. ClassDef ::= "class" PIdent ClassBlock ;
ClassDefE. ClassDef ::= "class" PIdent "extends" PIdent ClassBlock ;
ClassBl. ClassBlock ::= "{" [ClassBlockDef] "}" ;
ClassMthd. ClassBlockDef ::= FunDef ;
ClassFld. ClassBlockDef ::= Type [Item] ";" ;
separator ClassBlockDef "" ;
-- statements ----------------------------------------------
Blk. Block ::= "{" [Stmt] "}" ;
separator Stmt "" ;
Empty. Stmt ::= ";" ;
BStmt. Stmt ::= Block ;
Decl. Stmt ::= Type [Item] ";" ;
NoInit. Item ::= PIdent ;
Init. Item ::= PIdent "=" Expr ;
separator nonempty Item "," ;
Ass. Stmt ::= Expr "=" Expr ";" ;
TableAss. Stmt ::= PIdent "[" Expr "]" "=" Expr ";" ;
TableIncr. Stmt ::= PIdent "[" Expr "]" "++" ";" ;
TableDecr. Stmt ::= PIdent "[" Expr "]" "--" ";" ;
Incr. Stmt ::= PIdent "++" ";" ;
Decr. Stmt ::= PIdent "--" ";" ;
Ret. Stmt ::= "return" Expr ";" ;
VRet. Stmt ::= "return" ";" ;
Cond. Stmt ::= "if" "(" Expr ")" Stmt ;
CondElse. Stmt ::= "if" "(" Expr ")" Stmt "else" Stmt ;
While. Stmt ::= "while" "(" Expr ")" Stmt ;
SExp. Stmt ::= Expr ";" ;
ForEach. Stmt ::= "for" "(" Type PIdent ":" Expr ")" Stmt ;
-- Types ---------------------------------------------------
Int. Type ::= "int" ;
Str. Type ::= "string" ;
Bool. Type ::= "boolean" ;
Void. Type ::= "void" ;
Array. Type ::= Type "[" "]" ;
ClassT. Type ::= PIdent ;
internal Fun. Type ::= Type "(" [Type] ")" ;
separator Type "," ;
-- Expressions ---------------------------------------------
EVar. Expr6 ::= PIdent ;
ELitInt. Expr6 ::= Integer ;
ELitTrue. Expr6 ::= "true" ;
ELitFalse. Expr6 ::= "false" ;
EApp. Expr6 ::= PIdent "(" [Expr] ")" ;
EString. Expr6 ::= String ;
ENewArray. Expr6 ::= "new" Type "[" Expr "]" ;
ENewClass. Expr6 ::= "new" PIdent ;
EClsMmbr. Expr6 ::= Expr6 "." PIdent ;
EClsMthd. Expr6 ::= Expr6 "." PIdent "(" [Expr] ")" ;
Null. Expr6 ::= "null" ;
EIndexAcc. Expr6 ::= PIdent "[" Expr "]" ;
ECast. Expr5 ::= "(" PIdent ")" Expr5 ;
Neg. Expr5 ::= "-" Expr6 ;
Not. Expr5 ::= "!" Expr6 ;
EMul. Expr4 ::= Expr4 MulOp Expr5 ;
EAdd. Expr3 ::= Expr3 AddOp Expr4 ;
ERel. Expr2 ::= Expr2 RelOp Expr3 ;
EAnd. Expr1 ::= Expr2 "&&" Expr1 ;
EOr. Expr ::= Expr1 "||" Expr ;
coercions Expr 6 ;
separator Expr "," ;
-- operators -----------------------------------------------
Plus. AddOp ::= "+" ;
Minus. AddOp ::= "-" ;
Times. MulOp ::= "*" ;
Div. MulOp ::= "/" ;
Mod. MulOp ::= "%" ;
LTH. RelOp ::= "<" ;
LE. RelOp ::= "<=" ;
GTH. RelOp ::= ">" ;
GE. RelOp ::= ">=" ;
EQU. RelOp ::= "==" ;
NE. RelOp ::= "!=" ;
-- comments ------------------------------------------------
comment "#" ;
comment "//" ;
comment "/*" "*/" ;
\ No newline at end of file
#include <stdio.h>
#include <string.h>
#include "Parser.h"
#include "Printer.h"
#include "Absyn.h"
#include "Compiler.h"
#include <fstream>
#include <iostream>
#include <filesystem>
std::filesystem::path binaryPath;
void usage() {
printf("usage: Call with one of the following argument combinations:\n");
printf("\t--help\t\tDisplay this help message.\n");
printf("\t(no arguments) Parse stdin silently.\n");
printf("\t(files)\t\tParse content of files silently.\n");
printf("\t-v (files)\tVerbose mode. Parse content of files verbosely.\n");
}
int main(int argc, char ** argv)
{
FILE *input;
int quiet = 0;
char *filename = NULL;
if (argc > 1) {
if (strcmp(argv[1], "-v") == 0) {
if (argc > 2) {
filename = argv[2];
} else {
input = stdin;
}
} else {
quiet = 1;
filename = argv[1];
}
}
if (filename) {
input = fopen(filename, "r");
if (!input) {
usage();
exit(1);
}
} else input = stdin;
/* The default entry point is used. For other options see Parser.H */
Program *parse_tree = pProgram(input);
if (!parse_tree) {
fprintf(stderr, "Parser error, invalid syntax!");
return 1;
}
if (!quiet) {
fprintf(stderr, "\n[Abstract Syntax]\n");
ShowAbsyn s;
fprintf(stderr, "%s\n\n", s.show(parse_tree));
fprintf(stderr, "[Linearized Tree]\n");
PrintAbsyn p;
fprintf(stderr, "%s\n\n", p.print(parse_tree));
}
binaryPath = argv[0];
std::filesystem::path file(filename ? filename : "Instant");
Compiler c(file);
std::string out = c.compile(parse_tree);
if (!filename) {
printf("%s\n", out.data());
return 0;
}
file.replace_extension(Compiler::extension);
std::ofstream ll(file);
if (!ll) {
fprintf(stderr, "Unable to open %s\n", file.c_str());
return 2;
}
ll << out;
ll.close();
Compiler::externalCommand(file);
}
#line 1 "Lexer.cpp"
#line 3 "Lexer.cpp"
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
/* end standard C headers. */
/* flex integer type definitions */
#ifndef FLEXINT_H
#define FLEXINT_H
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif
#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX (4294967295U)
#endif
#ifndef SIZE_MAX
#define SIZE_MAX (~(size_t)0)
#endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
/* begin standard C++ headers. */
/* TODO: this is always defined, so inline it */
#define yyconst const
#if defined(__GNUC__) && __GNUC__ >= 3
#define yynoreturn __attribute__((__noreturn__))
#else
#define yynoreturn
#endif
/* Returned upon end-of-file. */
#define YY_NULL 0
/* Promotes a possibly negative, possibly signed char to an
* integer in range [0..255] for use as an array index.
*/
#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
#define BEGIN (yy_start) = 1 + 2 *
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START (((yy_start) - 1) / 2)
#define YYSTATE YY_START
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning "start processing a new file". */
#define YY_NEW_FILE yyrestart( yyin )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
*/
#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
extern int yyleng;
extern FILE *yyin, *yyout;
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
do \
{ \
/* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
*yy_cp = (yy_hold_char); \
YY_RESTORE_YY_MORE_OFFSET \
(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
#define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
FILE *yy_input_file;
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
int yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
* delete it.
*/
int yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc()
* instead of fread(), to make sure we stop fetching input after
* each newline.
*/
int yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise
* not.
*/
int yy_at_bol;
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
int yy_fill_buffer;
int yy_buffer_status;
#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
/* When an EOF's been seen but there's still some text to process
* then we mark the buffer as YY_EOF_PENDING, to indicate that we
* shouldn't try reading from the input source any more. We might
* still have a bunch of tokens to match, though, because of
* possible backing-up.
*
* When we actually see the EOF, we change the status to "new"
* (via yyrestart()), so that the user can continue scanning by
* just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
/* Stack of input buffers. */
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
* "scanner state".
*
* Returns the top of the stack, or NULL.
*/
#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
? (yy_buffer_stack)[(yy_buffer_stack_top)] \
: NULL)
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
int yyleng;
/* Points to current character in buffer. */
static char *yy_c_buf_p = NULL;
static int yy_init = 0; /* whether we need to initialize */
static int yy_start = 0; /* start state number */
/* Flag which is used to allow yywrap()'s to do buffer switches
* instead of setting up a fresh yyin. A bit of a hack ...
*/
static int yy_did_buffer_switch_on_eof;
void yyrestart ( FILE *input_file );
void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
void yy_delete_buffer ( YY_BUFFER_STATE b );
void yy_flush_buffer ( YY_BUFFER_STATE b );
void yypush_buffer_state ( YY_BUFFER_STATE new_buffer );
void yypop_buffer_state ( void );
static void yyensure_buffer_stack ( void );
static void yy_load_buffer_state ( void );
static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file );
#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER )
YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
void *yyalloc ( yy_size_t );
void *yyrealloc ( void *, yy_size_t );
void yyfree ( void * );
#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
yyensure_buffer_stack (); \
YY_CURRENT_BUFFER_LVALUE = \
yy_create_buffer( yyin, YY_BUF_SIZE ); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
yyensure_buffer_stack (); \
YY_CURRENT_BUFFER_LVALUE = \
yy_create_buffer( yyin, YY_BUF_SIZE ); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* Begin user sect3 */
typedef flex_uint8_t YY_CHAR;
FILE *yyin = NULL, *yyout = NULL;
typedef int yy_state_type;
extern int yylineno;
int yylineno = 1;
extern char *yytext;
#ifdef yytext_ptr
#undef yytext_ptr
#endif
#define yytext_ptr yytext
static yy_state_type yy_get_previous_state ( void );
static yy_state_type yy_try_NUL_trans ( yy_state_type current_state );
static int yy_get_next_buffer ( void );
static void yynoreturn yy_fatal_error ( const char* msg );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
#define YY_DO_BEFORE_ACTION \
(yytext_ptr) = yy_bp; \
yyleng = (int) (yy_cp - yy_bp); \
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
#define YY_NUM_RULES 63
#define YY_END_OF_BUFFER 64
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
{
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_accept[141] =
{ 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 64, 63, 60, 62,
61, 60, 15, 50, 62, 21, 62, 1, 2, 19,
18, 3, 14, 13, 20, 59, 12, 6, 22, 7,
24, 49, 8, 9, 49, 49, 49, 49, 49, 49,
49, 49, 49, 49, 49, 4, 62, 5, 47, 48,
47, 53, 52, 51, 58, 55, 56, 54, 57, 27,
0, 43, 16, 10, 11, 45, 0, 59, 23, 26,
25, 49, 49, 49, 49, 49, 49, 49, 34, 49,
49, 49, 49, 49, 49, 49, 49, 17, 46, 0,
44, 49, 49, 49, 49, 49, 33, 35, 36, 49,
49, 49, 49, 49, 49, 49, 49, 30, 49, 49,
37, 49, 49, 40, 41, 49, 49, 29, 49, 32,
49, 49, 42, 49, 49, 38, 39, 28, 31, 0
} ;
static const YY_CHAR yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 4, 5, 6, 1, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 19, 20, 21,
22, 23, 1, 1, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 26, 27, 1, 28, 1, 29, 30, 31, 32,
33, 34, 35, 36, 37, 24, 24, 38, 24, 39,
40, 24, 24, 41, 42, 43, 44, 45, 46, 47,
24, 24, 48, 49, 50, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1
} ;
static const YY_CHAR yy_meta[51] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
1, 1, 1, 1, 1, 1, 1, 2, 1, 1,
1, 1, 1, 2, 1, 1, 1, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 1, 1, 1
} ;
static const flex_int16_t yy_base[148] =
{ 0,
159, 158, 0, 0, 48, 49, 157, 156, 155, 154,
153, 152, 50, 51, 54, 59, 154, 163, 163, 163,
163, 163, 131, 163, 149, 163, 143, 163, 163, 163,
137, 163, 134, 163, 46, 130, 163, 163, 125, 124,
123, 0, 163, 163, 104, 105, 27, 38, 32, 35,
109, 98, 99, 99, 102, 163, 88, 163, 163, 163,
119, 163, 163, 163, 163, 163, 163, 163, 163, 163,
132, 163, 163, 163, 163, 163, 131, 115, 163, 163,
163, 0, 92, 102, 88, 86, 90, 86, 0, 83,
79, 86, 80, 81, 77, 83, 82, 163, 163, 115,
163, 79, 74, 82, 68, 58, 0, 0, 0, 61,
52, 58, 61, 60, 53, 57, 47, 0, 49, 54,
0, 45, 45, 0, 0, 50, 53, 0, 49, 0,
36, 38, 0, 33, 28, 0, 0, 0, 0, 163,
102, 104, 106, 108, 110, 67, 112
} ;
static const flex_int16_t yy_def[148] =
{ 0,
141, 141, 140, 3, 142, 142, 141, 141, 141, 141,
141, 141, 143, 143, 144, 144, 140, 140, 140, 140,
140, 140, 140, 140, 145, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 146, 140, 140, 146, 146, 146, 146, 146, 146,
146, 146, 146, 146, 146, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
145, 140, 140, 140, 140, 140, 147, 140, 140, 140,
140, 146, 146, 146, 146, 146, 146, 146, 146, 146,
146, 146, 146, 146, 146, 146, 146, 140, 140, 147,
140, 146, 146, 146, 146, 146, 146, 146, 146, 146,
146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
146, 146, 146, 146, 146, 146, 146, 146, 146, 0,
140, 140, 140, 140, 140, 140, 140
} ;
static const flex_int16_t yy_nxt[214] =
{ 0,
20, 21, 22, 23, 24, 25, 26, 27, 20, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 20, 44, 20, 42, 45,
46, 42, 47, 48, 42, 42, 49, 42, 50, 42,
51, 52, 53, 42, 54, 55, 42, 56, 57, 58,
60, 60, 19, 19, 63, 63, 19, 76, 66, 61,
61, 19, 77, 66, 85, 89, 87, 91, 82, 139,
90, 138, 137, 86, 136, 64, 64, 88, 92, 67,
135, 134, 133, 132, 67, 131, 130, 129, 128, 127,
126, 125, 68, 124, 123, 122, 69, 68, 121, 120,
119, 69, 18, 18, 59, 59, 62, 62, 65, 65,
71, 71, 100, 100, 118, 117, 116, 101, 115, 114,
113, 112, 111, 110, 109, 108, 107, 106, 105, 104,
103, 102, 78, 101, 72, 99, 98, 97, 96, 95,
94, 93, 84, 83, 81, 80, 79, 78, 75, 74,
73, 72, 70, 140, 19, 19, 19, 19, 19, 19,
19, 19, 17, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140
} ;
static const flex_int16_t yy_chk[214] =
{ 0,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
5, 6, 13, 14, 13, 14, 15, 35, 15, 5,
6, 16, 35, 16, 47, 49, 48, 50, 146, 135,
49, 134, 132, 47, 131, 13, 14, 48, 50, 15,
129, 127, 126, 123, 16, 122, 120, 119, 117, 116,
115, 114, 15, 113, 112, 111, 15, 16, 110, 106,
105, 16, 141, 141, 142, 142, 143, 143, 144, 144,
145, 145, 147, 147, 104, 103, 102, 100, 97, 96,
95, 94, 93, 92, 91, 90, 88, 87, 86, 85,
84, 83, 78, 77, 71, 61, 57, 55, 54, 53,
52, 51, 46, 45, 41, 40, 39, 36, 33, 31,
27, 25, 23, 17, 12, 11, 10, 9, 8, 7,
2, 1, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140
} ;
static yy_state_type yy_last_accepting_state;
static char *yy_last_accepting_cpos;
extern int yy_flex_debug;
int yy_flex_debug = 0;
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
*/
#define REJECT reject_used_but_not_detected
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
char *yytext;
#line 1 "Grammar.l"
/* This FLex file was machine-generated by the BNF converter */
#line 4 "Grammar.l"
#include <string.h>
#include "Parser.h"
#define YY_BUFFER_LENGTH 4096
extern int yy_mylinenumber ;
static char YY_PARSED_STRING[YY_BUFFER_LENGTH];
static void YY_BUFFER_APPEND(char *s)
{
strcat(YY_PARSED_STRING, s); //Do something better here!
}
static void YY_BUFFER_RESET(void)
{
for(int x = 0; x < YY_BUFFER_LENGTH; x++)
YY_PARSED_STRING[x] = 0;
}
#line 552 "Lexer.cpp"
#line 554 "Lexer.cpp"
#define INITIAL 0
#define YYINITIAL 1
#define COMMENT 2
#define CHAR 3
#define CHARESC 4
#define CHAREND 5
#define STRING 6
#define ESCAPED 7
#ifndef YY_NO_UNISTD_H
/* Special case for "unistd.h", since it is non-ANSI. We include it way
* down here because we want the user's section 1 to have been scanned first.
* The user has a chance to override it with an option.
*/
#include <unistd.h>
#endif
#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif
static int yy_init_globals ( void );
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
int yylex_destroy ( void );
int yyget_debug ( void );
void yyset_debug ( int debug_flag );
YY_EXTRA_TYPE yyget_extra ( void );
void yyset_extra ( YY_EXTRA_TYPE user_defined );
FILE *yyget_in ( void );
void yyset_in ( FILE * _in_str );
FILE *yyget_out ( void );
void yyset_out ( FILE * _out_str );
int yyget_leng ( void );
char *yyget_text ( void );
int yyget_lineno ( void );
void yyset_lineno ( int _line_number );
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap ( void );
#else
extern int yywrap ( void );
#endif
#endif
#ifndef YY_NO_UNPUT
static void yyunput ( int c, char *buf_ptr );
#endif
#ifndef yytext_ptr
static void yy_flex_strncpy ( char *, const char *, int );
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen ( const char * );
#endif
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput ( void );
#else
static int input ( void );
#endif
#endif
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
#ifndef ECHO
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
* is returned in "result".
*/
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
int n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
if ( c == '\n' ) \
buf[n++] = (char) c; \
if ( c == EOF && ferror( yyin ) ) \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
else \
{ \
errno=0; \
while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
break; \
} \
errno=0; \
clearerr(yyin); \
} \
}\
\
#endif
/* No semi-colon after return; correct usage is to write "yyterminate();" -
* we don't want an extra ';' after the "return" because that will cause
* some compilers to complain about unreachable statements.
*/
#ifndef yyterminate
#define yyterminate() return YY_NULL
#endif
/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif
/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
#endif
/* end tables serialization structures and prototypes */
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
extern int yylex (void);
#define YY_DECL int yylex (void)
#endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng
* have been set up.
*/
#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK /*LINTED*/break;
#endif
#define YY_RULE_SETUP \
YY_USER_ACTION
/** The main scanner function which does all the work.
*/
YY_DECL
{
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
if ( !(yy_init) )
{
(yy_init) = 1;
#ifdef YY_USER_INIT
YY_USER_INIT;
#endif
if ( ! (yy_start) )
(yy_start) = 1; /* first start state */
if ( ! yyin )
yyin = stdin;
if ( ! yyout )
yyout = stdout;
if ( ! YY_CURRENT_BUFFER ) {
yyensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
yy_create_buffer( yyin, YY_BUF_SIZE );
}
yy_load_buffer_state( );
}
{
#line 27 "Grammar.l"
#line 781 "Lexer.cpp"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
yy_cp = (yy_c_buf_p);
/* Support of yytext. */
*yy_cp = (yy_hold_char);
/* yy_bp points to the position in yy_ch_buf of the start of
* the current run.
*/
yy_bp = yy_cp;
yy_current_state = (yy_start);
yy_match:
do
{
YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 141 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
while ( yy_base[yy_current_state] != 163 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
if ( yy_act == 0 )
{ /* have to back up */
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
yy_act = yy_accept[yy_current_state];
}
YY_DO_BEFORE_ACTION;
do_action: /* This label is used only to access EOF actions. */
switch ( yy_act )
{ /* beginning of action switch */
case 0: /* must back up */
/* undo the effects of YY_DO_BEFORE_ACTION */
*yy_cp = (yy_hold_char);
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
goto yy_find_action;
case 1:
YY_RULE_SETUP
#line 29 "Grammar.l"
return _SYMB_0;
YY_BREAK
case 2:
YY_RULE_SETUP
#line 30 "Grammar.l"
return _SYMB_1;
YY_BREAK
case 3:
YY_RULE_SETUP
#line 31 "Grammar.l"
return _SYMB_2;
YY_BREAK
case 4:
YY_RULE_SETUP
#line 32 "Grammar.l"
return _SYMB_3;
YY_BREAK
case 5:
YY_RULE_SETUP
#line 33 "Grammar.l"
return _SYMB_4;
YY_BREAK
case 6:
YY_RULE_SETUP
#line 34 "Grammar.l"
return _SYMB_5;
YY_BREAK
case 7:
YY_RULE_SETUP
#line 35 "Grammar.l"
return _SYMB_6;
YY_BREAK
case 8:
YY_RULE_SETUP
#line 36 "Grammar.l"
return _SYMB_7;
YY_BREAK
case 9:
YY_RULE_SETUP
#line 37 "Grammar.l"
return _SYMB_8;
YY_BREAK
case 10:
YY_RULE_SETUP
#line 38 "Grammar.l"
return _SYMB_9;
YY_BREAK
case 11:
YY_RULE_SETUP
#line 39 "Grammar.l"
return _SYMB_10;
YY_BREAK
case 12:
YY_RULE_SETUP
#line 40 "Grammar.l"
return _SYMB_11;
YY_BREAK
case 13:
YY_RULE_SETUP
#line 41 "Grammar.l"
return _SYMB_12;
YY_BREAK
case 14:
YY_RULE_SETUP
#line 42 "Grammar.l"
return _SYMB_13;
YY_BREAK
case 15:
YY_RULE_SETUP
#line 43 "Grammar.l"
return _SYMB_14;
YY_BREAK
case 16:
YY_RULE_SETUP
#line 44 "Grammar.l"
return _SYMB_15;
YY_BREAK
case 17:
YY_RULE_SETUP
#line 45 "Grammar.l"
return _SYMB_16;
YY_BREAK
case 18:
YY_RULE_SETUP
#line 46 "Grammar.l"
return _SYMB_17;
YY_BREAK
case 19:
YY_RULE_SETUP
#line 47 "Grammar.l"
return _SYMB_18;
YY_BREAK
case 20:
YY_RULE_SETUP
#line 48 "Grammar.l"
return _SYMB_19;
YY_BREAK
case 21:
YY_RULE_SETUP
#line 49 "Grammar.l"
return _SYMB_20;
YY_BREAK
case 22:
YY_RULE_SETUP
#line 50 "Grammar.l"
return _SYMB_21;
YY_BREAK
case 23:
YY_RULE_SETUP
#line 51 "Grammar.l"
return _SYMB_22;
YY_BREAK
case 24:
YY_RULE_SETUP
#line 52 "Grammar.l"
return _SYMB_23;
YY_BREAK
case 25:
YY_RULE_SETUP
#line 53 "Grammar.l"
return _SYMB_24;
YY_BREAK
case 26:
YY_RULE_SETUP
#line 54 "Grammar.l"
return _SYMB_25;
YY_BREAK
case 27:
YY_RULE_SETUP
#line 55 "Grammar.l"
return _SYMB_26;
YY_BREAK
case 28:
YY_RULE_SETUP
#line 56 "Grammar.l"
return _SYMB_27;
YY_BREAK
case 29:
YY_RULE_SETUP
#line 57 "Grammar.l"
return _SYMB_28;
YY_BREAK
case 30:
YY_RULE_SETUP
#line 58 "Grammar.l"
return _SYMB_29;
YY_BREAK
case 31:
YY_RULE_SETUP
#line 59 "Grammar.l"
return _SYMB_30;
YY_BREAK
case 32:
YY_RULE_SETUP
#line 60 "Grammar.l"
return _SYMB_31;
YY_BREAK
case 33:
YY_RULE_SETUP
#line 61 "Grammar.l"
return _SYMB_32;
YY_BREAK
case 34:
YY_RULE_SETUP
#line 62 "Grammar.l"
return _SYMB_33;
YY_BREAK
case 35:
YY_RULE_SETUP
#line 63 "Grammar.l"
return _SYMB_34;
YY_BREAK
case 36:
YY_RULE_SETUP
#line 64 "Grammar.l"
return _SYMB_35;
YY_BREAK
case 37:
YY_RULE_SETUP
#line 65 "Grammar.l"
return _SYMB_36;
YY_BREAK
case 38:
YY_RULE_SETUP
#line 66 "Grammar.l"
return _SYMB_37;
YY_BREAK
case 39:
YY_RULE_SETUP
#line 67 "Grammar.l"
return _SYMB_38;
YY_BREAK
case 40:
YY_RULE_SETUP
#line 68 "Grammar.l"
return _SYMB_39;
YY_BREAK
case 41:
YY_RULE_SETUP
#line 69 "Grammar.l"
return _SYMB_40;
YY_BREAK
case 42:
YY_RULE_SETUP
#line 70 "Grammar.l"
return _SYMB_41;
YY_BREAK
case 43:
/* rule 43 can match eol */
YY_RULE_SETUP
#line 72 "Grammar.l"
++yy_mylinenumber; // BNFC: comment "#";
YY_BREAK
case 44:
/* rule 44 can match eol */
YY_RULE_SETUP
#line 73 "Grammar.l"
++yy_mylinenumber; // BNFC: comment "//";
YY_BREAK
case 45:
YY_RULE_SETUP
#line 74 "Grammar.l"
BEGIN COMMENT; // BNFC: comment "/*" "*/";
YY_BREAK
case 46:
YY_RULE_SETUP
#line 75 "Grammar.l"
BEGIN YYINITIAL;
YY_BREAK
case 47:
YY_RULE_SETUP
#line 76 "Grammar.l"
/* skip */;
YY_BREAK
case 48:
/* rule 48 can match eol */
YY_RULE_SETUP
#line 77 "Grammar.l"
++yy_mylinenumber;
YY_BREAK
case 49:
YY_RULE_SETUP
#line 79 "Grammar.l"
yylval.string_ = strdup(yytext); return _SYMB_42;
YY_BREAK
case 50:
YY_RULE_SETUP
#line 80 "Grammar.l"
BEGIN STRING;
YY_BREAK
case 51:
YY_RULE_SETUP
#line 81 "Grammar.l"
BEGIN ESCAPED;
YY_BREAK
case 52:
YY_RULE_SETUP
#line 82 "Grammar.l"
yylval.string_ = strdup(YY_PARSED_STRING); YY_BUFFER_RESET(); BEGIN YYINITIAL; return _STRING_;
YY_BREAK
case 53:
YY_RULE_SETUP
#line 83 "Grammar.l"
YY_BUFFER_APPEND(yytext);
YY_BREAK
case 54:
YY_RULE_SETUP
#line 84 "Grammar.l"
YY_BUFFER_APPEND("\n"); BEGIN STRING;
YY_BREAK
case 55:
YY_RULE_SETUP
#line 85 "Grammar.l"
YY_BUFFER_APPEND("\""); BEGIN STRING ;
YY_BREAK
case 56:
YY_RULE_SETUP
#line 86 "Grammar.l"
YY_BUFFER_APPEND("\\"); BEGIN STRING;
YY_BREAK
case 57:
YY_RULE_SETUP
#line 87 "Grammar.l"
YY_BUFFER_APPEND("\t"); BEGIN STRING;
YY_BREAK
case 58:
YY_RULE_SETUP
#line 88 "Grammar.l"
YY_BUFFER_APPEND(yytext); BEGIN STRING;
YY_BREAK
case 59:
YY_RULE_SETUP
#line 89 "Grammar.l"
yylval.int_ = atoi(yytext); return _INTEGER_;
YY_BREAK
case 60:
/* rule 60 can match eol */
YY_RULE_SETUP
#line 90 "Grammar.l"
++yy_mylinenumber ;
YY_BREAK
case 61:
/* rule 61 can match eol */
YY_RULE_SETUP
#line 91 "Grammar.l"
/* ignore white space. */;
YY_BREAK
case 62:
YY_RULE_SETUP
#line 92 "Grammar.l"
return _ERROR_;
YY_BREAK
case 63:
YY_RULE_SETUP
#line 93 "Grammar.l"
ECHO;
YY_BREAK
#line 1158 "Lexer.cpp"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(YYINITIAL):
case YY_STATE_EOF(COMMENT):
case YY_STATE_EOF(CHAR):
case YY_STATE_EOF(CHARESC):
case YY_STATE_EOF(CHAREND):
case YY_STATE_EOF(STRING):
case YY_STATE_EOF(ESCAPED):
yyterminate();
case YY_END_OF_BUFFER:
{
/* Amount of text matched not including the EOB char. */
int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
/* Undo the effects of YY_DO_BEFORE_ACTION. */
*yy_cp = (yy_hold_char);
YY_RESTORE_YY_MORE_OFFSET
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
{
/* We're scanning a new file or input source. It's
* possible that this happened because the user
* just pointed yyin at a new source and called
* yylex(). If so, then we have to assure
* consistency between YY_CURRENT_BUFFER and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
* back-up) that will match for the new input source.
*/
(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
}
/* Note that here we test for yy_c_buf_p "<=" to the position
* of the first EOB in the buffer, since yy_c_buf_p will
* already have been incremented past the NUL character
* (since all states make transitions on EOB to the
* end-of-buffer state). Contrast this with the test
* in input().
*/
if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
{ /* This was really a NUL. */
yy_state_type yy_next_state;
(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state( );
/* Okay, we're now positioned to make the NUL
* transition. We couldn't have
* yy_get_previous_state() go ahead and do it
* for us because it doesn't know how to deal
* with the possibility of jamming (and we don't
* want to build jamming into it because then it
* will run more slowly).
*/
yy_next_state = yy_try_NUL_trans( yy_current_state );
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
if ( yy_next_state )
{
/* Consume the NUL. */
yy_cp = ++(yy_c_buf_p);
yy_current_state = yy_next_state;
goto yy_match;
}
else
{
yy_cp = (yy_c_buf_p);
goto yy_find_action;
}
}
else switch ( yy_get_next_buffer( ) )
{
case EOB_ACT_END_OF_FILE:
{
(yy_did_buffer_switch_on_eof) = 0;
if ( yywrap( ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
* yytext, we can now set up
* yy_c_buf_p so that if some total
* hoser (like flex itself) wants to
* call the scanner after we return the
* YY_NULL, it'll still work - another
* YY_NULL will get returned.
*/
(yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
yy_act = YY_STATE_EOF(YY_START);
goto do_action;
}
else
{
if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
}
break;
}
case EOB_ACT_CONTINUE_SCAN:
(yy_c_buf_p) =
(yytext_ptr) + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state( );
yy_cp = (yy_c_buf_p);
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
goto yy_match;
case EOB_ACT_LAST_MATCH:
(yy_c_buf_p) =
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
yy_current_state = yy_get_previous_state( );
yy_cp = (yy_c_buf_p);
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
goto yy_find_action;
}
break;
}
default:
YY_FATAL_ERROR(
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
} /* end of user's declarations */
} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
*
* Returns a code representing an action:
* EOB_ACT_LAST_MATCH -
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
* EOB_ACT_END_OF_FILE - end of file
*/
static int yy_get_next_buffer (void)
{
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = (yytext_ptr);
int number_to_move, i;
int ret_val;
if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
YY_FATAL_ERROR(
"fatal flex scanner internal error--end of buffer missed" );
if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
{ /* Don't try to fill the buffer, so this is an EOF. */
if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
{
/* We matched a single character, the EOB, so
* treat this as a final EOF.
*/
return EOB_ACT_END_OF_FILE;
}
else
{
/* We matched some text prior to the EOB, first
* process it.
*/
return EOB_ACT_LAST_MATCH;
}
}
/* Try to read more data. */
/* First move last chars to start of buffer. */
number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
/* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF
*/
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
else
{
int num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
int new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
else
b->yy_buf_size *= 2;
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
yyrealloc( (void *) b->yy_ch_buf,
(yy_size_t) (b->yy_buf_size + 2) );
}
else
/* Can't grow it, we don't own it. */
b->yy_ch_buf = NULL;
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR(
"fatal error - scanner input buffer overflow" );
(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
number_to_move - 1;
}
if ( num_to_read > YY_READ_BUF_SIZE )
num_to_read = YY_READ_BUF_SIZE;
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
(yy_n_chars), num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
if ( (yy_n_chars) == 0 )
{
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
yyrestart( yyin );
}
else
{
ret_val = EOB_ACT_LAST_MATCH;
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
YY_BUFFER_EOF_PENDING;
}
}
else
ret_val = EOB_ACT_CONTINUE_SCAN;
if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
/* "- 2" to take care of EOB's */
YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
}
(yy_n_chars) += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
return ret_val;
}
/* yy_get_previous_state - get the state just before the EOB char was reached */
static yy_state_type yy_get_previous_state (void)
{
yy_state_type yy_current_state;
char *yy_cp;
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 141 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
}
return yy_current_state;
}
/* yy_try_NUL_trans - try to make a transition on the NUL character
*
* synopsis
* next_state = yy_try_NUL_trans( current_state );
*/
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
{
int yy_is_jam;
char *yy_cp = (yy_c_buf_p);
YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 141 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 140);
return yy_is_jam ? 0 : yy_current_state;
}
#ifndef YY_NO_UNPUT
static void yyunput (int c, char * yy_bp )
{
char *yy_cp;
yy_cp = (yy_c_buf_p);
/* undo effects of setting up yytext */
*yy_cp = (yy_hold_char);
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
int number_to_move = (yy_n_chars) + 2;
char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
char *source =
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
*--dest = *--source;
yy_cp += (int) (dest - source);
yy_bp += (int) (dest - source);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
(yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
YY_FATAL_ERROR( "flex scanner push-back overflow" );
}
*--yy_cp = (char) c;
(yytext_ptr) = yy_bp;
(yy_hold_char) = *yy_cp;
(yy_c_buf_p) = yy_cp;
}
#endif
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void)
#else
static int input (void)
#endif
{
int c;
*(yy_c_buf_p) = (yy_hold_char);
if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
{
/* yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer.
*/
if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
/* This was really a NUL. */
*(yy_c_buf_p) = '\0';
else
{ /* need more input */
int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
{
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
* sees that we've accumulated a
* token and flags that we need to
* try matching the token before
* proceeding. But for input(),
* there's no matching to consider.
* So convert the EOB_ACT_LAST_MATCH
* to EOB_ACT_END_OF_FILE.
*/
/* Reset buffer status. */
yyrestart( yyin );
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
if ( yywrap( ) )
return 0;
if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
#ifdef __cplusplus
return yyinput();
#else
return input();
#endif
}
case EOB_ACT_CONTINUE_SCAN:
(yy_c_buf_p) = (yytext_ptr) + offset;
break;
}
}
}
c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
*(yy_c_buf_p) = '\0'; /* preserve yytext */
(yy_hold_char) = *++(yy_c_buf_p);
return c;
}
#endif /* ifndef YY_NO_INPUT */
/** Immediately switch to a different input stream.
* @param input_file A readable stream.
*
* @note This function does not reset the start condition to @c INITIAL .
*/
void yyrestart (FILE * input_file )
{
if ( ! YY_CURRENT_BUFFER ){
yyensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
yy_create_buffer( yyin, YY_BUF_SIZE );
}
yy_init_buffer( YY_CURRENT_BUFFER, input_file );
yy_load_buffer_state( );
}
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
*
*/
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
{
/* TODO. We should be able to replace this entire function body
* with
* yypop_buffer_state();
* yypush_buffer_state(new_buffer);
*/
yyensure_buffer_stack ();
if ( YY_CURRENT_BUFFER == new_buffer )
return;
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
*(yy_c_buf_p) = (yy_hold_char);
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
yy_load_buffer_state( );
/* We don't actually know whether we did this switch during
* EOF (yywrap()) processing, but the only time this flag
* is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
(yy_did_buffer_switch_on_eof) = 1;
}
static void yy_load_buffer_state (void)
{
(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
(yy_hold_char) = *(yy_c_buf_p);
}
/** Allocate and initialize an input buffer state.
* @param file A readable stream.
* @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
*
* @return the allocated buffer state.
*/
YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
{
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
yy_init_buffer( b, file );
return b;
}
/** Destroy the buffer.
* @param b a buffer created with yy_create_buffer()
*
*/
void yy_delete_buffer (YY_BUFFER_STATE b )
{
if ( ! b )
return;
if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
yyfree( (void *) b->yy_ch_buf );
yyfree( (void *) b );
}
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a yyrestart() or at EOF.
*/
static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
{
int oerrno = errno;
yy_flush_buffer( b );
b->yy_input_file = file;
b->yy_fill_buffer = 1;
/* If b is the current buffer, then yy_init_buffer was _probably_
* called from yyrestart() or through yy_get_next_buffer.
* In that case, we don't want to reset the lineno or column.
*/
if (b != YY_CURRENT_BUFFER){
b->yy_bs_lineno = 1;
b->yy_bs_column = 0;
}
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
errno = oerrno;
}
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
*
*/
void yy_flush_buffer (YY_BUFFER_STATE b )
{
if ( ! b )
return;
b->yy_n_chars = 0;
/* We always need two end-of-buffer characters. The first causes
* a transition to the end-of-buffer state. The second causes
* a jam in that state.
*/
b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
b->yy_buf_pos = &b->yy_ch_buf[0];
b->yy_at_bol = 1;
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
yy_load_buffer_state( );
}
/** Pushes the new state onto the stack. The new state becomes
* the current state. This function will allocate the stack
* if necessary.
* @param new_buffer The new state.
*
*/
void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
{
if (new_buffer == NULL)
return;
yyensure_buffer_stack();
/* This block is copied from yy_switch_to_buffer. */
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
*(yy_c_buf_p) = (yy_hold_char);
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
/* Only push if top exists. Otherwise, replace top. */
if (YY_CURRENT_BUFFER)
(yy_buffer_stack_top)++;
YY_CURRENT_BUFFER_LVALUE = new_buffer;
/* copied from yy_switch_to_buffer. */
yy_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
}
/** Removes and deletes the top of the stack, if present.
* The next element becomes the new top.
*
*/
void yypop_buffer_state (void)
{
if (!YY_CURRENT_BUFFER)
return;
yy_delete_buffer(YY_CURRENT_BUFFER );
YY_CURRENT_BUFFER_LVALUE = NULL;
if ((yy_buffer_stack_top) > 0)
--(yy_buffer_stack_top);
if (YY_CURRENT_BUFFER) {
yy_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
}
}
/* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/
static void yyensure_buffer_stack (void)
{
yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
/* First allocation is just for 2 elements, since we don't know if this
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
(yy_buffer_stack_top) = 0;
return;
}
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
/* Increase the buffer to prepare for a possible push. */
yy_size_t grow_size = 8 /* arbitrary grow size */;
num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
((yy_buffer_stack),
num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
}
}
/** Setup the input buffer state to scan directly from a user-specified character buffer.
* @param base the character buffer
* @param size the size in bytes of the character buffer
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
{
YY_BUFFER_STATE b;
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
return NULL;
b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = NULL;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
yy_switch_to_buffer( b );
return b;
}
/** Setup the input buffer state to scan a string. The next call to yylex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
*
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
* yy_scan_bytes() instead.
*/
YY_BUFFER_STATE yy_scan_string (const char * yystr )
{
return yy_scan_bytes( yystr, (int) strlen(yystr) );
}
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
int i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = (yy_size_t) (_yybytes_len + 2);
buf = (char *) yyalloc( n );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
for ( i = 0; i < _yybytes_len; ++i )
buf[i] = yybytes[i];
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
b = yy_scan_buffer( buf, n );
if ( ! b )
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
/* It's okay to grow etc. this buffer, and we should throw it
* away when we're done.
*/
b->yy_is_our_buffer = 1;
return b;
}
#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif
static void yynoreturn yy_fatal_error (const char* msg )
{
fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
/* Redefine yyless() so it works in section 3 code. */
#undef yyless
#define yyless(n) \
do \
{ \
/* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
yytext[yyleng] = (yy_hold_char); \
(yy_c_buf_p) = yytext + yyless_macro_arg; \
(yy_hold_char) = *(yy_c_buf_p); \
*(yy_c_buf_p) = '\0'; \
yyleng = yyless_macro_arg; \
} \
while ( 0 )
/* Accessor methods (get/set functions) to struct members. */
/** Get the current line number.
*
*/
int yyget_lineno (void)
{
return yylineno;
}
/** Get the input stream.
*
*/
FILE *yyget_in (void)
{
return yyin;
}
/** Get the output stream.
*
*/
FILE *yyget_out (void)
{
return yyout;
}
/** Get the length of the current token.
*
*/
int yyget_leng (void)
{
return yyleng;
}
/** Get the current token.
*
*/
char *yyget_text (void)
{
return yytext;
}
/** Set the current line number.
* @param _line_number line number
*
*/
void yyset_lineno (int _line_number )
{
yylineno = _line_number;
}
/** Set the input stream. This does not discard the current
* input buffer.
* @param _in_str A readable stream.
*
* @see yy_switch_to_buffer
*/
void yyset_in (FILE * _in_str )
{
yyin = _in_str ;
}
void yyset_out (FILE * _out_str )
{
yyout = _out_str ;
}
int yyget_debug (void)
{
return yy_flex_debug;
}
void yyset_debug (int _bdebug )
{
yy_flex_debug = _bdebug ;
}
static int yy_init_globals (void)
{
/* Initialization is the same as for the non-reentrant scanner.
* This function is called from yylex_destroy(), so don't allocate here.
*/
(yy_buffer_stack) = NULL;
(yy_buffer_stack_top) = 0;
(yy_buffer_stack_max) = 0;
(yy_c_buf_p) = NULL;
(yy_init) = 0;
(yy_start) = 0;
/* Defined in main.c */
#ifdef YY_STDINIT
yyin = stdin;
yyout = stdout;
#else
yyin = NULL;
yyout = NULL;
#endif
/* For future reference: Set errno on error, since we are called by
* yylex_init()
*/
return 0;
}
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy (void)
{
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
yy_delete_buffer( YY_CURRENT_BUFFER );
YY_CURRENT_BUFFER_LVALUE = NULL;
yypop_buffer_state();
}
/* Destroy the stack itself. */
yyfree((yy_buffer_stack) );
(yy_buffer_stack) = NULL;
/* Reset the globals. This is important in a non-reentrant scanner so the next time
* yylex() is called, initialization will occur. */
yy_init_globals( );
return 0;
}
/*
* Internal utility routines.
*/
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, const char * s2, int n )
{
int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (const char * s )
{
int n;
for ( n = 0; s[n]; ++n )
;
return n;
}
#endif
void *yyalloc (yy_size_t size )
{
return malloc(size);
}
void *yyrealloc (void * ptr, yy_size_t size )
{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
* because both ANSI C and C++ allow castless assignment from
* any pointer type to void*, and deal with argument conversions
* as though doing an assignment.
*/
return realloc(ptr, size);
}
void yyfree (void * ptr )
{
free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"
#line 93 "Grammar.l"
void initialize_lexer(FILE *inp) { yyrestart(inp); BEGIN YYINITIAL; }
int yywrap(void) { return 1; }
CC=g++
CCFLAGS=-g -W -Wall
FLEX=flex
FLEX_OPTS=-PGrammar
BISON=bison
BISON_OPTS=-t -pGrammar
OBJS=Absyn.o Lexer.o Parser.o Printer.o
.PHONY : clean distclean
all : TestGrammar
clean :
rm -f *.o TestGrammar Grammar.aux Grammar.log Grammar.pdf Grammar.dvi Grammar.ps Grammar
distclean : clean
rm -f Absyn.cpp Absyn.h Test.cpp Parser.cpp Parser.h Lexer.cpp Skeleton.cpp Skeleton.h Printer.cpp Printer.h Makefile Grammar.l Grammar.y Grammar.tex
TestGrammar : ${OBJS} Test.o
@echo "Linking TestGrammar..."
${CC} ${CCFLAGS} ${OBJS} Test.o -o TestGrammar
Absyn.o : Absyn.cpp Absyn.h
${CC} ${CCFLAGS} -c Absyn.cpp
Lexer.cpp : Grammar.l
${FLEX} -oLexer.cpp Grammar.l
Parser.cpp : Grammar.y
${BISON} Grammar.y -o Parser.cpp
Lexer.o : Lexer.cpp Parser.h
${CC} ${CCFLAGS} -c Lexer.cpp
Parser.o : Parser.cpp Absyn.h
${CC} ${CCFLAGS} -c Parser.cpp
Printer.o : Printer.cpp Printer.h Absyn.h
${CC} ${CCFLAGS} -c Printer.cpp
Skeleton.o : Skeleton.cpp Skeleton.h Absyn.h
${CC} ${CCFLAGS} -Wno-unused-parameter -c Skeleton.cpp
Test.o : Test.cpp Parser.h Printer.h Absyn.h
${CC} ${CCFLAGS} -c Test.cpp
/* A Bison parser, made by GNU Bison 3.7.2. */
/* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
variables, as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "3.7.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.cpp"
/* Pure parsers. */
#define YYPURE 0
/* Push parsers. */
#define YYPUSH 0
/* Pull parsers. */
#define YYPULL 1
/* First part of user prologue. */
#line 2 "Grammar.y"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include "Absyn.h"
typedef struct yy_buffer_state *YY_BUFFER_STATE;
int yyparse(void);
int yylex(void);
YY_BUFFER_STATE yy_scan_string(const char *str);
void yy_delete_buffer(YY_BUFFER_STATE buf);
int yy_mylinenumber;
int initialize_lexer(FILE * inp);
int yywrap(void)
{
return 1;
}
void yyerror(const char *str)
{
extern char *yytext;
fprintf(stderr,"error: line %d: %s at %s\n",
yy_mylinenumber, str, yytext);
}
static Program* YY_RESULT_Program_ = 0;
static PIdent* YY_RESULT_PIdent_ = 0;
Program* pProgram(FILE *inp)
{
yy_mylinenumber = 1;
initialize_lexer(inp);
if (yyparse())
{ /* Failure */
return 0;
}
else
{ /* Success */
return YY_RESULT_Program_;
}
}
Program* pProgram(const char *str)
{
YY_BUFFER_STATE buf;
int result;
yy_mylinenumber = 1;
initialize_lexer(0);
buf = yy_scan_string(str);
result = yyparse();
yy_delete_buffer(buf);
if (result)
{ /* Failure */
return 0;
}
else
{ /* Success */
return YY_RESULT_Program_;
}
}
PIdent* pPIdent(FILE *inp)
{
yy_mylinenumber = 1;
initialize_lexer(inp);
if (yyparse())
{ /* Failure */
return 0;
}
else
{ /* Success */
return YY_RESULT_PIdent_;
}
}
PIdent* pPIdent(const char *str)
{
YY_BUFFER_STATE buf;
int result;
yy_mylinenumber = 1;
initialize_lexer(0);
buf = yy_scan_string(str);
result = yyparse();
yy_delete_buffer(buf);
if (result)
{ /* Failure */
return 0;
}
else
{ /* Success */
return YY_RESULT_PIdent_;
}
}
#line 168 "Parser.cpp"
# ifndef YY_CAST
# ifdef __cplusplus
# define YY_CAST(Type, Val) static_cast<Type> (Val)
# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
# else
# define YY_CAST(Type, Val) ((Type) (Val))
# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
# endif
# endif
# ifndef YY_NULLPTR
# if defined __cplusplus
# if 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# else
# define YY_NULLPTR 0
# endif
# else
# define YY_NULLPTR ((void*)0)
# endif
# endif
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Token kinds. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
YYEMPTY = -2,
YYEOF = 0, /* "end of file" */
YYerror = 256, /* error */
YYUNDEF = 257, /* "invalid token" */
_ERROR_ = 258, /* _ERROR_ */
_SYMB_0 = 259, /* _SYMB_0 */
_SYMB_1 = 260, /* _SYMB_1 */
_SYMB_2 = 261, /* _SYMB_2 */
_SYMB_3 = 262, /* _SYMB_3 */
_SYMB_4 = 263, /* _SYMB_4 */
_SYMB_5 = 264, /* _SYMB_5 */
_SYMB_6 = 265, /* _SYMB_6 */
_SYMB_7 = 266, /* _SYMB_7 */
_SYMB_8 = 267, /* _SYMB_8 */
_SYMB_9 = 268, /* _SYMB_9 */
_SYMB_10 = 269, /* _SYMB_10 */
_SYMB_11 = 270, /* _SYMB_11 */
_SYMB_12 = 271, /* _SYMB_12 */
_SYMB_13 = 272, /* _SYMB_13 */
_SYMB_14 = 273, /* _SYMB_14 */
_SYMB_15 = 274, /* _SYMB_15 */
_SYMB_16 = 275, /* _SYMB_16 */
_SYMB_17 = 276, /* _SYMB_17 */
_SYMB_18 = 277, /* _SYMB_18 */
_SYMB_19 = 278, /* _SYMB_19 */
_SYMB_20 = 279, /* _SYMB_20 */
_SYMB_21 = 280, /* _SYMB_21 */
_SYMB_22 = 281, /* _SYMB_22 */
_SYMB_23 = 282, /* _SYMB_23 */
_SYMB_24 = 283, /* _SYMB_24 */
_SYMB_25 = 284, /* _SYMB_25 */
_SYMB_26 = 285, /* _SYMB_26 */
_SYMB_27 = 286, /* _SYMB_27 */
_SYMB_28 = 287, /* _SYMB_28 */
_SYMB_29 = 288, /* _SYMB_29 */
_SYMB_30 = 289, /* _SYMB_30 */
_SYMB_31 = 290, /* _SYMB_31 */
_SYMB_32 = 291, /* _SYMB_32 */
_SYMB_33 = 292, /* _SYMB_33 */
_SYMB_34 = 293, /* _SYMB_34 */
_SYMB_35 = 294, /* _SYMB_35 */
_SYMB_36 = 295, /* _SYMB_36 */
_SYMB_37 = 296, /* _SYMB_37 */
_SYMB_38 = 297, /* _SYMB_38 */
_SYMB_39 = 298, /* _SYMB_39 */
_SYMB_40 = 299, /* _SYMB_40 */
_SYMB_41 = 300, /* _SYMB_41 */
_SYMB_42 = 301, /* _SYMB_42 */
_STRING_ = 302, /* _STRING_ */
_INTEGER_ = 303 /* _INTEGER_ */
};
typedef enum yytokentype yytoken_kind_t;
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 100 "Grammar.y"
int int_;
char char_;
double double_;
char* string_;
PIdent* pident_;
Program* program_;
TopDef* topdef_;
ListTopDef* listtopdef_;
FunDef* fundef_;
Arg* arg_;
ListArg* listarg_;
ClassDef* classdef_;
ClassBlock* classblock_;
ClassBlockDef* classblockdef_;
ListClassBlockDef* listclassblockdef_;
Block* block_;
ListStmt* liststmt_;
Stmt* stmt_;
Item* item_;
ListItem* listitem_;
Type* type_;
ListType* listtype_;
Expr* expr_;
ListExpr* listexpr_;
AddOp* addop_;
MulOp* mulop_;
RelOp* relop_;
#line 293 "Parser.cpp"
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval;
int yyparse (void);
/* Symbol kind. */
enum yysymbol_kind_t
{
YYSYMBOL_YYEMPTY = -2,
YYSYMBOL_YYEOF = 0, /* "end of file" */
YYSYMBOL_YYerror = 1, /* error */
YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
YYSYMBOL__ERROR_ = 3, /* _ERROR_ */
YYSYMBOL__SYMB_0 = 4, /* _SYMB_0 */
YYSYMBOL__SYMB_1 = 5, /* _SYMB_1 */
YYSYMBOL__SYMB_2 = 6, /* _SYMB_2 */
YYSYMBOL__SYMB_3 = 7, /* _SYMB_3 */
YYSYMBOL__SYMB_4 = 8, /* _SYMB_4 */
YYSYMBOL__SYMB_5 = 9, /* _SYMB_5 */
YYSYMBOL__SYMB_6 = 10, /* _SYMB_6 */
YYSYMBOL__SYMB_7 = 11, /* _SYMB_7 */
YYSYMBOL__SYMB_8 = 12, /* _SYMB_8 */
YYSYMBOL__SYMB_9 = 13, /* _SYMB_9 */
YYSYMBOL__SYMB_10 = 14, /* _SYMB_10 */
YYSYMBOL__SYMB_11 = 15, /* _SYMB_11 */
YYSYMBOL__SYMB_12 = 16, /* _SYMB_12 */
YYSYMBOL__SYMB_13 = 17, /* _SYMB_13 */
YYSYMBOL__SYMB_14 = 18, /* _SYMB_14 */
YYSYMBOL__SYMB_15 = 19, /* _SYMB_15 */
YYSYMBOL__SYMB_16 = 20, /* _SYMB_16 */
YYSYMBOL__SYMB_17 = 21, /* _SYMB_17 */
YYSYMBOL__SYMB_18 = 22, /* _SYMB_18 */
YYSYMBOL__SYMB_19 = 23, /* _SYMB_19 */
YYSYMBOL__SYMB_20 = 24, /* _SYMB_20 */
YYSYMBOL__SYMB_21 = 25, /* _SYMB_21 */
YYSYMBOL__SYMB_22 = 26, /* _SYMB_22 */
YYSYMBOL__SYMB_23 = 27, /* _SYMB_23 */
YYSYMBOL__SYMB_24 = 28, /* _SYMB_24 */
YYSYMBOL__SYMB_25 = 29, /* _SYMB_25 */
YYSYMBOL__SYMB_26 = 30, /* _SYMB_26 */
YYSYMBOL__SYMB_27 = 31, /* _SYMB_27 */
YYSYMBOL__SYMB_28 = 32, /* _SYMB_28 */
YYSYMBOL__SYMB_29 = 33, /* _SYMB_29 */
YYSYMBOL__SYMB_30 = 34, /* _SYMB_30 */
YYSYMBOL__SYMB_31 = 35, /* _SYMB_31 */
YYSYMBOL__SYMB_32 = 36, /* _SYMB_32 */
YYSYMBOL__SYMB_33 = 37, /* _SYMB_33 */
YYSYMBOL__SYMB_34 = 38, /* _SYMB_34 */
YYSYMBOL__SYMB_35 = 39, /* _SYMB_35 */
YYSYMBOL__SYMB_36 = 40, /* _SYMB_36 */
YYSYMBOL__SYMB_37 = 41, /* _SYMB_37 */
YYSYMBOL__SYMB_38 = 42, /* _SYMB_38 */
YYSYMBOL__SYMB_39 = 43, /* _SYMB_39 */
YYSYMBOL__SYMB_40 = 44, /* _SYMB_40 */
YYSYMBOL__SYMB_41 = 45, /* _SYMB_41 */
YYSYMBOL__SYMB_42 = 46, /* _SYMB_42 */
YYSYMBOL__STRING_ = 47, /* _STRING_ */
YYSYMBOL__INTEGER_ = 48, /* _INTEGER_ */
YYSYMBOL_YYACCEPT = 49, /* $accept */
YYSYMBOL_Program = 50, /* Program */
YYSYMBOL_TopDef = 51, /* TopDef */
YYSYMBOL_ListTopDef = 52, /* ListTopDef */
YYSYMBOL_FunDef = 53, /* FunDef */
YYSYMBOL_Arg = 54, /* Arg */
YYSYMBOL_ListArg = 55, /* ListArg */
YYSYMBOL_ClassDef = 56, /* ClassDef */
YYSYMBOL_ClassBlock = 57, /* ClassBlock */
YYSYMBOL_ClassBlockDef = 58, /* ClassBlockDef */
YYSYMBOL_ListClassBlockDef = 59, /* ListClassBlockDef */
YYSYMBOL_Block = 60, /* Block */
YYSYMBOL_ListStmt = 61, /* ListStmt */
YYSYMBOL_Stmt = 62, /* Stmt */
YYSYMBOL_Item = 63, /* Item */
YYSYMBOL_ListItem = 64, /* ListItem */
YYSYMBOL_Type = 65, /* Type */
YYSYMBOL_Expr6 = 66, /* Expr6 */
YYSYMBOL_Expr5 = 67, /* Expr5 */
YYSYMBOL_Expr4 = 68, /* Expr4 */
YYSYMBOL_Expr3 = 69, /* Expr3 */
YYSYMBOL_Expr2 = 70, /* Expr2 */
YYSYMBOL_Expr1 = 71, /* Expr1 */
YYSYMBOL_Expr = 72, /* Expr */
YYSYMBOL_ListExpr = 73, /* ListExpr */
YYSYMBOL_AddOp = 74, /* AddOp */
YYSYMBOL_MulOp = 75, /* MulOp */
YYSYMBOL_RelOp = 76, /* RelOp */
YYSYMBOL_PIdent = 77 /* PIdent */
};
typedef enum yysymbol_kind_t yysymbol_kind_t;
#ifdef short
# undef short
#endif
/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
<limits.h> and (if available) <stdint.h> are included
so that the code can choose integer types of a good width. */
#ifndef __PTRDIFF_MAX__
# include <limits.h> /* INFRINGES ON USER NAME SPACE */
# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
# define YY_STDINT_H
# endif
#endif
/* Narrow types that promote to a signed type and that can represent a
signed or unsigned integer of at least N bits. In tables they can
save space and decrease cache pressure. Promoting to a signed type
helps avoid bugs in integer arithmetic. */
#ifdef __INT_LEAST8_MAX__
typedef __INT_LEAST8_TYPE__ yytype_int8;
#elif defined YY_STDINT_H
typedef int_least8_t yytype_int8;
#else
typedef signed char yytype_int8;
#endif
#ifdef __INT_LEAST16_MAX__
typedef __INT_LEAST16_TYPE__ yytype_int16;
#elif defined YY_STDINT_H
typedef int_least16_t yytype_int16;
#else
typedef short yytype_int16;
#endif
#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
&& UINT_LEAST8_MAX <= INT_MAX)
typedef uint_least8_t yytype_uint8;
#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
typedef unsigned char yytype_uint8;
#else
typedef short yytype_uint8;
#endif
#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
&& UINT_LEAST16_MAX <= INT_MAX)
typedef uint_least16_t yytype_uint16;
#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
typedef unsigned short yytype_uint16;
#else
typedef int yytype_uint16;
#endif
#ifndef YYPTRDIFF_T
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
# define YYPTRDIFF_T __PTRDIFF_TYPE__
# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
# elif defined PTRDIFF_MAX
# ifndef ptrdiff_t
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# endif
# define YYPTRDIFF_T ptrdiff_t
# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
# else
# define YYPTRDIFF_T long
# define YYPTRDIFF_MAXIMUM LONG_MAX
# endif
#endif
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned
# endif
#endif
#define YYSIZE_MAXIMUM \
YY_CAST (YYPTRDIFF_T, \
(YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
? YYPTRDIFF_MAXIMUM \
: YY_CAST (YYSIZE_T, -1)))
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
/* Stored state numbers (used for stacks). */
typedef yytype_uint8 yy_state_t;
/* State numbers in computations. */
typedef int yy_state_fast_t;
#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(Msgid) Msgid
# endif
#endif
#ifndef YY_ATTRIBUTE_PURE
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
# else
# define YY_ATTRIBUTE_PURE
# endif
#endif
#ifndef YY_ATTRIBUTE_UNUSED
# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
# else
# define YY_ATTRIBUTE_UNUSED
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic pu.h") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
# define YY_IGNORE_USELESS_CAST_BEGIN \
_Pragma ("GCC diagnostic pu.h") \
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
# define YY_IGNORE_USELESS_CAST_END \
_Pragma ("GCC diagnostic pop")
#endif
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_END
#endif
#define YY_ASSERT(E) ((void) (0 && (E)))
#if !defined yyoverflow
/* The parser invokes alloca or malloc; define the necessary symbols. */
# ifdef YYSTACK_USE_ALLOCA
# if YYSTACK_USE_ALLOCA
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# elif defined __BUILTIN_VA_ARG_INCR
# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
# elif defined _AIX
# define YYSTACK_ALLOC __alloca
# elif defined _MSC_VER
# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
/* Pacify GCC's 'empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# ifndef YYSTACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
to allow for a few compiler-allocated temporary stack slots. */
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
# endif
# else
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# endif
#endif /* !defined yyoverflow */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
{
yy_state_t yyss_alloc;
YYSTYPE yyvs_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define YYSTACK_BYTES(N) \
((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
+ YYSTACK_GAP_MAXIMUM)
# define YYCOPY_NEEDED 1
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYPTRDIFF_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / YYSIZEOF (*yyptr); \
} \
while (0)
#endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from SRC to DST. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(Dst, Src, Count) \
__builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
# else
# define YYCOPY(Dst, Src, Count) \
do \
{ \
YYPTRDIFF_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(Dst)[yyi] = (Src)[yyi]; \
} \
while (0)
# endif
# endif
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 15
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 251
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 49
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 29
/* YYNRULES -- Number of rules. */
#define YYNRULES 89
/* YYNSTATES -- Number of states. */
#define YYNSTATES 165
/* YYMAXUTOK -- Last valid token kind. */
#define YYMAXUTOK 303
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, with out-of-bounds checking. */
#define YYTRANSLATE(YYX) \
(0 <= (YYX) && (YYX) <= YYMAXUTOK \
? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
: YYSYMBOL_YYUNDEF)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex. */
static const yytype_int8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48
};
#if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_int16 yyrline[] =
{
0, 210, 210, 212, 213, 215, 216, 218, 220, 222,
223, 224, 226, 227, 229, 231, 232, 234, 235, 237,
239, 240, 242, 243, 244, 245, 246, 247, 248, 249,
250, 251, 252, 253, 254, 255, 256, 257, 259, 260,
262, 263, 265, 266, 267, 268, 269, 270, 276, 277,
278, 279, 280, 281, 282, 283, 284, 285, 286, 287,
288, 290, 291, 292, 293, 295, 296, 298, 299, 301,
302, 304, 305, 307, 308, 310, 311, 312, 314, 315,
317, 318, 319, 321, 322, 323, 324, 325, 326, 328
};
#endif
/** Accessing symbol of state STATE. */
#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
#if YYDEBUG || 0
/* The user-facing name of the symbol whose (internal) number is
YYSYMBOL. No bounds checking. */
static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
"\"end of file\"", "error", "\"invalid token\"", "_ERROR_", "_SYMB_0",
"_SYMB_1", "_SYMB_2", "_SYMB_3", "_SYMB_4", "_SYMB_5", "_SYMB_6",
"_SYMB_7", "_SYMB_8", "_SYMB_9", "_SYMB_10", "_SYMB_11", "_SYMB_12",
"_SYMB_13", "_SYMB_14", "_SYMB_15", "_SYMB_16", "_SYMB_17", "_SYMB_18",
"_SYMB_19", "_SYMB_20", "_SYMB_21", "_SYMB_22", "_SYMB_23", "_SYMB_24",
"_SYMB_25", "_SYMB_26", "_SYMB_27", "_SYMB_28", "_SYMB_29", "_SYMB_30",
"_SYMB_31", "_SYMB_32", "_SYMB_33", "_SYMB_34", "_SYMB_35", "_SYMB_36",
"_SYMB_37", "_SYMB_38", "_SYMB_39", "_SYMB_40", "_SYMB_41", "_SYMB_42",
"_STRING_", "_INTEGER_", "$accept", "Program", "TopDef", "ListTopDef",
"FunDef", "Arg", "ListArg", "ClassDef", "ClassBlock", "ClassBlockDef",
"ListClassBlockDef", "Block", "ListStmt", "Stmt", "Item", "ListItem",
"Type", "Expr6", "Expr5", "Expr4", "Expr3", "Expr2", "Expr1", "Expr",
"ListExpr", "AddOp", "MulOp", "RelOp", "PIdent", YY_NULLPTR
};
static const char *
yysymbol_name (yysymbol_kind_t yysymbol)
{
return yytname[yysymbol];
}
#endif
#ifdef YYPRINT
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
(internal) symbol number NUM (which must be that of a token). */
static const yytype_int16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
295, 296, 297, 298, 299, 300, 301, 302, 303
};
#endif
#define YYPACT_NINF (-89)
#define yypact_value_is_default(Yyn) \
((Yyn) == YYPACT_NINF)
#define YYTABLE_NINF (-48)
#define yytable_value_is_error(Yyn) \
0
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
static const yytype_int16 yypact[] =
{
124, -89, -35, -89, -89, -89, -89, 17, 124, -89,
-89, -89, -8, -89, -3, -89, -89, 10, 35, -89,
-35, -89, -89, 76, 81, 20, 44, 77, -8, -89,
-89, -89, -8, -89, 76, 74, -89, 79, 82, 3,
-89, -89, -89, -35, -89, 203, 93, -89, 80, 203,
40, 40, -89, 76, -89, -89, -89, -89, 83, -89,
54, 4, 189, 72, -89, 41, -89, -89, 91, 92,
156, 94, -89, -89, -8, 38, 5, 99, 57, 203,
83, 83, 95, 102, -35, -89, -89, -89, 203, -89,
-89, 203, 203, -89, -89, -89, -89, -89, -89, 203,
203, 203, 203, 76, 203, -89, 106, 203, 107, -89,
203, 203, 108, 112, -89, 203, 188, 140, -89, 54,
-89, 4, -89, 143, 142, 134, -8, 146, -89, 147,
-89, 144, 151, -89, -89, -89, 152, 203, 203, -89,
-89, 139, 141, 141, -89, 23, -89, 162, -89, 203,
136, -89, 203, 166, 181, -89, 192, 141, 184, -89,
-89, 141, -89, -89, -89
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
Performed when YYTABLE does not specify something else to do. Zero
means the default is an error. */
static const yytype_int8 yydefact[] =
{
0, 44, 0, 42, 43, 45, 89, 0, 5, 2,
3, 4, 0, 47, 0, 1, 6, 0, 0, 17,
0, 12, 46, 9, 0, 0, 10, 0, 0, 14,
15, 18, 0, 13, 9, 0, 8, 40, 0, 38,
11, 20, 7, 0, 16, 0, 0, 41, 38, 0,
0, 0, 51, 0, 58, 50, 53, 49, 64, 66,
68, 70, 72, 74, 39, 48, 19, 22, 0, 0,
0, 0, 23, 21, 0, 0, 48, 0, 48, 0,
62, 63, 0, 55, 0, 80, 81, 82, 0, 79,
78, 0, 0, 83, 84, 85, 86, 87, 88, 0,
0, 75, 0, 0, 0, 32, 0, 0, 0, 36,
0, 0, 0, 0, 60, 0, 0, 56, 65, 67,
71, 69, 73, 76, 0, 0, 0, 0, 31, 0,
24, 0, 0, 29, 30, 61, 0, 75, 75, 52,
59, 0, 0, 0, 25, 59, 54, 0, 77, 0,
33, 35, 0, 0, 0, 57, 0, 0, 0, 27,
28, 0, 34, 26, 37
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int16 yypgoto[] =
{
-89, -89, -89, 163, 170, -89, 164, -89, 176, -89,
-89, 174, -89, -88, -89, -33, 6, 14, -73, 119,
113, -89, 121, -44, -67, -89, -89, -89, 0
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
-1, 7, 8, 9, 10, 26, 27, 11, 21, 31,
24, 72, 46, 73, 37, 38, 74, 58, 59, 60,
61, 62, 63, 75, 124, 91, 88, 99, 65
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule whose
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_int16 yytable[] =
{
13, 64, 14, 17, 19, 77, 12, 23, 13, 101,
47, 6, 18, 45, 12, 118, 111, 15, 112, 113,
25, 89, 22, 13, 13, 90, 106, 19, 36, 28,
32, 20, 39, 152, 13, 77, 153, 154, 6, 23,
28, 108, 135, 48, 79, 101, 76, 109, 110, 78,
34, -47, 102, 83, 150, 151, 122, 123, 125, 82,
127, 101, 115, 129, 80, 81, 131, 132, 102, 162,
147, 148, 136, 164, 48, 52, 85, 86, 87, 53,
54, 41, 35, 55, 117, 43, 6, 56, 57, 29,
45, 44, 100, 123, 123, 103, 104, 49, 107, 84,
41, 66, 67, 13, 114, 156, 116, 1, 158, 126,
50, 51, 1, -47, 3, 128, 130, 133, 4, 3,
5, 134, 6, 4, 1, 5, 141, 6, 52, 68,
69, 3, 53, 54, 70, 4, 55, 5, 71, 6,
56, 57, 76, 76, 137, 49, 140, 139, 41, 138,
67, 142, 143, 144, 149, 1, 2, 76, 50, 51,
49, 76, 3, 145, 146, 105, 4, 155, 5, 157,
6, 16, 1, 50, 51, 159, 52, 68, 69, 3,
53, 54, 70, 4, 55, 5, 71, 6, 56, 57,
160, 52, 49, 163, 30, 53, 54, 161, 40, 55,
22, 33, 6, 56, 57, 50, 51, 49, 92, 42,
119, 0, 121, 120, 93, 94, 95, 96, 97, 98,
50, 51, 0, 52, 0, 0, 0, 53, 54, 0,
0, 55, 0, 0, 6, 56, 57, 0, 52, 0,
0, 0, 53, 54, 0, 0, 55, 0, 0, 6,
56, 57
};
static const yytype_int16 yycheck[] =
{
0, 45, 2, 11, 7, 49, 0, 4, 8, 4,
43, 46, 12, 10, 8, 88, 11, 0, 13, 14,
20, 17, 12, 23, 24, 21, 70, 7, 28, 23,
24, 34, 32, 10, 34, 79, 13, 14, 46, 4,
34, 74, 115, 43, 4, 4, 46, 9, 10, 49,
6, 46, 11, 53, 142, 143, 100, 101, 102, 53,
104, 4, 5, 107, 50, 51, 110, 111, 11, 157,
137, 138, 116, 161, 74, 35, 22, 23, 24, 39,
40, 7, 5, 43, 84, 6, 46, 47, 48, 8,
10, 9, 20, 137, 138, 4, 4, 4, 4, 16,
7, 8, 9, 103, 5, 149, 11, 31, 152, 103,
17, 18, 31, 11, 38, 9, 9, 9, 42, 38,
44, 9, 46, 42, 31, 44, 126, 46, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
47, 48, 142, 143, 4, 4, 12, 5, 7, 6,
9, 5, 5, 9, 15, 31, 32, 157, 17, 18,
4, 161, 38, 12, 12, 9, 42, 5, 44, 33,
46, 8, 31, 17, 18, 9, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
9, 35, 4, 9, 24, 39, 40, 5, 34, 43,
12, 25, 46, 47, 48, 17, 18, 4, 19, 35,
91, -1, 99, 92, 25, 26, 27, 28, 29, 30,
17, 18, -1, 35, -1, -1, -1, 39, 40, -1,
-1, 43, -1, -1, 46, 47, 48, -1, 35, -1,
-1, -1, 39, 40, -1, -1, 43, -1, -1, 46,
47, 48
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_int8 yystos[] =
{
0, 31, 32, 38, 42, 44, 46, 50, 51, 52,
53, 56, 65, 77, 77, 0, 52, 11, 77, 7,
34, 57, 12, 4, 59, 77, 54, 55, 65, 8,
53, 58, 65, 57, 6, 5, 77, 63, 64, 77,
55, 7, 60, 6, 9, 10, 61, 64, 77, 4,
17, 18, 35, 39, 40, 43, 47, 48, 66, 67,
68, 69, 70, 71, 72, 77, 8, 9, 36, 37,
41, 45, 60, 62, 65, 72, 77, 72, 77, 4,
66, 66, 65, 77, 16, 22, 23, 24, 75, 17,
21, 74, 19, 25, 26, 27, 28, 29, 30, 76,
20, 4, 11, 4, 4, 9, 72, 4, 64, 9,
10, 11, 13, 14, 5, 5, 11, 77, 67, 68,
71, 69, 72, 72, 73, 72, 65, 72, 9, 72,
9, 72, 72, 9, 9, 67, 72, 4, 6, 5,
12, 77, 5, 5, 9, 12, 12, 73, 73, 15,
62, 62, 10, 13, 14, 5, 72, 33, 72, 9,
9, 5, 62, 9, 62
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_int8 yyr1[] =
{
0, 49, 50, 51, 51, 52, 52, 53, 54, 55,
55, 55, 56, 56, 57, 58, 58, 59, 59, 60,
61, 61, 62, 62, 62, 62, 62, 62, 62, 62,
62, 62, 62, 62, 62, 62, 62, 62, 63, 63,
64, 64, 65, 65, 65, 65, 65, 65, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 67, 67, 67, 67, 68, 68, 69, 69, 70,
70, 71, 71, 72, 72, 73, 73, 73, 74, 74,
75, 75, 75, 76, 76, 76, 76, 76, 76, 77
};
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
static const yytype_int8 yyr2[] =
{
0, 2, 1, 1, 1, 1, 2, 6, 2, 0,
1, 3, 3, 5, 3, 1, 3, 0, 2, 3,
0, 2, 1, 1, 3, 4, 7, 6, 6, 3,
3, 3, 2, 5, 7, 5, 2, 8, 1, 3,
1, 3, 1, 1, 1, 1, 3, 1, 1, 1,
1, 1, 4, 1, 5, 2, 3, 6, 1, 4,
3, 4, 2, 2, 1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 0, 1, 3, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1
};
enum { YYENOMEM = -2 };
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (yylen); \
yystate = *yyssp; \
goto yybackup; \
} \
else \
{ \
yyerror (YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (0)
/* Backward compatibility with an undocumented macro.
Use YYerror or YYUNDEF. */
#define YYERRCODE YYUNDEF
/* Enable debugging if requested. */
#if YYDEBUG
# ifndef YYFPRINTF
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
# define YYFPRINTF fprintf
# endif
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
} while (0)
/* This macro is provided for backward compatibility. */
# ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Kind, Value); \
YYFPRINTF (stderr, "\n"); \
} \
} while (0)
/*-----------------------------------.
| Print this symbol's value on YYO. |
`-----------------------------------*/
static void
yy_symbol_value_print (FILE *yyo,
yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
{
FILE *yyoutput = yyo;
YYUSE (yyoutput);
if (!yyvaluep)
return;
# ifdef YYPRINT
if (yykind < YYNTOKENS)
YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
# endif
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YYUSE (yykind);
YY_IGNORE_MAYBE_UNINITIALIZED_END
}
/*---------------------------.
| Print this symbol on YYO. |
`---------------------------*/
static void
yy_symbol_print (FILE *yyo,
yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
{
YYFPRINTF (yyo, "%s %s (",
yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
yy_symbol_value_print (yyo, yykind, yyvaluep);
YYFPRINTF (yyo, ")");
}
/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included). |
`------------------------------------------------------------------*/
static void
yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
{
int yybot = *yybottom;
YYFPRINTF (stderr, " %d", yybot);
}
YYFPRINTF (stderr, "\n");
}
# define YY_STACK_PRINT(Bottom, Top) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
} while (0)
/*------------------------------------------------.
| Report that the YYRULE is going to be reduced. |
`------------------------------------------------*/
static void
yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
int yyrule)
{
int yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
yyrule - 1, yylno);
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
&yyvsp[(yyi + 1) - (yynrhs)]);
YYFPRINTF (stderr, "\n");
}
}
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
yy_reduce_print (yyssp, yyvsp, Rule); \
} while (0)
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args) ((void) 0)
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
if the built-in stack extension method is used).
Do not make this value too large; the results are undefined if
YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
static void
yydestruct (const char *yymsg,
yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
{
YYUSE (yyvaluep);
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YYUSE (yykind);
YY_IGNORE_MAYBE_UNINITIALIZED_END
}
/* Lookahead token kind. */
int yychar;
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
/* Number of syntax errors so far. */
int yynerrs;
/*----------.
| yyparse. |
`----------*/
int
yyparse (void)
{
yy_state_fast_t yystate = 0;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus = 0;
/* Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* Their size. */
YYPTRDIFF_T yystacksize = YYINITDEPTH;
/* The state stack: array, bottom, top. */
yy_state_t yyssa[YYINITDEPTH];
yy_state_t *yyss = yyssa;
yy_state_t *yyssp = yyss;
/* The semantic value stack: array, bottom, top. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs = yyvsa;
YYSTYPE *yyvsp = yyvs;
int yyn;
/* The return value of yyparse. */
int yyresult;
/* Lookahead symbol kind. */
yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
YYDPRINTF ((stderr, "Starting parse\n"));
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- push a new state, which is found in yystate. |
`------------------------------------------------------------*/
yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
/*--------------------------------------------------------------------.
| yysetstate -- set current state (the top of the stack) to yystate. |
`--------------------------------------------------------------------*/
yysetstate:
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
YY_IGNORE_USELESS_CAST_BEGIN
*yyssp = YY_CAST (yy_state_t, yystate);
YY_IGNORE_USELESS_CAST_END
YY_STACK_PRINT (yyss, yyssp);
if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
goto yyexhaustedlab;
#else
{
/* Get the current used size of the three stacks, in elements. */
YYPTRDIFF_T yysize = yyssp - yyss + 1;
# if defined yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
yy_state_t *yyss1 = yyss;
YYSTYPE *yyvs1 = yyvs;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * YYSIZEOF (*yyssp),
&yyvs1, yysize * YYSIZEOF (*yyvsp),
&yystacksize);
yyss = yyss1;
yyvs = yyvs1;
}
# else /* defined YYSTACK_RELOCATE */
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
{
yy_state_t *yyss1 = yyss;
union yyalloc *yyptr =
YY_CAST (union yyalloc *,
YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YY_IGNORE_USELESS_CAST_BEGIN
YYDPRINTF ((stderr, "Stack size increased to %ld\n",
YY_CAST (long, yystacksize)));
YY_IGNORE_USELESS_CAST_END
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
if (yystate == YYFINAL)
YYACCEPT;
goto yybackup;
/*-----------.
| yybackup. |
`-----------*/
yybackup:
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yypact_value_is_default (yyn))
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token\n"));
yychar = yylex ();
}
if (yychar <= YYEOF)
{
yychar = YYEOF;
yytoken = YYSYMBOL_YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else if (yychar == YYerror)
{
/* The scanner already issued an error message, process directly
to error recovery. But do not keep the error token as
lookahead, it is too special and may lead us to an endless
loop in error recovery. */
yychar = YYUNDEF;
yytoken = YYSYMBOL_YYerror;
goto yyerrlab1;
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
yyn += yytoken;
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
{
if (yytable_value_is_error (yyn))
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Discard the shifted token. */
yychar = YYEMPTY;
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
'$$ = $1'.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 2: /* Program: ListTopDef */
#line 210 "Grammar.y"
{ std::reverse((yyvsp[0].listtopdef_)->begin(),(yyvsp[0].listtopdef_)->end()) ;(yyval.program_) = new Prog((yyvsp[0].listtopdef_)); YY_RESULT_Program_= (yyval.program_); }
#line 1474 "Parser.cpp"
break;
case 3: /* TopDef: FunDef */
#line 212 "Grammar.y"
{ (yyval.topdef_) = new FnDef((yyvsp[0].fundef_)); }
#line 1480 "Parser.cpp"
break;
case 4: /* TopDef: ClassDef */
#line 213 "Grammar.y"
{ (yyval.topdef_) = new ClDef((yyvsp[0].classdef_)); }
#line 1486 "Parser.cpp"
break;
case 5: /* ListTopDef: TopDef */
#line 215 "Grammar.y"
{ (yyval.listtopdef_) = new ListTopDef() ; (yyval.listtopdef_)->push_back((yyvsp[0].topdef_)); }
#line 1492 "Parser.cpp"
break;
case 6: /* ListTopDef: TopDef ListTopDef */
#line 216 "Grammar.y"
{ (yyvsp[0].listtopdef_)->push_back((yyvsp[-1].topdef_)) ; (yyval.listtopdef_) = (yyvsp[0].listtopdef_) ; }
#line 1498 "Parser.cpp"
break;
case 7: /* FunDef: Type PIdent _SYMB_0 ListArg _SYMB_1 Block */
#line 218 "Grammar.y"
{ std::reverse((yyvsp[-2].listarg_)->begin(),(yyvsp[-2].listarg_)->end()) ;(yyval.fundef_) = new FuncDef((yyvsp[-5].type_), (yyvsp[-4].pident_), (yyvsp[-2].listarg_), (yyvsp[0].block_)); }
#line 1504 "Parser.cpp"
break;
case 8: /* Arg: Type PIdent */
#line 220 "Grammar.y"
{ (yyval.arg_) = new Ar((yyvsp[-1].type_), (yyvsp[0].pident_)); }
#line 1510 "Parser.cpp"
break;
case 9: /* ListArg: %empty */
#line 222 "Grammar.y"
{ (yyval.listarg_) = new ListArg(); }
#line 1516 "Parser.cpp"
break;
case 10: /* ListArg: Arg */
#line 223 "Grammar.y"
{ (yyval.listarg_) = new ListArg() ; (yyval.listarg_)->push_back((yyvsp[0].arg_)); }
#line 1522 "Parser.cpp"
break;
case 11: /* ListArg: Arg _SYMB_2 ListArg */
#line 224 "Grammar.y"
{ (yyvsp[0].listarg_)->push_back((yyvsp[-2].arg_)) ; (yyval.listarg_) = (yyvsp[0].listarg_) ; }
#line 1528 "Parser.cpp"
break;
case 12: /* ClassDef: _SYMB_28 PIdent ClassBlock */
#line 226 "Grammar.y"
{ (yyval.classdef_) = new ClassDefN((yyvsp[-1].pident_), (yyvsp[0].classblock_)); }
#line 1534 "Parser.cpp"
break;
case 13: /* ClassDef: _SYMB_28 PIdent _SYMB_30 PIdent ClassBlock */
#line 227 "Grammar.y"
{ (yyval.classdef_) = new ClassDefE((yyvsp[-3].pident_), (yyvsp[-1].pident_), (yyvsp[0].classblock_)); }
#line 1540 "Parser.cpp"
break;
case 14: /* ClassBlock: _SYMB_3 ListClassBlockDef _SYMB_4 */
#line 229 "Grammar.y"
{ (yyval.classblock_) = new ClassBl((yyvsp[-1].listclassblockdef_)); }
#line 1546 "Parser.cpp"
break;
case 15: /* ClassBlockDef: FunDef */
#line 231 "Grammar.y"
{ (yyval.classblockdef_) = new ClassMthd((yyvsp[0].fundef_)); }
#line 1552 "Parser.cpp"
break;
case 16: /* ClassBlockDef: Type ListItem _SYMB_5 */
#line 232 "Grammar.y"
{ std::reverse((yyvsp[-1].listitem_)->begin(),(yyvsp[-1].listitem_)->end()) ;(yyval.classblockdef_) = new ClassFld((yyvsp[-2].type_), (yyvsp[-1].listitem_)); }
#line 1558 "Parser.cpp"
break;
case 17: /* ListClassBlockDef: %empty */
#line 234 "Grammar.y"
{ (yyval.listclassblockdef_) = new ListClassBlockDef(); }
#line 1564 "Parser.cpp"
break;
case 18: /* ListClassBlockDef: ListClassBlockDef ClassBlockDef */
#line 235 "Grammar.y"
{ (yyvsp[-1].listclassblockdef_)->push_back((yyvsp[0].classblockdef_)) ; (yyval.listclassblockdef_) = (yyvsp[-1].listclassblockdef_) ; }
#line 1570 "Parser.cpp"
break;
case 19: /* Block: _SYMB_3 ListStmt _SYMB_4 */
#line 237 "Grammar.y"
{ (yyval.block_) = new Blk((yyvsp[-1].liststmt_)); }
#line 1576 "Parser.cpp"
break;
case 20: /* ListStmt: %empty */
#line 239 "Grammar.y"
{ (yyval.liststmt_) = new ListStmt(); }
#line 1582 "Parser.cpp"
break;
case 21: /* ListStmt: ListStmt Stmt */
#line 240 "Grammar.y"
{ (yyvsp[-1].liststmt_)->push_back((yyvsp[0].stmt_)) ; (yyval.liststmt_) = (yyvsp[-1].liststmt_) ; }
#line 1588 "Parser.cpp"
break;
case 22: /* Stmt: _SYMB_5 */
#line 242 "Grammar.y"
{ (yyval.stmt_) = new Empty(); }
#line 1594 "Parser.cpp"
break;
case 23: /* Stmt: Block */
#line 243 "Grammar.y"
{ (yyval.stmt_) = new BStmt((yyvsp[0].block_)); }
#line 1600 "Parser.cpp"
break;
case 24: /* Stmt: Type ListItem _SYMB_5 */
#line 244 "Grammar.y"
{ std::reverse((yyvsp[-1].listitem_)->begin(),(yyvsp[-1].listitem_)->end()) ;(yyval.stmt_) = new Decl((yyvsp[-2].type_), (yyvsp[-1].listitem_)); }
#line 1606 "Parser.cpp"
break;
case 25: /* Stmt: Expr _SYMB_6 Expr _SYMB_5 */
#line 245 "Grammar.y"
{ (yyval.stmt_) = new Ass((yyvsp[-3].expr_), (yyvsp[-1].expr_)); }
#line 1612 "Parser.cpp"
break;
case 26: /* Stmt: PIdent _SYMB_7 Expr _SYMB_8 _SYMB_6 Expr _SYMB_5 */
#line 246 "Grammar.y"
{ (yyval.stmt_) = new TableAss((yyvsp[-6].pident_), (yyvsp[-4].expr_), (yyvsp[-1].expr_)); }
#line 1618 "Parser.cpp"
break;
case 27: /* Stmt: PIdent _SYMB_7 Expr _SYMB_8 _SYMB_9 _SYMB_5 */
#line 247 "Grammar.y"
{ (yyval.stmt_) = new TableIncr((yyvsp[-5].pident_), (yyvsp[-3].expr_)); }
#line 1624 "Parser.cpp"
break;
case 28: /* Stmt: PIdent _SYMB_7 Expr _SYMB_8 _SYMB_10 _SYMB_5 */
#line 248 "Grammar.y"
{ (yyval.stmt_) = new TableDecr((yyvsp[-5].pident_), (yyvsp[-3].expr_)); }
#line 1630 "Parser.cpp"
break;
case 29: /* Stmt: PIdent _SYMB_9 _SYMB_5 */
#line 249 "Grammar.y"
{ (yyval.stmt_) = new Incr((yyvsp[-2].pident_)); }
#line 1636 "Parser.cpp"
break;
case 30: /* Stmt: PIdent _SYMB_10 _SYMB_5 */
#line 250 "Grammar.y"
{ (yyval.stmt_) = new Decr((yyvsp[-2].pident_)); }
#line 1642 "Parser.cpp"
break;
case 31: /* Stmt: _SYMB_37 Expr _SYMB_5 */
#line 251 "Grammar.y"
{ (yyval.stmt_) = new Ret((yyvsp[-1].expr_)); }
#line 1648 "Parser.cpp"
break;
case 32: /* Stmt: _SYMB_37 _SYMB_5 */
#line 252 "Grammar.y"
{ (yyval.stmt_) = new VRet(); }
#line 1654 "Parser.cpp"
break;
case 33: /* Stmt: _SYMB_33 _SYMB_0 Expr _SYMB_1 Stmt */
#line 253 "Grammar.y"
{ (yyval.stmt_) = new Cond((yyvsp[-2].expr_), (yyvsp[0].stmt_)); }
#line 1660 "Parser.cpp"
break;
case 34: /* Stmt: _SYMB_33 _SYMB_0 Expr _SYMB_1 Stmt _SYMB_29 Stmt */
#line 254 "Grammar.y"
{ (yyval.stmt_) = new CondElse((yyvsp[-4].expr_), (yyvsp[-2].stmt_), (yyvsp[0].stmt_)); }
#line 1666 "Parser.cpp"
break;
case 35: /* Stmt: _SYMB_41 _SYMB_0 Expr _SYMB_1 Stmt */
#line 255 "Grammar.y"
{ (yyval.stmt_) = new While((yyvsp[-2].expr_), (yyvsp[0].stmt_)); }
#line 1672 "Parser.cpp"
break;
case 36: /* Stmt: Expr _SYMB_5 */
#line 256 "Grammar.y"
{ (yyval.stmt_) = new SExp((yyvsp[-1].expr_)); }
#line 1678 "Parser.cpp"
break;
case 37: /* Stmt: _SYMB_32 _SYMB_0 Type PIdent _SYMB_11 Expr _SYMB_1 Stmt */
#line 257 "Grammar.y"
{ (yyval.stmt_) = new ForEach((yyvsp[-5].type_), (yyvsp[-4].pident_), (yyvsp[-2].expr_), (yyvsp[0].stmt_)); }
#line 1684 "Parser.cpp"
break;
case 38: /* Item: PIdent */
#line 259 "Grammar.y"
{ (yyval.item_) = new NoInit((yyvsp[0].pident_)); }
#line 1690 "Parser.cpp"
break;
case 39: /* Item: PIdent _SYMB_6 Expr */
#line 260 "Grammar.y"
{ (yyval.item_) = new Init((yyvsp[-2].pident_), (yyvsp[0].expr_)); }
#line 1696 "Parser.cpp"
break;
case 40: /* ListItem: Item */
#line 262 "Grammar.y"
{ (yyval.listitem_) = new ListItem() ; (yyval.listitem_)->push_back((yyvsp[0].item_)); }
#line 1702 "Parser.cpp"
break;
case 41: /* ListItem: Item _SYMB_2 ListItem */
#line 263 "Grammar.y"
{ (yyvsp[0].listitem_)->push_back((yyvsp[-2].item_)) ; (yyval.listitem_) = (yyvsp[0].listitem_) ; }
#line 1708 "Parser.cpp"
break;
case 42: /* Type: _SYMB_34 */
#line 265 "Grammar.y"
{ (yyval.type_) = new Int(); }
#line 1714 "Parser.cpp"
break;
case 43: /* Type: _SYMB_38 */
#line 266 "Grammar.y"
{ (yyval.type_) = new Str(); }
#line 1720 "Parser.cpp"
break;
case 44: /* Type: _SYMB_27 */
#line 267 "Grammar.y"
{ (yyval.type_) = new Bool(); }
#line 1726 "Parser.cpp"
break;
case 45: /* Type: _SYMB_40 */
#line 268 "Grammar.y"
{ (yyval.type_) = new Void(); }
#line 1732 "Parser.cpp"
break;
case 46: /* Type: Type _SYMB_7 _SYMB_8 */
#line 269 "Grammar.y"
{ (yyval.type_) = new Array((yyvsp[-2].type_)); }
#line 1738 "Parser.cpp"
break;
case 47: /* Type: PIdent */
#line 270 "Grammar.y"
{ (yyval.type_) = new ClassT((yyvsp[0].pident_)); }
#line 1744 "Parser.cpp"
break;
case 48: /* Expr6: PIdent */
#line 276 "Grammar.y"
{ (yyval.expr_) = new EVar((yyvsp[0].pident_)); }
#line 1750 "Parser.cpp"
break;
case 49: /* Expr6: _INTEGER_ */
#line 277 "Grammar.y"
{ (yyval.expr_) = new ELitInt((yyvsp[0].int_)); }
#line 1756 "Parser.cpp"
break;
case 50: /* Expr6: _SYMB_39 */
#line 278 "Grammar.y"
{ (yyval.expr_) = new ELitTrue(); }
#line 1762 "Parser.cpp"
break;
case 51: /* Expr6: _SYMB_31 */
#line 279 "Grammar.y"
{ (yyval.expr_) = new ELitFalse(); }
#line 1768 "Parser.cpp"
break;
case 52: /* Expr6: PIdent _SYMB_0 ListExpr _SYMB_1 */
#line 280 "Grammar.y"
{ std::reverse((yyvsp[-1].listexpr_)->begin(),(yyvsp[-1].listexpr_)->end()) ;(yyval.expr_) = new EApp((yyvsp[-3].pident_), (yyvsp[-1].listexpr_)); }
#line 1774 "Parser.cpp"
break;
case 53: /* Expr6: _STRING_ */
#line 281 "Grammar.y"
{ (yyval.expr_) = new EString((yyvsp[0].string_)); }
#line 1780 "Parser.cpp"
break;
case 54: /* Expr6: _SYMB_35 Type _SYMB_7 Expr _SYMB_8 */
#line 282 "Grammar.y"
{ (yyval.expr_) = new ENewArray((yyvsp[-3].type_), (yyvsp[-1].expr_)); }
#line 1786 "Parser.cpp"
break;
case 55: /* Expr6: _SYMB_35 PIdent */
#line 283 "Grammar.y"
{ (yyval.expr_) = new ENewClass((yyvsp[0].pident_)); }
#line 1792 "Parser.cpp"
break;
case 56: /* Expr6: Expr6 _SYMB_12 PIdent */
#line 284 "Grammar.y"
{ (yyval.expr_) = new EClsMmbr((yyvsp[-2].expr_), (yyvsp[0].pident_)); }
#line 1798 "Parser.cpp"
break;
case 57: /* Expr6: Expr6 _SYMB_12 PIdent _SYMB_0 ListExpr _SYMB_1 */
#line 285 "Grammar.y"
{ std::reverse((yyvsp[-1].listexpr_)->begin(),(yyvsp[-1].listexpr_)->end()) ;(yyval.expr_) = new EClsMthd((yyvsp[-5].expr_), (yyvsp[-3].pident_), (yyvsp[-1].listexpr_)); }
#line 1804 "Parser.cpp"
break;
case 58: /* Expr6: _SYMB_36 */
#line 286 "Grammar.y"
{ (yyval.expr_) = new Null(); }
#line 1810 "Parser.cpp"
break;
case 59: /* Expr6: PIdent _SYMB_7 Expr _SYMB_8 */
#line 287 "Grammar.y"
{ (yyval.expr_) = new EIndexAcc((yyvsp[-3].pident_), (yyvsp[-1].expr_)); }
#line 1816 "Parser.cpp"
break;
case 60: /* Expr6: _SYMB_0 Expr _SYMB_1 */
#line 288 "Grammar.y"
{ (yyval.expr_) = (yyvsp[-1].expr_); }
#line 1822 "Parser.cpp"
break;
case 61: /* Expr5: _SYMB_0 PIdent _SYMB_1 Expr5 */
#line 290 "Grammar.y"
{ (yyval.expr_) = new ECast((yyvsp[-2].pident_), (yyvsp[0].expr_)); }
#line 1828 "Parser.cpp"
break;
case 62: /* Expr5: _SYMB_13 Expr6 */
#line 291 "Grammar.y"
{ (yyval.expr_) = new Neg((yyvsp[0].expr_)); }
#line 1834 "Parser.cpp"
break;
case 63: /* Expr5: _SYMB_14 Expr6 */
#line 292 "Grammar.y"
{ (yyval.expr_) = new Not((yyvsp[0].expr_)); }
#line 1840 "Parser.cpp"
break;
case 64: /* Expr5: Expr6 */
#line 293 "Grammar.y"
{ (yyval.expr_) = (yyvsp[0].expr_); }
#line 1846 "Parser.cpp"
break;
case 65: /* Expr4: Expr4 MulOp Expr5 */
#line 295 "Grammar.y"
{ (yyval.expr_) = new EMul((yyvsp[-2].expr_), (yyvsp[-1].mulop_), (yyvsp[0].expr_)); }
#line 1852 "Parser.cpp"
break;
case 66: /* Expr4: Expr5 */
#line 296 "Grammar.y"
{ (yyval.expr_) = (yyvsp[0].expr_); }
#line 1858 "Parser.cpp"
break;
case 67: /* Expr3: Expr3 AddOp Expr4 */
#line 298 "Grammar.y"
{ (yyval.expr_) = new EAdd((yyvsp[-2].expr_), (yyvsp[-1].addop_), (yyvsp[0].expr_)); }
#line 1864 "Parser.cpp"
break;
case 68: /* Expr3: Expr4 */
#line 299 "Grammar.y"
{ (yyval.expr_) = (yyvsp[0].expr_); }
#line 1870 "Parser.cpp"
break;
case 69: /* Expr2: Expr2 RelOp Expr3 */
#line 301 "Grammar.y"
{ (yyval.expr_) = new ERel((yyvsp[-2].expr_), (yyvsp[-1].relop_), (yyvsp[0].expr_)); }
#line 1876 "Parser.cpp"
break;
case 70: /* Expr2: Expr3 */
#line 302 "Grammar.y"
{ (yyval.expr_) = (yyvsp[0].expr_); }
#line 1882 "Parser.cpp"
break;
case 71: /* Expr1: Expr2 _SYMB_15 Expr1 */
#line 304 "Grammar.y"
{ (yyval.expr_) = new EAnd((yyvsp[-2].expr_), (yyvsp[0].expr_)); }
#line 1888 "Parser.cpp"
break;
case 72: /* Expr1: Expr2 */
#line 305 "Grammar.y"
{ (yyval.expr_) = (yyvsp[0].expr_); }
#line 1894 "Parser.cpp"
break;
case 73: /* Expr: Expr1 _SYMB_16 Expr */
#line 307 "Grammar.y"
{ (yyval.expr_) = new EOr((yyvsp[-2].expr_), (yyvsp[0].expr_)); }
#line 1900 "Parser.cpp"
break;
case 74: /* Expr: Expr1 */
#line 308 "Grammar.y"
{ (yyval.expr_) = (yyvsp[0].expr_); }
#line 1906 "Parser.cpp"
break;
case 75: /* ListExpr: %empty */
#line 310 "Grammar.y"
{ (yyval.listexpr_) = new ListExpr(); }
#line 1912 "Parser.cpp"
break;
case 76: /* ListExpr: Expr */
#line 311 "Grammar.y"
{ (yyval.listexpr_) = new ListExpr() ; (yyval.listexpr_)->push_back((yyvsp[0].expr_)); }
#line 1918 "Parser.cpp"
break;
case 77: /* ListExpr: Expr _SYMB_2 ListExpr */
#line 312 "Grammar.y"
{ (yyvsp[0].listexpr_)->push_back((yyvsp[-2].expr_)) ; (yyval.listexpr_) = (yyvsp[0].listexpr_) ; }
#line 1924 "Parser.cpp"
break;
case 78: /* AddOp: _SYMB_17 */
#line 314 "Grammar.y"
{ (yyval.addop_) = new Plus(); }
#line 1930 "Parser.cpp"
break;
case 79: /* AddOp: _SYMB_13 */
#line 315 "Grammar.y"
{ (yyval.addop_) = new Minus(); }
#line 1936 "Parser.cpp"
break;
case 80: /* MulOp: _SYMB_18 */
#line 317 "Grammar.y"
{ (yyval.mulop_) = new Times(); }
#line 1942 "Parser.cpp"
break;
case 81: /* MulOp: _SYMB_19 */
#line 318 "Grammar.y"
{ (yyval.mulop_) = new Div(); }
#line 1948 "Parser.cpp"
break;
case 82: /* MulOp: _SYMB_20 */
#line 319 "Grammar.y"
{ (yyval.mulop_) = new Mod(); }
#line 1954 "Parser.cpp"
break;
case 83: /* RelOp: _SYMB_21 */
#line 321 "Grammar.y"
{ (yyval.relop_) = new LTH(); }
#line 1960 "Parser.cpp"
break;
case 84: /* RelOp: _SYMB_22 */
#line 322 "Grammar.y"
{ (yyval.relop_) = new LE(); }
#line 1966 "Parser.cpp"
break;
case 85: /* RelOp: _SYMB_23 */
#line 323 "Grammar.y"
{ (yyval.relop_) = new GTH(); }
#line 1972 "Parser.cpp"
break;
case 86: /* RelOp: _SYMB_24 */
#line 324 "Grammar.y"
{ (yyval.relop_) = new GE(); }
#line 1978 "Parser.cpp"
break;
case 87: /* RelOp: _SYMB_25 */
#line 325 "Grammar.y"
{ (yyval.relop_) = new EQU(); }
#line 1984 "Parser.cpp"
break;
case 88: /* RelOp: _SYMB_26 */
#line 326 "Grammar.y"
{ (yyval.relop_) = new NE(); }
#line 1990 "Parser.cpp"
break;
case 89: /* PIdent: _SYMB_42 */
#line 328 "Grammar.y"
{ (yyval.pident_) = new PIdent((yyvsp[0].string_),yy_mylinenumber) ; YY_RESULT_PIdent_= (yyval.pident_) ; }
#line 1996 "Parser.cpp"
break;
#line 2000 "Parser.cpp"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
that yytoken be updated with the new translation. We take the
approach of translating immediately before every use of yytoken.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
YYPOPSTACK (yylen);
yylen = 0;
*++yyvsp = yyval;
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
{
const int yylhs = yyr1[yyn] - YYNTOKENS;
const int yyi = yypgoto[yylhs] + *yyssp;
yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
? yytable[yyi]
: yydefgoto[yylhs]);
}
goto yynewstate;
/*--------------------------------------.
| yyerrlab -- here on detecting error. |
`--------------------------------------*/
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
yyerror (YY_("syntax error"));
}
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval);
yychar = YYEMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
/* Pacify compilers when the user code never invokes YYERROR and the
label yyerrorlab therefore never appears in user code. */
if (0)
YYERROR;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
yystate = *yyssp;
goto yyerrlab1;
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
/* Pop stack until we find a state that shifts the error token. */
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
yyn += YYSYMBOL_YYerror;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
yydestruct ("Error: popping",
YY_ACCESSING_SYMBOL (yystate), yyvsp);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
#if !defined yyoverflow
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
yyexhaustedlab:
yyerror (YY_("memory exhausted"));
yyresult = 2;
goto yyreturn;
#endif
/*-------------------------------------------------------.
| yyreturn -- parsing is finished, clean up and return. |
`-------------------------------------------------------*/
yyreturn:
if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval);
}
/* Do not reclaim the symbols of the rule whose action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
return yyresult;
}
#ifndef PARSER_HEADER_FILE
#define PARSER_HEADER_FILE
#include<vector>
#include<string>
class Program;
class TopDef;
class ListTopDef;
class FunDef;
class Arg;
class ListArg;
class ClassDef;
class ClassBlock;
class ClassBlockDef;
class ListClassBlockDef;
class Block;
class ListStmt;
class Stmt;
class Item;
class ListItem;
class Type;
class ListType;
class Expr;
class ListExpr;
class AddOp;
class MulOp;
class RelOp;
typedef union
{
int int_;
char char_;
double double_;
char* string_;
Program* program_;
TopDef* topdef_;
ListTopDef* listtopdef_;
FunDef* fundef_;
Arg* arg_;
ListArg* listarg_;
ClassDef* classdef_;
ClassBlock* classblock_;
ClassBlockDef* classblockdef_;
ListClassBlockDef* listclassblockdef_;
Block* block_;
ListStmt* liststmt_;
Stmt* stmt_;
Item* item_;
ListItem* listitem_;
Type* type_;
ListType* listtype_;
Expr* expr_;
ListExpr* listexpr_;
AddOp* addop_;
MulOp* mulop_;
RelOp* relop_;
} YYSTYPE;
Program* pProgram(FILE *inp);
Program* pProgram(const char *str);
#define _ERROR_ 258
#define _SYMB_0 259
#define _SYMB_1 260
#define _SYMB_2 261
#define _SYMB_3 262
#define _SYMB_4 263
#define _SYMB_5 264
#define _SYMB_6 265
#define _SYMB_7 266
#define _SYMB_8 267
#define _SYMB_9 268
#define _SYMB_10 269
#define _SYMB_11 270
#define _SYMB_12 271
#define _SYMB_13 272
#define _SYMB_14 273
#define _SYMB_15 274
#define _SYMB_16 275
#define _SYMB_17 276
#define _SYMB_18 277
#define _SYMB_19 278
#define _SYMB_20 279
#define _SYMB_21 280
#define _SYMB_22 281
#define _SYMB_23 282
#define _SYMB_24 283
#define _SYMB_25 284
#define _SYMB_26 285
#define _SYMB_27 286
#define _SYMB_28 287
#define _SYMB_29 288
#define _SYMB_30 289
#define _SYMB_31 290
#define _SYMB_32 291
#define _SYMB_33 292
#define _SYMB_34 293
#define _SYMB_35 294
#define _SYMB_36 295
#define _SYMB_37 296
#define _SYMB_38 297
#define _SYMB_39 298
#define _SYMB_40 299
#define _SYMB_41 300
#define _SYMB_42 301
#define _STRING_ 302
#define _INTEGER_ 303
extern YYSTYPE yylval;
#endif
/*** BNFC-Generated Pretty Printer and Abstract Syntax Viewer ***/
#include <string>
#include "Printer.h"
#define INDENT_WIDTH 2
//You may wish to change render
void PrintAbsyn::render(Char c)
{
if (c == '{')
{
bufAppend('\n');
indent();
bufAppend(c);
_n_ = _n_ + INDENT_WIDTH;
bufAppend('\n');
indent();
}
else if (c == '(' || c == '[')
bufAppend(c);
else if (c == ')' || c == ']')
{
backup();
bufAppend(c);
}
else if (c == '}')
{
int t;
_n_ = _n_ - INDENT_WIDTH;
for (t=0; t<INDENT_WIDTH; t++) {
backup();
}
bufAppend(c);
bufAppend('\n');
indent();
}
else if (c == ',')
{
backup();
bufAppend(c);
bufAppend(' ');
}
else if (c == ';')
{
backup();
bufAppend(c);
bufAppend('\n');
indent();
}
else if (c == 0) return;
else
{
bufAppend(' ');
bufAppend(c);
bufAppend(' ');
}
}
void PrintAbsyn::render(String s_)
{
const char *s = s_.c_str() ;
if(strlen(s) > 0)
{
bufAppend(s);
bufAppend(' ');
}
}
void PrintAbsyn::render(const char *s)
{
if(strlen(s) > 0)
{
bufAppend(s);
bufAppend(' ');
}
}
void PrintAbsyn::indent()
{
int n = _n_;
while (n > 0)
{
bufAppend(' ');
n--;
}
}
void PrintAbsyn::backup()
{
if (buf_[cur_ - 1] == ' ')
{
buf_[cur_ - 1] = 0;
cur_--;
}
}
PrintAbsyn::PrintAbsyn(void)
{
_i_ = 0; _n_ = 0;
buf_ = 0;
bufReset();
}
PrintAbsyn::~PrintAbsyn(void)
{
}
char *PrintAbsyn::print(Visitable *v)
{
_i_ = 0; _n_ = 0;
bufReset();
v->accept(this);
return buf_;
}
void PrintAbsyn::visitPIdent(PIdent *p)
{
visitIdent(p->string_);
}
void PrintAbsyn::visitProgram(Program *p) {} //abstract class
void PrintAbsyn::visitProg(Prog *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
if(p->listtopdef_) {_i_ = 0; p->listtopdef_->accept(this);}
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitTopDef(TopDef *p) {} //abstract class
void PrintAbsyn::visitFnDef(FnDef *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->fundef_->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitClDef(ClDef *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->classdef_->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitListTopDef(ListTopDef *listtopdef)
{
for (ListTopDef::const_iterator i = listtopdef->begin() ; i != listtopdef->end() ; ++i)
{
(*i)->accept(this);
if (i != listtopdef->end() - 1) render("");
}
}void PrintAbsyn::visitFunDef(FunDef *p) {} //abstract class
void PrintAbsyn::visitFuncDef(FuncDef *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->type_->accept(this);
visitPIdent(p->pident_);
render('(');
if(p->listarg_) {_i_ = 0; p->listarg_->accept(this);}
render(')');
_i_ = 0; p->block_->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitArg(Arg *p) {} //abstract class
void PrintAbsyn::visitAr(Ar *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->type_->accept(this);
visitPIdent(p->pident_);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitListArg(ListArg *listarg)
{
for (ListArg::const_iterator i = listarg->begin() ; i != listarg->end() ; ++i)
{
(*i)->accept(this);
if (i != listarg->end() - 1) render(',');
}
}void PrintAbsyn::visitClassDef(ClassDef *p) {} //abstract class
void PrintAbsyn::visitClassDefN(ClassDefN *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("class");
visitPIdent(p->pident_);
_i_ = 0; p->classblock_->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitClassDefE(ClassDefE *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("class");
visitPIdent(p->pident_1);
render("extends");
visitPIdent(p->pident_2);
_i_ = 0; p->classblock_->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitClassBlock(ClassBlock *p) {} //abstract class
void PrintAbsyn::visitClassBl(ClassBl *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render('{');
if(p->listclassblockdef_) {_i_ = 0; p->listclassblockdef_->accept(this);}
render('}');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitClassBlockDef(ClassBlockDef *p) {} //abstract class
void PrintAbsyn::visitClassMthd(ClassMthd *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->fundef_->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitClassFld(ClassFld *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->type_->accept(this);
if(p->listitem_) {_i_ = 0; p->listitem_->accept(this);}
render(';');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitListClassBlockDef(ListClassBlockDef *listclassblockdef)
{
for (ListClassBlockDef::const_iterator i = listclassblockdef->begin() ; i != listclassblockdef->end() ; ++i)
{
(*i)->accept(this);
render("");
}
}void PrintAbsyn::visitBlock(Block *p) {} //abstract class
void PrintAbsyn::visitBlk(Blk *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render('{');
if(p->liststmt_) {_i_ = 0; p->liststmt_->accept(this);}
render('}');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitListStmt(ListStmt *liststmt)
{
for (ListStmt::const_iterator i = liststmt->begin() ; i != liststmt->end() ; ++i)
{
(*i)->accept(this);
render("");
}
}void PrintAbsyn::visitStmt(Stmt *p) {} //abstract class
void PrintAbsyn::visitEmpty(Empty *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render(';');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitBStmt(BStmt *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->block_->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitDecl(Decl *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->type_->accept(this);
if(p->listitem_) {_i_ = 0; p->listitem_->accept(this);}
render(';');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitAss(Ass *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->expr_1->accept(this);
render('=');
_i_ = 0; p->expr_2->accept(this);
render(';');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitTableAss(TableAss *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_);
render('[');
_i_ = 0; p->expr_1->accept(this);
render(']');
render('=');
_i_ = 0; p->expr_2->accept(this);
render(';');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitTableIncr(TableIncr *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_);
render('[');
_i_ = 0; p->expr_->accept(this);
render(']');
render("++");
render(';');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitTableDecr(TableDecr *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_);
render('[');
_i_ = 0; p->expr_->accept(this);
render(']');
render("--");
render(';');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitIncr(Incr *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_);
render("++");
render(';');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitDecr(Decr *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_);
render("--");
render(';');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitRet(Ret *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("return");
_i_ = 0; p->expr_->accept(this);
render(';');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitVRet(VRet *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("return");
render(';');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitCond(Cond *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("if");
render('(');
_i_ = 0; p->expr_->accept(this);
render(')');
_i_ = 0; p->stmt_->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitCondElse(CondElse *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("if");
render('(');
_i_ = 0; p->expr_->accept(this);
render(')');
_i_ = 0; p->stmt_1->accept(this);
render("else");
_i_ = 0; p->stmt_2->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitWhile(While *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("while");
render('(');
_i_ = 0; p->expr_->accept(this);
render(')');
_i_ = 0; p->stmt_->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitSExp(SExp *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->expr_->accept(this);
render(';');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitForEach(ForEach *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("for");
render('(');
_i_ = 0; p->type_->accept(this);
visitPIdent(p->pident_);
render(':');
_i_ = 0; p->expr_->accept(this);
render(')');
_i_ = 0; p->stmt_->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitItem(Item *p) {} //abstract class
void PrintAbsyn::visitNoInit(NoInit *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitInit(Init *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_);
render('=');
_i_ = 0; p->expr_->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitListItem(ListItem *listitem)
{
for (ListItem::const_iterator i = listitem->begin() ; i != listitem->end() ; ++i)
{
(*i)->accept(this);
if (i != listitem->end() - 1) render(',');
}
}void PrintAbsyn::visitType(Type *p) {} //abstract class
void PrintAbsyn::visitInt(Int *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("int");
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitStr(Str *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("string");
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitBool(Bool *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("boolean");
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitVoid(Void *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("void");
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitArray(Array *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
_i_ = 0; p->type_->accept(this);
render('[');
render(']');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitClassT(ClassT *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
visitPIdent(p->pident_);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitFun(Fun *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
/* Internal Category */
_i_ = 0; p->type_->accept(this);
render('(');
if(p->listtype_) {_i_ = 0; p->listtype_->accept(this);}
render(')');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitListType(ListType *listtype)
{
for (ListType::const_iterator i = listtype->begin() ; i != listtype->end() ; ++i)
{
(*i)->accept(this);
if (i != listtype->end() - 1) render(',');
}
}void PrintAbsyn::visitExpr(Expr *p) {} //abstract class
void PrintAbsyn::visitEVar(EVar *p)
{
int oldi = _i_;
if (oldi > 6) render(_L_PAREN);
visitPIdent(p->pident_);
if (oldi > 6) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitELitInt(ELitInt *p)
{
int oldi = _i_;
if (oldi > 6) render(_L_PAREN);
visitInteger(p->integer_);
if (oldi > 6) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitELitTrue(ELitTrue *p)
{
int oldi = _i_;
if (oldi > 6) render(_L_PAREN);
render("true");
if (oldi > 6) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitELitFalse(ELitFalse *p)
{
int oldi = _i_;
if (oldi > 6) render(_L_PAREN);
render("false");
if (oldi > 6) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitEApp(EApp *p)
{
int oldi = _i_;
if (oldi > 6) render(_L_PAREN);
visitPIdent(p->pident_);
render('(');
if(p->listexpr_) {_i_ = 0; p->listexpr_->accept(this);}
render(')');
if (oldi > 6) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitEString(EString *p)
{
int oldi = _i_;
if (oldi > 6) render(_L_PAREN);
visitString(p->string_);
if (oldi > 6) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitENewArray(ENewArray *p)
{
int oldi = _i_;
if (oldi > 6) render(_L_PAREN);
render("new");
_i_ = 0; p->type_->accept(this);
render('[');
_i_ = 0; p->expr_->accept(this);
render(']');
if (oldi > 6) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitENewClass(ENewClass *p)
{
int oldi = _i_;
if (oldi > 6) render(_L_PAREN);
render("new");
visitPIdent(p->pident_);
if (oldi > 6) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitEClsMmbr(EClsMmbr *p)
{
int oldi = _i_;
if (oldi > 6) render(_L_PAREN);
_i_ = 6; p->expr_->accept(this);
render('.');
visitPIdent(p->pident_);
if (oldi > 6) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitEClsMthd(EClsMthd *p)
{
int oldi = _i_;
if (oldi > 6) render(_L_PAREN);
_i_ = 6; p->expr_->accept(this);
render('.');
visitPIdent(p->pident_);
render('(');
if(p->listexpr_) {_i_ = 0; p->listexpr_->accept(this);}
render(')');
if (oldi > 6) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitNull(Null *p)
{
int oldi = _i_;
if (oldi > 6) render(_L_PAREN);
render("null");
if (oldi > 6) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitEIndexAcc(EIndexAcc *p)
{
int oldi = _i_;
if (oldi > 6) render(_L_PAREN);
visitPIdent(p->pident_);
render('[');
_i_ = 0; p->expr_->accept(this);
render(']');
if (oldi > 6) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitECast(ECast *p)
{
int oldi = _i_;
if (oldi > 5) render(_L_PAREN);
render('(');
visitPIdent(p->pident_);
render(')');
_i_ = 5; p->expr_->accept(this);
if (oldi > 5) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitNeg(Neg *p)
{
int oldi = _i_;
if (oldi > 5) render(_L_PAREN);
render('-');
_i_ = 6; p->expr_->accept(this);
if (oldi > 5) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitNot(Not *p)
{
int oldi = _i_;
if (oldi > 5) render(_L_PAREN);
render('!');
_i_ = 6; p->expr_->accept(this);
if (oldi > 5) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitEMul(EMul *p)
{
int oldi = _i_;
if (oldi > 4) render(_L_PAREN);
_i_ = 4; p->expr_1->accept(this);
_i_ = 0; p->mulop_->accept(this);
_i_ = 5; p->expr_2->accept(this);
if (oldi > 4) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitEAdd(EAdd *p)
{
int oldi = _i_;
if (oldi > 3) render(_L_PAREN);
_i_ = 3; p->expr_1->accept(this);
_i_ = 0; p->addop_->accept(this);
_i_ = 4; p->expr_2->accept(this);
if (oldi > 3) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitERel(ERel *p)
{
int oldi = _i_;
if (oldi > 2) render(_L_PAREN);
_i_ = 2; p->expr_1->accept(this);
_i_ = 0; p->relop_->accept(this);
_i_ = 3; p->expr_2->accept(this);
if (oldi > 2) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitEAnd(EAnd *p)
{
int oldi = _i_;
if (oldi > 1) render(_L_PAREN);
_i_ = 2; p->expr_1->accept(this);
render("&&");
_i_ = 1; p->expr_2->accept(this);
if (oldi > 1) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitEOr(EOr *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
_i_ = 1; p->expr_1->accept(this);
render("||");
_i_ = 0; p->expr_2->accept(this);
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitListExpr(ListExpr *listexpr)
{
for (ListExpr::const_iterator i = listexpr->begin() ; i != listexpr->end() ; ++i)
{
(*i)->accept(this);
if (i != listexpr->end() - 1) render(',');
}
}void PrintAbsyn::visitAddOp(AddOp *p) {} //abstract class
void PrintAbsyn::visitPlus(Plus *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render('+');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitMinus(Minus *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render('-');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitMulOp(MulOp *p) {} //abstract class
void PrintAbsyn::visitTimes(Times *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render('*');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitDiv(Div *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render('/');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitMod(Mod *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render('%');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitRelOp(RelOp *p) {} //abstract class
void PrintAbsyn::visitLTH(LTH *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render('<');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitLE(LE *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("<=");
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitGTH(GTH *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render('>');
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitGE(GE *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render(">=");
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitEQU(EQU *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("==");
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitNE(NE *p)
{
int oldi = _i_;
if (oldi > 0) render(_L_PAREN);
render("!=");
if (oldi > 0) render(_R_PAREN);
_i_ = oldi;
}
void PrintAbsyn::visitInteger(Integer i)
{
char tmp[16];
sprintf(tmp, "%d", i);
bufAppend(tmp);
}
void PrintAbsyn::visitDouble(Double d)
{
char tmp[16];
sprintf(tmp, "%g", d);
bufAppend(tmp);
}
void PrintAbsyn::visitChar(Char c)
{
bufAppend('\'');
bufAppend(c);
bufAppend('\'');
}
void PrintAbsyn::visitString(String s)
{
bufAppend('\"');
bufAppend(s);
bufAppend('\"');
}
void PrintAbsyn::visitIdent(String s)
{
render(s);
}
void PrintAbsyn::visitPIdent(String s)
{
render(s);
}
ShowAbsyn::ShowAbsyn(void)
{
buf_ = 0;
bufReset();
}
ShowAbsyn::~ShowAbsyn(void)
{
}
char *ShowAbsyn::show(Visitable *v)
{
bufReset();
v->accept(this);
return buf_;
}
void ShowAbsyn::visitPIdent(PIdent *p)
{
bufAppend('(');
bufAppend("PIdent");
bufAppend(' ');
visitString(p->string_);
bufAppend(' ');
visitInteger(p->integer_);
bufAppend(')');
}
void ShowAbsyn::visitProgram(Program *p) {} //abstract class
void ShowAbsyn::visitProg(Prog *p)
{
bufAppend('(');
bufAppend("Prog");
bufAppend(' ');
bufAppend('[');
if (p->listtopdef_) p->listtopdef_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitTopDef(TopDef *p) {} //abstract class
void ShowAbsyn::visitFnDef(FnDef *p)
{
bufAppend('(');
bufAppend("FnDef");
bufAppend(' ');
bufAppend('[');
if (p->fundef_) p->fundef_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitClDef(ClDef *p)
{
bufAppend('(');
bufAppend("ClDef");
bufAppend(' ');
bufAppend('[');
if (p->classdef_) p->classdef_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitListTopDef(ListTopDef *listtopdef)
{
for (ListTopDef::const_iterator i = listtopdef->begin() ; i != listtopdef->end() ; ++i)
{
(*i)->accept(this);
if (i != listtopdef->end() - 1) bufAppend(", ");
}
}
void ShowAbsyn::visitFunDef(FunDef *p) {} //abstract class
void ShowAbsyn::visitFuncDef(FuncDef *p)
{
bufAppend('(');
bufAppend("FuncDef");
bufAppend(' ');
bufAppend('[');
if (p->type_) p->type_->accept(this);
bufAppend(']');
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
bufAppend('[');
if (p->listarg_) p->listarg_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend('[');
if (p->block_) p->block_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitArg(Arg *p) {} //abstract class
void ShowAbsyn::visitAr(Ar *p)
{
bufAppend('(');
bufAppend("Ar");
bufAppend(' ');
bufAppend('[');
if (p->type_) p->type_->accept(this);
bufAppend(']');
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(')');
}
void ShowAbsyn::visitListArg(ListArg *listarg)
{
for (ListArg::const_iterator i = listarg->begin() ; i != listarg->end() ; ++i)
{
(*i)->accept(this);
if (i != listarg->end() - 1) bufAppend(", ");
}
}
void ShowAbsyn::visitClassDef(ClassDef *p) {} //abstract class
void ShowAbsyn::visitClassDefN(ClassDefN *p)
{
bufAppend('(');
bufAppend("ClassDefN");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
bufAppend('[');
if (p->classblock_) p->classblock_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitClassDefE(ClassDefE *p)
{
bufAppend('(');
bufAppend("ClassDefE");
bufAppend(' ');
visitPIdent(p->pident_1);
bufAppend(' ');
visitPIdent(p->pident_2);
bufAppend(' ');
bufAppend('[');
if (p->classblock_) p->classblock_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitClassBlock(ClassBlock *p) {} //abstract class
void ShowAbsyn::visitClassBl(ClassBl *p)
{
bufAppend('(');
bufAppend("ClassBl");
bufAppend(' ');
bufAppend('[');
if (p->listclassblockdef_) p->listclassblockdef_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitClassBlockDef(ClassBlockDef *p) {} //abstract class
void ShowAbsyn::visitClassMthd(ClassMthd *p)
{
bufAppend('(');
bufAppend("ClassMthd");
bufAppend(' ');
bufAppend('[');
if (p->fundef_) p->fundef_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitClassFld(ClassFld *p)
{
bufAppend('(');
bufAppend("ClassFld");
bufAppend(' ');
bufAppend('[');
if (p->type_) p->type_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend('[');
if (p->listitem_) p->listitem_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitListClassBlockDef(ListClassBlockDef *listclassblockdef)
{
for (ListClassBlockDef::const_iterator i = listclassblockdef->begin() ; i != listclassblockdef->end() ; ++i)
{
(*i)->accept(this);
if (i != listclassblockdef->end() - 1) bufAppend(", ");
}
}
void ShowAbsyn::visitBlock(Block *p) {} //abstract class
void ShowAbsyn::visitBlk(Blk *p)
{
bufAppend('(');
bufAppend("Blk");
bufAppend(' ');
bufAppend('[');
if (p->liststmt_) p->liststmt_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitListStmt(ListStmt *liststmt)
{
for (ListStmt::const_iterator i = liststmt->begin() ; i != liststmt->end() ; ++i)
{
(*i)->accept(this);
if (i != liststmt->end() - 1) bufAppend(", ");
}
}
void ShowAbsyn::visitStmt(Stmt *p) {} //abstract class
void ShowAbsyn::visitEmpty(Empty *p)
{
bufAppend("Empty");
}
void ShowAbsyn::visitBStmt(BStmt *p)
{
bufAppend('(');
bufAppend("BStmt");
bufAppend(' ');
bufAppend('[');
if (p->block_) p->block_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitDecl(Decl *p)
{
bufAppend('(');
bufAppend("Decl");
bufAppend(' ');
bufAppend('[');
if (p->type_) p->type_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend('[');
if (p->listitem_) p->listitem_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitAss(Ass *p)
{
bufAppend('(');
bufAppend("Ass");
bufAppend(' ');
p->expr_1->accept(this);
bufAppend(' ');
p->expr_2->accept(this);
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitTableAss(TableAss *p)
{
bufAppend('(');
bufAppend("TableAss");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
p->expr_1->accept(this);
bufAppend(' ');
p->expr_2->accept(this);
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitTableIncr(TableIncr *p)
{
bufAppend('(');
bufAppend("TableIncr");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitTableDecr(TableDecr *p)
{
bufAppend('(');
bufAppend("TableDecr");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitIncr(Incr *p)
{
bufAppend('(');
bufAppend("Incr");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitDecr(Decr *p)
{
bufAppend('(');
bufAppend("Decr");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitRet(Ret *p)
{
bufAppend('(');
bufAppend("Ret");
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitVRet(VRet *p)
{
bufAppend("VRet");
}
void ShowAbsyn::visitCond(Cond *p)
{
bufAppend('(');
bufAppend("Cond");
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend('[');
if (p->stmt_) p->stmt_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitCondElse(CondElse *p)
{
bufAppend('(');
bufAppend("CondElse");
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(' ');
p->stmt_1->accept(this);
bufAppend(' ');
p->stmt_2->accept(this);
bufAppend(')');
}
void ShowAbsyn::visitWhile(While *p)
{
bufAppend('(');
bufAppend("While");
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend('[');
if (p->stmt_) p->stmt_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitSExp(SExp *p)
{
bufAppend('(');
bufAppend("SExp");
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitForEach(ForEach *p)
{
bufAppend('(');
bufAppend("ForEa.h");
bufAppend(' ');
bufAppend('[');
if (p->type_) p->type_->accept(this);
bufAppend(']');
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend('[');
if (p->stmt_) p->stmt_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitItem(Item *p) {} //abstract class
void ShowAbsyn::visitNoInit(NoInit *p)
{
bufAppend('(');
bufAppend("NoInit");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(')');
}
void ShowAbsyn::visitInit(Init *p)
{
bufAppend('(');
bufAppend("Init");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitListItem(ListItem *listitem)
{
for (ListItem::const_iterator i = listitem->begin() ; i != listitem->end() ; ++i)
{
(*i)->accept(this);
if (i != listitem->end() - 1) bufAppend(", ");
}
}
void ShowAbsyn::visitType(Type *p) {} //abstract class
void ShowAbsyn::visitInt(Int *p)
{
bufAppend("Int");
}
void ShowAbsyn::visitStr(Str *p)
{
bufAppend("Str");
}
void ShowAbsyn::visitBool(Bool *p)
{
bufAppend("Bool");
}
void ShowAbsyn::visitVoid(Void *p)
{
bufAppend("Void");
}
void ShowAbsyn::visitArray(Array *p)
{
bufAppend('(');
bufAppend("Array");
bufAppend(' ');
bufAppend('[');
if (p->type_) p->type_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitClassT(ClassT *p)
{
bufAppend('(');
bufAppend("ClassT");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(')');
}
void ShowAbsyn::visitFun(Fun *p)
{
bufAppend('(');
bufAppend("Fun");
bufAppend(' ');
/* Internal Category */
bufAppend(' ');
bufAppend('[');
if (p->type_) p->type_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend('[');
if (p->listtype_) p->listtype_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitListType(ListType *listtype)
{
for (ListType::const_iterator i = listtype->begin() ; i != listtype->end() ; ++i)
{
(*i)->accept(this);
if (i != listtype->end() - 1) bufAppend(", ");
}
}
void ShowAbsyn::visitExpr(Expr *p) {} //abstract class
void ShowAbsyn::visitEVar(EVar *p)
{
bufAppend('(');
bufAppend("EVar");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(')');
}
void ShowAbsyn::visitELitInt(ELitInt *p)
{
bufAppend('(');
bufAppend("ELitInt");
bufAppend(' ');
visitInteger(p->integer_);
bufAppend(')');
}
void ShowAbsyn::visitELitTrue(ELitTrue *p)
{
bufAppend("ELitTrue");
}
void ShowAbsyn::visitELitFalse(ELitFalse *p)
{
bufAppend("ELitFalse");
}
void ShowAbsyn::visitEApp(EApp *p)
{
bufAppend('(');
bufAppend("EApp");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
bufAppend('[');
if (p->listexpr_) p->listexpr_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitEString(EString *p)
{
bufAppend('(');
bufAppend("EString");
bufAppend(' ');
visitString(p->string_);
bufAppend(')');
}
void ShowAbsyn::visitENewArray(ENewArray *p)
{
bufAppend('(');
bufAppend("ENewArray");
bufAppend(' ');
bufAppend('[');
if (p->type_) p->type_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitENewClass(ENewClass *p)
{
bufAppend('(');
bufAppend("ENewClass");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(')');
}
void ShowAbsyn::visitEClsMmbr(EClsMmbr *p)
{
bufAppend('(');
bufAppend("EClsMmbr");
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(')');
}
void ShowAbsyn::visitEClsMthd(EClsMthd *p)
{
bufAppend('(');
bufAppend("EClsMthd");
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
bufAppend('[');
if (p->listexpr_) p->listexpr_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitNull(Null *p)
{
bufAppend("Null");
}
void ShowAbsyn::visitEIndexAcc(EIndexAcc *p)
{
bufAppend('(');
bufAppend("EIndexAcc");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(' ');
bufAppend(')');
}
void ShowAbsyn::visitECast(ECast *p)
{
bufAppend('(');
bufAppend("ECast");
bufAppend(' ');
visitPIdent(p->pident_);
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitNeg(Neg *p)
{
bufAppend('(');
bufAppend("Neg");
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitNot(Not *p)
{
bufAppend('(');
bufAppend("Not");
bufAppend(' ');
bufAppend('[');
if (p->expr_) p->expr_->accept(this);
bufAppend(']');
bufAppend(')');
}
void ShowAbsyn::visitEMul(EMul *p)
{
bufAppend('(');
bufAppend("EMul");
bufAppend(' ');
p->expr_1->accept(this);
bufAppend(' ');
bufAppend('[');
if (p->mulop_) p->mulop_->accept(this);
bufAppend(']');
bufAppend(' ');
p->expr_2->accept(this);
bufAppend(')');
}
void ShowAbsyn::visitEAdd(EAdd *p)
{
bufAppend('(');
bufAppend("EAdd");
bufAppend(' ');
p->expr_1->accept(this);
bufAppend(' ');
bufAppend('[');
if (p->addop_) p->addop_->accept(this);
bufAppend(']');
bufAppend(' ');
p->expr_2->accept(this);
bufAppend(')');
}
void ShowAbsyn::visitERel(ERel *p)
{
bufAppend('(');
bufAppend("ERel");
bufAppend(' ');
p->expr_1->accept(this);
bufAppend(' ');
bufAppend('[');
if (p->relop_) p->relop_->accept(this);
bufAppend(']');
bufAppend(' ');
p->expr_2->accept(this);
bufAppend(')');
}
void ShowAbsyn::visitEAnd(EAnd *p)
{
bufAppend('(');
bufAppend("EAnd");
bufAppend(' ');
p->expr_1->accept(this);
bufAppend(' ');
p->expr_2->accept(this);
bufAppend(')');
}
void ShowAbsyn::visitEOr(EOr *p)
{
bufAppend('(');
bufAppend("EOr");
bufAppend(' ');
p->expr_1->accept(this);
bufAppend(' ');
p->expr_2->accept(this);
bufAppend(')');
}
void ShowAbsyn::visitListExpr(ListExpr *listexpr)
{
for (ListExpr::const_iterator i = listexpr->begin() ; i != listexpr->end() ; ++i)
{
(*i)->accept(this);
if (i != listexpr->end() - 1) bufAppend(", ");
}
}
void ShowAbsyn::visitAddOp(AddOp *p) {} //abstract class
void ShowAbsyn::visitPlus(Plus *p)
{
bufAppend("Plus");
}
void ShowAbsyn::visitMinus(Minus *p)
{
bufAppend("Minus");
}
void ShowAbsyn::visitMulOp(MulOp *p) {} //abstract class
void ShowAbsyn::visitTimes(Times *p)
{
bufAppend("Times");
}
void ShowAbsyn::visitDiv(Div *p)
{
bufAppend("Div");
}
void ShowAbsyn::visitMod(Mod *p)
{
bufAppend("Mod");
}
void ShowAbsyn::visitRelOp(RelOp *p) {} //abstract class
void ShowAbsyn::visitLTH(LTH *p)
{
bufAppend("L.h");
}
void ShowAbsyn::visitLE(LE *p)
{
bufAppend("LE");
}
void ShowAbsyn::visitGTH(GTH *p)
{
bufAppend("G.h");
}
void ShowAbsyn::visitGE(GE *p)
{
bufAppend("GE");
}
void ShowAbsyn::visitEQU(EQU *p)
{
bufAppend("EQU");
}
void ShowAbsyn::visitNE(NE *p)
{
bufAppend("NE");
}
void ShowAbsyn::visitInteger(Integer i)
{
char tmp[16];
sprintf(tmp, "%d", i);
bufAppend(tmp);
}
void ShowAbsyn::visitDouble(Double d)
{
char tmp[16];
sprintf(tmp, "%g", d);
bufAppend(tmp);
}
void ShowAbsyn::visitChar(Char c)
{
bufAppend('\'');
bufAppend(c);
bufAppend('\'');
}
void ShowAbsyn::visitString(String s)
{
bufAppend('\"');
bufAppend(s);
bufAppend('\"');
}
void ShowAbsyn::visitIdent(String s)
{
bufAppend('\"');
bufAppend(s);
bufAppend('\"');
}
void ShowAbsyn::visitPIdent(String s)
{
bufAppend('\"');
bufAppend(s);
bufAppend('\"');
}
#ifndef PRINTER_HEADER
#define PRINTER_HEADER
#include "Absyn.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/* Certain applications may improve performance by changing the buffer size */
#define BUFFER_INITIAL 2000
/* You may wish to change _L_PAREN or _R_PAREN */
#define _L_PAREN '('
#define _R_PAREN ')'
class PrintAbsyn : public Visitor
{
protected:
int _n_, _i_;
/* The following are simple heuristics for rendering terminals */
/* You may wish to change them */
void render(Char c);
void render(String s);
void render(const char *s);
void indent(void);
void backup(void);
public:
PrintAbsyn(void);
~PrintAbsyn(void);
char *print(Visitable *v);
void visitPIdent(PIdent *p);
void visitProgram(Program *p); /* abstract class */
void visitProg(Prog *p);
void visitTopDef(TopDef *p); /* abstract class */
void visitFnDef(FnDef *p);
void visitClDef(ClDef *p);
void visitListTopDef(ListTopDef *p);
void visitFunDef(FunDef *p); /* abstract class */
void visitFuncDef(FuncDef *p);
void visitArg(Arg *p); /* abstract class */
void visitAr(Ar *p);
void visitListArg(ListArg *p);
void visitClassDef(ClassDef *p); /* abstract class */
void visitClassDefN(ClassDefN *p);
void visitClassDefE(ClassDefE *p);
void visitClassBlock(ClassBlock *p); /* abstract class */
void visitClassBl(ClassBl *p);
void visitClassBlockDef(ClassBlockDef *p); /* abstract class */
void visitClassMthd(ClassMthd *p);
void visitClassFld(ClassFld *p);
void visitListClassBlockDef(ListClassBlockDef *p);
void visitBlock(Block *p); /* abstract class */
void visitBlk(Blk *p);
void visitListStmt(ListStmt *p);
void visitStmt(Stmt *p); /* abstract class */
void visitEmpty(Empty *p);
void visitBStmt(BStmt *p);
void visitDecl(Decl *p);
void visitAss(Ass *p);
void visitTableAss(TableAss *p);
void visitTableIncr(TableIncr *p);
void visitTableDecr(TableDecr *p);
void visitIncr(Incr *p);
void visitDecr(Decr *p);
void visitRet(Ret *p);
void visitVRet(VRet *p);
void visitCond(Cond *p);
void visitCondElse(CondElse *p);
void visitWhile(While *p);
void visitSExp(SExp *p);
void visitForEach(ForEach *p);
void visitItem(Item *p); /* abstract class */
void visitNoInit(NoInit *p);
void visitInit(Init *p);
void visitListItem(ListItem *p);
void visitType(Type *p); /* abstract class */
void visitInt(Int *p);
void visitStr(Str *p);
void visitBool(Bool *p);
void visitVoid(Void *p);
void visitArray(Array *p);
void visitClassT(ClassT *p);
void visitFun(Fun *p);
void visitListType(ListType *p);
void visitExpr(Expr *p); /* abstract class */
void visitEVar(EVar *p);
void visitELitInt(ELitInt *p);
void visitELitTrue(ELitTrue *p);
void visitELitFalse(ELitFalse *p);
void visitEApp(EApp *p);
void visitEString(EString *p);
void visitENewArray(ENewArray *p);
void visitENewClass(ENewClass *p);
void visitEClsMmbr(EClsMmbr *p);
void visitEClsMthd(EClsMthd *p);
void visitNull(Null *p);
void visitEIndexAcc(EIndexAcc *p);
void visitECast(ECast *p);
void visitNeg(Neg *p);
void visitNot(Not *p);
void visitEMul(EMul *p);
void visitEAdd(EAdd *p);
void visitERel(ERel *p);
void visitEAnd(EAnd *p);
void visitEOr(EOr *p);
void visitListExpr(ListExpr *p);
void visitAddOp(AddOp *p); /* abstract class */
void visitPlus(Plus *p);
void visitMinus(Minus *p);
void visitMulOp(MulOp *p); /* abstract class */
void visitTimes(Times *p);
void visitDiv(Div *p);
void visitMod(Mod *p);
void visitRelOp(RelOp *p); /* abstract class */
void visitLTH(LTH *p);
void visitLE(LE *p);
void visitGTH(GTH *p);
void visitGE(GE *p);
void visitEQU(EQU *p);
void visitNE(NE *p);
void visitInteger(Integer i);
void visitDouble(Double d);
void visitChar(Char c);
void visitString(String s);
void visitIdent(String s);
void visitPIdent(String s);
protected:
char *buf_;
int cur_, buf_size;
void inline bufAppend(const char *s)
{
int len = strlen(s);
while (cur_ + len >= buf_size)
{
buf_size *= 2; /* Double the buffer size */
}
resizeBuffer();
for(int n = 0; n < len; n++)
{
buf_[cur_ + n] = s[n];
}
cur_ += len;
buf_[cur_] = 0;
}
void inline bufAppend(const char c)
{
if (cur_ >= buf_size)
{
buf_size *= 2; /* Double the buffer size */
resizeBuffer();
}
buf_[cur_] = c;
cur_++;
buf_[cur_] = 0;
}
void inline bufAppend(String str)
{
const char *s = str.c_str();
bufAppend(s);
}
void inline bufReset(void)
{
if (buf_) free(buf_);
buf_size = BUFFER_INITIAL;
buf_ = (char *) malloc(buf_size);
if (!buf_) {
fprintf(stderr, "Error: Out of memory while allocating buffer!\n");
exit(1);
}
memset(buf_, 0, buf_size);
cur_ = 0;
}
void inline resizeBuffer(void)
{
char *temp = (char *) malloc(buf_size);
if (!temp)
{
fprintf(stderr, "Error: Out of memory while attempting to grow buffer!\n");
exit(1);
}
if (buf_)
{
strcpy(temp, buf_);
free(buf_);
}
buf_ = temp;
}
};
class ShowAbsyn : public Visitor
{
public:
ShowAbsyn(void);
~ShowAbsyn(void);
char *show(Visitable *v);
void visitPIdent(PIdent *p);
void visitProgram(Program *p); /* abstract class */
void visitProg(Prog *p);
void visitTopDef(TopDef *p); /* abstract class */
void visitFnDef(FnDef *p);
void visitClDef(ClDef *p);
void visitListTopDef(ListTopDef *p);
void visitFunDef(FunDef *p); /* abstract class */
void visitFuncDef(FuncDef *p);
void visitArg(Arg *p); /* abstract class */
void visitAr(Ar *p);
void visitListArg(ListArg *p);
void visitClassDef(ClassDef *p); /* abstract class */
void visitClassDefN(ClassDefN *p);
void visitClassDefE(ClassDefE *p);
void visitClassBlock(ClassBlock *p); /* abstract class */
void visitClassBl(ClassBl *p);
void visitClassBlockDef(ClassBlockDef *p); /* abstract class */
void visitClassMthd(ClassMthd *p);
void visitClassFld(ClassFld *p);
void visitListClassBlockDef(ListClassBlockDef *p);
void visitBlock(Block *p); /* abstract class */
void visitBlk(Blk *p);
void visitListStmt(ListStmt *p);
void visitStmt(Stmt *p); /* abstract class */
void visitEmpty(Empty *p);
void visitBStmt(BStmt *p);
void visitDecl(Decl *p);
void visitAss(Ass *p);
void visitTableAss(TableAss *p);
void visitTableIncr(TableIncr *p);
void visitTableDecr(TableDecr *p);
void visitIncr(Incr *p);
void visitDecr(Decr *p);
void visitRet(Ret *p);
void visitVRet(VRet *p);
void visitCond(Cond *p);
void visitCondElse(CondElse *p);
void visitWhile(While *p);
void visitSExp(SExp *p);
void visitForEach(ForEach *p);
void visitItem(Item *p); /* abstract class */
void visitNoInit(NoInit *p);
void visitInit(Init *p);
void visitListItem(ListItem *p);
void visitType(Type *p); /* abstract class */
void visitInt(Int *p);
void visitStr(Str *p);
void visitBool(Bool *p);
void visitVoid(Void *p);
void visitArray(Array *p);
void visitClassT(ClassT *p);
void visitFun(Fun *p);
void visitListType(ListType *p);
void visitExpr(Expr *p); /* abstract class */
void visitEVar(EVar *p);
void visitELitInt(ELitInt *p);
void visitELitTrue(ELitTrue *p);
void visitELitFalse(ELitFalse *p);
void visitEApp(EApp *p);
void visitEString(EString *p);
void visitENewArray(ENewArray *p);
void visitENewClass(ENewClass *p);
void visitEClsMmbr(EClsMmbr *p);
void visitEClsMthd(EClsMthd *p);
void visitNull(Null *p);
void visitEIndexAcc(EIndexAcc *p);
void visitECast(ECast *p);
void visitNeg(Neg *p);
void visitNot(Not *p);
void visitEMul(EMul *p);
void visitEAdd(EAdd *p);
void visitERel(ERel *p);
void visitEAnd(EAnd *p);
void visitEOr(EOr *p);
void visitListExpr(ListExpr *p);
void visitAddOp(AddOp *p); /* abstract class */
void visitPlus(Plus *p);
void visitMinus(Minus *p);
void visitMulOp(MulOp *p); /* abstract class */
void visitTimes(Times *p);
void visitDiv(Div *p);
void visitMod(Mod *p);
void visitRelOp(RelOp *p); /* abstract class */
void visitLTH(LTH *p);
void visitLE(LE *p);
void visitGTH(GTH *p);
void visitGE(GE *p);
void visitEQU(EQU *p);
void visitNE(NE *p);
void visitInteger(Integer i);
void visitDouble(Double d);
void visitChar(Char c);
void visitString(String s);
void visitIdent(String s);
void visitPIdent(String s);
protected:
char *buf_;
int cur_, buf_size;
void inline bufAppend(const char *s)
{
int len = strlen(s);
while (cur_ + len >= buf_size)
{
buf_size *= 2; /* Double the buffer size */
}
resizeBuffer();
for(int n = 0; n < len; n++)
{
buf_[cur_ + n] = s[n];
}
cur_ += len;
buf_[cur_] = 0;
}
void inline bufAppend(const char c)
{
if (cur_ >= buf_size)
{
buf_size *= 2; /* Double the buffer size */
resizeBuffer();
}
buf_[cur_] = c;
cur_++;
buf_[cur_] = 0;
}
void inline bufAppend(String str)
{
const char *s = str.c_str();
bufAppend(s);
}
void inline bufReset(void)
{
if (buf_) free(buf_);
buf_size = BUFFER_INITIAL;
buf_ = (char *) malloc(buf_size);
if (!buf_) {
fprintf(stderr, "Error: Out of memory while allocating buffer!\n");
exit(1);
}
memset(buf_, 0, buf_size);
cur_ = 0;
}
void inline resizeBuffer(void)
{
char *temp = (char *) malloc(buf_size);
if (!temp)
{
fprintf(stderr, "Error: Out of memory while attempting to grow buffer!\n");
exit(1);
}
if (buf_)
{
strcpy(temp, buf_);
free(buf_);
}
buf_ = temp;
}
};
#endif
/*** BNFC-Generated Visitor Design Pattern Skeleton. ***/
/* This implements the common visitor design pattern.
Note that this method uses Visitor-traversal of lists, so
List->accept() does NOT traverse the list. This allows different
algorithms to use context information differently. */
#include "Skeleton.h"
void Skeleton::visitProgram(Program *t) {} //abstract class
void Skeleton::visitTopDef(TopDef *t) {} //abstract class
void Skeleton::visitFunDef(FunDef *t) {} //abstract class
void Skeleton::visitArg(Arg *t) {} //abstract class
void Skeleton::visitClassDef(ClassDef *t) {} //abstract class
void Skeleton::visitClassBlock(ClassBlock *t) {} //abstract class
void Skeleton::visitClassBlockDef(ClassBlockDef *t) {} //abstract class
void Skeleton::visitBlock(Block *t) {} //abstract class
void Skeleton::visitStmt(Stmt *t) {} //abstract class
void Skeleton::visitItem(Item *t) {} //abstract class
void Skeleton::visitType(Type *t) {} //abstract class
void Skeleton::visitExpr(Expr *t) {} //abstract class
void Skeleton::visitAddOp(AddOp *t) {} //abstract class
void Skeleton::visitMulOp(MulOp *t) {} //abstract class
void Skeleton::visitRelOp(RelOp *t) {} //abstract class
void Skeleton::visitPIdent(PIdent *p_ident)
{
/* Code For PIdent Goes Here */
visitString(p_ident->string_);
visitInteger(p_ident->integer_);
}
void Skeleton::visitProg(Prog *prog)
{
/* Code For Prog Goes Here */
prog->listtopdef_->accept(this);
}
void Skeleton::visitFnDef(FnDef *fn_def)
{
/* Code For FnDef Goes Here */
fn_def->fundef_->accept(this);
}
void Skeleton::visitClDef(ClDef *cl_def)
{
/* Code For ClDef Goes Here */
cl_def->classdef_->accept(this);
}
void Skeleton::visitFuncDef(FuncDef *func_def)
{
/* Code For FuncDef Goes Here */
func_def->type_->accept(this);
func_def->pident_->accept(this);
func_def->listarg_->accept(this);
func_def->block_->accept(this);
}
void Skeleton::visitAr(Ar *ar)
{
/* Code For Ar Goes Here */
ar->type_->accept(this);
ar->pident_->accept(this);
}
void Skeleton::visitClassDefN(ClassDefN *class_def_n)
{
/* Code For ClassDefN Goes Here */
class_def_n->pident_->accept(this);
class_def_n->classblock_->accept(this);
}
void Skeleton::visitClassDefE(ClassDefE *class_def_e)
{
/* Code For ClassDefE Goes Here */
class_def_e->pident_1->accept(this);
class_def_e->pident_2->accept(this);
class_def_e->classblock_->accept(this);
}
void Skeleton::visitClassBl(ClassBl *class_bl)
{
/* Code For ClassBl Goes Here */
class_bl->listclassblockdef_->accept(this);
}
void Skeleton::visitClassMthd(ClassMthd *class_mthd)
{
/* Code For ClassMthd Goes Here */
class_mthd->fundef_->accept(this);
}
void Skeleton::visitClassFld(ClassFld *class_fld)
{
/* Code For ClassFld Goes Here */
class_fld->type_->accept(this);
class_fld->listitem_->accept(this);
}
void Skeleton::visitBlk(Blk *blk)
{
/* Code For Blk Goes Here */
blk->liststmt_->accept(this);
}
void Skeleton::visitEmpty(Empty *empty)
{
/* Code For Empty Goes Here */
}
void Skeleton::visitBStmt(BStmt *b_stmt)
{
/* Code For BStmt Goes Here */
b_stmt->block_->accept(this);
}
void Skeleton::visitDecl(Decl *decl)
{
/* Code For Decl Goes Here */
decl->type_->accept(this);
decl->listitem_->accept(this);
}
void Skeleton::visitAss(Ass *ass)
{
/* Code For Ass Goes Here */
ass->expr_1->accept(this);
ass->expr_2->accept(this);
}
void Skeleton::visitTableAss(TableAss *table_ass)
{
/* Code For TableAss Goes Here */
table_ass->pident_->accept(this);
table_ass->expr_1->accept(this);
table_ass->expr_2->accept(this);
}
void Skeleton::visitTableIncr(TableIncr *table_incr)
{
/* Code For TableIncr Goes Here */
table_incr->pident_->accept(this);
table_incr->expr_->accept(this);
}
void Skeleton::visitTableDecr(TableDecr *table_decr)
{
/* Code For TableDecr Goes Here */
table_decr->pident_->accept(this);
table_decr->expr_->accept(this);
}
void Skeleton::visitIncr(Incr *incr)
{
/* Code For Incr Goes Here */
incr->pident_->accept(this);
}
void Skeleton::visitDecr(Decr *decr)
{
/* Code For Decr Goes Here */
decr->pident_->accept(this);
}
void Skeleton::visitRet(Ret *ret)
{
/* Code For Ret Goes Here */
ret->expr_->accept(this);
}
void Skeleton::visitVRet(VRet *v_ret)
{
/* Code For VRet Goes Here */
}
void Skeleton::visitCond(Cond *cond)
{
/* Code For Cond Goes Here */
cond->expr_->accept(this);
cond->stmt_->accept(this);
}
void Skeleton::visitCondElse(CondElse *cond_else)
{
/* Code For CondElse Goes Here */
cond_else->expr_->accept(this);
cond_else->stmt_1->accept(this);
cond_else->stmt_2->accept(this);
}
void Skeleton::visitWhile(While *while_)
{
/* Code For While Goes Here */
while_->expr_->accept(this);
while_->stmt_->accept(this);
}
void Skeleton::visitSExp(SExp *s_exp)
{
/* Code For SExp Goes Here */
s_exp->expr_->accept(this);
}
void Skeleton::visitForEach(ForEach *for_each)
{
/* Code For ForEach Goes Here */
for_each->type_->accept(this);
for_each->pident_->accept(this);
for_each->expr_->accept(this);
for_each->stmt_->accept(this);
}
void Skeleton::visitNoInit(NoInit *no_init)
{
/* Code For NoInit Goes Here */
no_init->pident_->accept(this);
}
void Skeleton::visitInit(Init *init)
{
/* Code For Init Goes Here */
init->pident_->accept(this);
init->expr_->accept(this);
}
void Skeleton::visitInt(Int *int_)
{
/* Code For Int Goes Here */
}
void Skeleton::visitStr(Str *str)
{
/* Code For Str Goes Here */
}
void Skeleton::visitBool(Bool *bool_)
{
/* Code For Bool Goes Here */
}
void Skeleton::visitVoid(Void *void_)
{
/* Code For Void Goes Here */
}
void Skeleton::visitArray(Array *array)
{
/* Code For Array Goes Here */
array->type_->accept(this);
}
void Skeleton::visitClassT(ClassT *class_t)
{
/* Code For ClassT Goes Here */
class_t->pident_->accept(this);
}
void Skeleton::visitFun(Fun *fun)
{
/* Code For Fun Goes Here */
fun->type_->accept(this);
fun->listtype_->accept(this);
}
void Skeleton::visitEVar(EVar *e_var)
{
/* Code For EVar Goes Here */
e_var->pident_->accept(this);
}
void Skeleton::visitELitInt(ELitInt *e_lit_int)
{
/* Code For ELitInt Goes Here */
visitInteger(e_lit_int->integer_);
}
void Skeleton::visitELitTrue(ELitTrue *e_lit_true)
{
/* Code For ELitTrue Goes Here */
}
void Skeleton::visitELitFalse(ELitFalse *e_lit_false)
{
/* Code For ELitFalse Goes Here */
}
void Skeleton::visitEApp(EApp *e_app)
{
/* Code For EApp Goes Here */
e_app->pident_->accept(this);
e_app->listexpr_->accept(this);
}
void Skeleton::visitEString(EString *e_string)
{
/* Code For EString Goes Here */
visitString(e_string->string_);
}
void Skeleton::visitENewArray(ENewArray *e_new_array)
{
/* Code For ENewArray Goes Here */
e_new_array->type_->accept(this);
e_new_array->expr_->accept(this);
}
void Skeleton::visitENewClass(ENewClass *e_new_class)
{
/* Code For ENewClass Goes Here */
e_new_class->pident_->accept(this);
}
void Skeleton::visitEClsMmbr(EClsMmbr *e_cls_mmbr)
{
/* Code For EClsMmbr Goes Here */
e_cls_mmbr->expr_->accept(this);
e_cls_mmbr->pident_->accept(this);
}
void Skeleton::visitEClsMthd(EClsMthd *e_cls_mthd)
{
/* Code For EClsMthd Goes Here */
e_cls_mthd->expr_->accept(this);
e_cls_mthd->pident_->accept(this);
e_cls_mthd->listexpr_->accept(this);
}
void Skeleton::visitNull(Null *null)
{
/* Code For Null Goes Here */
}
void Skeleton::visitEIndexAcc(EIndexAcc *e_index_acc)
{
/* Code For EIndexAcc Goes Here */
e_index_acc->pident_->accept(this);
e_index_acc->expr_->accept(this);
}
void Skeleton::visitECast(ECast *e_cast)
{
/* Code For ECast Goes Here */
e_cast->pident_->accept(this);
e_cast->expr_->accept(this);
}
void Skeleton::visitNeg(Neg *neg)
{
/* Code For Neg Goes Here */
neg->expr_->accept(this);
}
void Skeleton::visitNot(Not *not_)
{
/* Code For Not Goes Here */
not_->expr_->accept(this);
}
void Skeleton::visitEMul(EMul *e_mul)
{
/* Code For EMul Goes Here */
e_mul->expr_1->accept(this);
e_mul->mulop_->accept(this);
e_mul->expr_2->accept(this);
}
void Skeleton::visitEAdd(EAdd *e_add)
{
/* Code For EAdd Goes Here */
e_add->expr_1->accept(this);
e_add->addop_->accept(this);
e_add->expr_2->accept(this);
}
void Skeleton::visitERel(ERel *e_rel)
{
/* Code For ERel Goes Here */
e_rel->expr_1->accept(this);
e_rel->relop_->accept(this);
e_rel->expr_2->accept(this);
}
void Skeleton::visitEAnd(EAnd *e_and)
{
/* Code For EAnd Goes Here */
e_and->expr_1->accept(this);
e_and->expr_2->accept(this);
}
void Skeleton::visitEOr(EOr *e_or)
{
/* Code For EOr Goes Here */
e_or->expr_1->accept(this);
e_or->expr_2->accept(this);
}
void Skeleton::visitPlus(Plus *plus)
{
/* Code For Plus Goes Here */
}
void Skeleton::visitMinus(Minus *minus)
{
/* Code For Minus Goes Here */
}
void Skeleton::visitTimes(Times *times)
{
/* Code For Times Goes Here */
}
void Skeleton::visitDiv(Div *div)
{
/* Code For Div Goes Here */
}
void Skeleton::visitMod(Mod *mod)
{
/* Code For Mod Goes Here */
}
void Skeleton::visitLTH(LTH *lth)
{
/* Code For LTH Goes Here */
}
void Skeleton::visitLE(LE *le)
{
/* Code For LE Goes Here */
}
void Skeleton::visitGTH(GTH *gth)
{
/* Code For GTH Goes Here */
}
void Skeleton::visitGE(GE *ge)
{
/* Code For GE Goes Here */
}
void Skeleton::visitEQU(EQU *equ)
{
/* Code For EQU Goes Here */
}
void Skeleton::visitNE(NE *ne)
{
/* Code For NE Goes Here */
}
void Skeleton::visitListTopDef(ListTopDef *list_top_def)
{
for (ListTopDef::iterator i = list_top_def->begin() ; i != list_top_def->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListArg(ListArg *list_arg)
{
for (ListArg::iterator i = list_arg->begin() ; i != list_arg->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListClassBlockDef(ListClassBlockDef *list_class_block_def)
{
for (ListClassBlockDef::iterator i = list_class_block_def->begin() ; i != list_class_block_def->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListStmt(ListStmt *list_stmt)
{
for (ListStmt::iterator i = list_stmt->begin() ; i != list_stmt->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListItem(ListItem *list_item)
{
for (ListItem::iterator i = list_item->begin() ; i != list_item->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListType(ListType *list_type)
{
for (ListType::iterator i = list_type->begin() ; i != list_type->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListExpr(ListExpr *list_expr)
{
for (ListExpr::iterator i = list_expr->begin() ; i != list_expr->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitInteger(Integer x)
{
/* Code for Integer Goes Here */
}
void Skeleton::visitChar(Char x)
{
/* Code for Char Goes Here */
}
void Skeleton::visitDouble(Double x)
{
/* Code for Double Goes Here */
}
void Skeleton::visitString(String x)
{
/* Code for String Goes Here */
}
void Skeleton::visitIdent(Ident x)
{
/* Code for Ident Goes Here */
}
#ifndef SKELETON_HEADER
#define SKELETON_HEADER
/* You might want to change the above name. */
#include "Absyn.h"
class Skeleton : public Visitor
{
public:
void visitProgram(Program *p);
void visitTopDef(TopDef *p);
void visitFunDef(FunDef *p);
void visitArg(Arg *p);
void visitClassDef(ClassDef *p);
void visitClassBlock(ClassBlock *p);
void visitClassBlockDef(ClassBlockDef *p);
void visitBlock(Block *p);
void visitStmt(Stmt *p);
void visitItem(Item *p);
void visitType(Type *p);
void visitExpr(Expr *p);
void visitAddOp(AddOp *p);
void visitMulOp(MulOp *p);
void visitRelOp(RelOp *p);
void visitProg(Prog *p);
void visitFnDef(FnDef *p);
void visitClDef(ClDef *p);
void visitFuncDef(FuncDef *p);
void visitAr(Ar *p);
void visitClassDefN(ClassDefN *p);
void visitClassDefE(ClassDefE *p);
void visitClassBl(ClassBl *p);
void visitClassMthd(ClassMthd *p);
void visitClassFld(ClassFld *p);
void visitBlk(Blk *p);
void visitEmpty(Empty *p);
void visitBStmt(BStmt *p);
void visitDecl(Decl *p);
void visitNoInit(NoInit *p);
void visitInit(Init *p);
void visitAss(Ass *p);
void visitTableAss(TableAss *p);
void visitTableIncr(TableIncr *p);
void visitTableDecr(TableDecr *p);
void visitIncr(Incr *p);
void visitDecr(Decr *p);
void visitRet(Ret *p);
void visitVRet(VRet *p);
void visitCond(Cond *p);
void visitCondElse(CondElse *p);
void visitWhile(While *p);
void visitSExp(SExp *p);
void visitForEach(ForEach *p);
void visitInt(Int *p);
void visitStr(Str *p);
void visitBool(Bool *p);
void visitVoid(Void *p);
void visitArray(Array *p);
void visitClassT(ClassT *p);
void visitFun(Fun *p);
void visitEVar(EVar *p);
void visitELitInt(ELitInt *p);
void visitELitTrue(ELitTrue *p);
void visitELitFalse(ELitFalse *p);
void visitEApp(EApp *p);
void visitEString(EString *p);
void visitENewArray(ENewArray *p);
void visitENewClass(ENewClass *p);
void visitEClsMmbr(EClsMmbr *p);
void visitEClsMthd(EClsMthd *p);
void visitNull(Null *p);
void visitEIndexAcc(EIndexAcc *p);
void visitECast(ECast *p);
void visitNeg(Neg *p);
void visitNot(Not *p);
void visitEMul(EMul *p);
void visitEAdd(EAdd *p);
void visitERel(ERel *p);
void visitEAnd(EAnd *p);
void visitEOr(EOr *p);
void visitPlus(Plus *p);
void visitMinus(Minus *p);
void visitTimes(Times *p);
void visitDiv(Div *p);
void visitMod(Mod *p);
void visitLTH(LTH *p);
void visitLE(LE *p);
void visitGTH(GTH *p);
void visitGE(GE *p);
void visitEQU(EQU *p);
void visitNE(NE *p);
void visitListTopDef(ListTopDef *p);
void visitListArg(ListArg *p);
void visitListClassBlockDef(ListClassBlockDef *p);
void visitListStmt(ListStmt *p);
void visitListItem(ListItem *p);
void visitListType(ListType *p);
void visitListExpr(ListExpr *p);
void visitPIdent(PIdent *p);
void visitInteger(Integer x);
void visitChar(Char x);
void visitDouble(Double x);
void visitString(String x);
void visitIdent(Ident x);
};
#endif
/*** Compiler Front-End Test automatically generated by the BNF Converter ***/
/* */
/* This test will parse a file, print the abstract syntax tree, and then */
/* pretty-print the result. */
/* */
/****************************************************************************/
#include <stdio.h>
#include <string.h>
#include "Parser.h"
#include "Printer.h"
#include "Absyn.h"
void usage() {
printf("usage: Call with one of the following argument combinations:\n");
printf("\t--help\t\tDisplay this help message.\n");
printf("\t(no arguments) Parse stdin verbosely.\n");
printf("\t(files)\t\tParse content of files verbosely.\n");
printf("\t-s (files)\tSilent mode. Parse content of files silently.\n");
}
int main(int argc, char ** argv)
{
FILE *input;
int quiet = 0;
char *filename = NULL;
if (argc > 1) {
if (strcmp(argv[1], "-s") == 0) {
quiet = 1;
if (argc > 2) {
filename = argv[2];
} else {
input = stdin;
}
} else {
filename = argv[1];
}
}
if (filename) {
input = fopen(filename, "r");
if (!input) {
usage();
exit(1);
}
} else input = stdin;
/* The default entry point is used. For other options see Parser.H */
Program *parse_tree = pProgram(input);
if (parse_tree)
{
printf("\nParse Successful!\n");
if (!quiet) {
printf("\n[Abstract Syntax]\n");
ShowAbsyn *s = new ShowAbsyn();
printf("%s\n\n", s->show(parse_tree));
printf("[Linearized Tree]\n");
PrintAbsyn *p = new PrintAbsyn();
printf("%s\n\n", p->print(parse_tree));
}
return 0;
}
return 1;
}
/*** BNFC-Generated Visitor Design Pattern Skeleton. ***/
/* This implements the common visitor design pattern.
Note that this method uses Visitor-traversal of lists, so
List->accept() does NOT traverse the list. This allows different
algorithms to use context information differently. */
#include "TypeCheck.h"
void Skeleton::visitProgram(Program *t) {} //abstract class
void Skeleton::visitTopDef(TopDef *t) {} //abstract class
void Skeleton::visitFunDef(FunDef *t) {} //abstract class
void Skeleton::visitArg(Arg *t) {} //abstract class
void Skeleton::visitClassDef(ClassDef *t) {} //abstract class
void Skeleton::visitClassBlock(ClassBlock *t) {} //abstract class
void Skeleton::visitClassBlockDef(ClassBlockDef *t) {} //abstract class
void Skeleton::visitBlock(Block *t) {} //abstract class
void Skeleton::visitStmt(Stmt *t) {} //abstract class
void Skeleton::visitItem(Item *t) {} //abstract class
void Skeleton::visitType(Type *t) {} //abstract class
void Skeleton::visitExpr(Expr *t) {} //abstract class
void Skeleton::visitAddOp(AddOp *t) {} //abstract class
void Skeleton::visitMulOp(MulOp *t) {} //abstract class
void Skeleton::visitRelOp(RelOp *t) {} //abstract class
void Skeleton::visitPIdent(PIdent *p_ident)
{
/* Code For PIdent Goes Here */
visitString(p_ident->string_);
visitInteger(p_ident->integer_);
}
void Skeleton::visitProg(Prog *prog)
{
/* Code For Prog Goes Here */
prog->listtopdef_->accept(this);
}
void Skeleton::visitFnDef(FnDef *fn_def)
{
/* Code For FnDef Goes Here */
fn_def->fundef_->accept(this);
}
void Skeleton::visitClDef(ClDef *cl_def)
{
/* Code For ClDef Goes Here */
cl_def->classdef_->accept(this);
}
void Skeleton::visitFuncDef(FuncDef *func_def)
{
/* Code For FuncDef Goes Here */
func_def->type_->accept(this);
func_def->pident_->accept(this);
func_def->listarg_->accept(this);
func_def->block_->accept(this);
}
void Skeleton::visitAr(Ar *ar)
{
/* Code For Ar Goes Here */
ar->type_->accept(this);
ar->pident_->accept(this);
}
void Skeleton::visitClassDefN(ClassDefN *class_def_n)
{
/* Code For ClassDefN Goes Here */
class_def_n->pident_->accept(this);
class_def_n->classblock_->accept(this);
}
void Skeleton::visitClassDefE(ClassDefE *class_def_e)
{
/* Code For ClassDefE Goes Here */
class_def_e->pident_1->accept(this);
class_def_e->pident_2->accept(this);
class_def_e->classblock_->accept(this);
}
void Skeleton::visitClassBl(ClassBl *class_bl)
{
/* Code For ClassBl Goes Here */
class_bl->listclassblockdef_->accept(this);
}
void Skeleton::visitClassMthd(ClassMthd *class_mthd)
{
/* Code For ClassMthd Goes Here */
class_mthd->fundef_->accept(this);
}
void Skeleton::visitClassFld(ClassFld *class_fld)
{
/* Code For ClassFld Goes Here */
class_fld->type_->accept(this);
class_fld->listitem_->accept(this);
}
void Skeleton::visitBlk(Blk *blk)
{
/* Code For Blk Goes Here */
blk->liststmt_->accept(this);
}
void Skeleton::visitEmpty(Empty *empty)
{
/* Code For Empty Goes Here */
}
void Skeleton::visitBStmt(BStmt *b_stmt)
{
/* Code For BStmt Goes Here */
b_stmt->block_->accept(this);
}
void Skeleton::visitDecl(Decl *decl)
{
/* Code For Decl Goes Here */
decl->type_->accept(this);
decl->listitem_->accept(this);
}
void Skeleton::visitAss(Ass *ass)
{
/* Code For Ass Goes Here */
ass->expr_1->accept(this);
ass->expr_2->accept(this);
}
void Skeleton::visitTableAss(TableAss *table_ass)
{
/* Code For TableAss Goes Here */
table_ass->pident_->accept(this);
table_ass->expr_1->accept(this);
table_ass->expr_2->accept(this);
}
void Skeleton::visitTableIncr(TableIncr *table_incr)
{
/* Code For TableIncr Goes Here */
table_incr->pident_->accept(this);
table_incr->expr_->accept(this);
}
void Skeleton::visitTableDecr(TableDecr *table_decr)
{
/* Code For TableDecr Goes Here */
table_decr->pident_->accept(this);
table_decr->expr_->accept(this);
}
void Skeleton::visitIncr(Incr *incr)
{
/* Code For Incr Goes Here */
incr->pident_->accept(this);
}
void Skeleton::visitDecr(Decr *decr)
{
/* Code For Decr Goes Here */
decr->pident_->accept(this);
}
void Skeleton::visitRet(Ret *ret)
{
/* Code For Ret Goes Here */
ret->expr_->accept(this);
}
void Skeleton::visitVRet(VRet *v_ret)
{
/* Code For VRet Goes Here */
}
void Skeleton::visitCond(Cond *cond)
{
/* Code For Cond Goes Here */
cond->expr_->accept(this);
cond->stmt_->accept(this);
}
void Skeleton::visitCondElse(CondElse *cond_else)
{
/* Code For CondElse Goes Here */
cond_else->expr_->accept(this);
cond_else->stmt_1->accept(this);
cond_else->stmt_2->accept(this);
}
void Skeleton::visitWhile(While *while_)
{
/* Code For While Goes Here */
while_->expr_->accept(this);
while_->stmt_->accept(this);
}
void Skeleton::visitSExp(SExp *s_exp)
{
/* Code For SExp Goes Here */
s_exp->expr_->accept(this);
}
void Skeleton::visitForEach(ForEach *for_each)
{
/* Code For ForEach Goes Here */
for_each->type_->accept(this);
for_each->pident_->accept(this);
for_each->expr_->accept(this);
for_each->stmt_->accept(this);
}
void Skeleton::visitNoInit(NoInit *no_init)
{
/* Code For NoInit Goes Here */
no_init->pident_->accept(this);
}
void Skeleton::visitInit(Init *init)
{
/* Code For Init Goes Here */
init->pident_->accept(this);
init->expr_->accept(this);
}
void Skeleton::visitInt(Int *int_)
{
/* Code For Int Goes Here */
}
void Skeleton::visitStr(Str *str)
{
/* Code For Str Goes Here */
}
void Skeleton::visitBool(Bool *bool_)
{
/* Code For Bool Goes Here */
}
void Skeleton::visitVoid(Void *void_)
{
/* Code For Void Goes Here */
}
void Skeleton::visitArray(Array *array)
{
/* Code For Array Goes Here */
array->type_->accept(this);
}
void Skeleton::visitClassT(ClassT *class_t)
{
/* Code For ClassT Goes Here */
class_t->pident_->accept(this);
}
void Skeleton::visitFun(Fun *fun)
{
/* Code For Fun Goes Here */
fun->type_->accept(this);
fun->listtype_->accept(this);
}
void Skeleton::visitEVar(EVar *e_var)
{
/* Code For EVar Goes Here */
e_var->pident_->accept(this);
}
void Skeleton::visitELitInt(ELitInt *e_lit_int)
{
/* Code For ELitInt Goes Here */
visitInteger(e_lit_int->integer_);
}
void Skeleton::visitELitTrue(ELitTrue *e_lit_true)
{
/* Code For ELitTrue Goes Here */
}
void Skeleton::visitELitFalse(ELitFalse *e_lit_false)
{
/* Code For ELitFalse Goes Here */
}
void Skeleton::visitEApp(EApp *e_app)
{
/* Code For EApp Goes Here */
e_app->pident_->accept(this);
e_app->listexpr_->accept(this);
}
void Skeleton::visitEString(EString *e_string)
{
/* Code For EString Goes Here */
visitString(e_string->string_);
}
void Skeleton::visitENewArray(ENewArray *e_new_array)
{
/* Code For ENewArray Goes Here */
e_new_array->type_->accept(this);
e_new_array->expr_->accept(this);
}
void Skeleton::visitENewClass(ENewClass *e_new_class)
{
/* Code For ENewClass Goes Here */
e_new_class->pident_->accept(this);
}
void Skeleton::visitEClsMmbr(EClsMmbr *e_cls_mmbr)
{
/* Code For EClsMmbr Goes Here */
e_cls_mmbr->expr_->accept(this);
e_cls_mmbr->pident_->accept(this);
}
void Skeleton::visitEClsMthd(EClsMthd *e_cls_mthd)
{
/* Code For EClsMthd Goes Here */
e_cls_mthd->expr_->accept(this);
e_cls_mthd->pident_->accept(this);
e_cls_mthd->listexpr_->accept(this);
}
void Skeleton::visitNull(Null *null)
{
/* Code For Null Goes Here */
}
void Skeleton::visitEIndexAcc(EIndexAcc *e_index_acc)
{
/* Code For EIndexAcc Goes Here */
e_index_acc->pident_->accept(this);
e_index_acc->expr_->accept(this);
}
void Skeleton::visitECast(ECast *e_cast)
{
/* Code For ECast Goes Here */
e_cast->pident_->accept(this);
e_cast->expr_->accept(this);
}
void Skeleton::visitNeg(Neg *neg)
{
/* Code For Neg Goes Here */
neg->expr_->accept(this);
}
void Skeleton::visitNot(Not *not_)
{
/* Code For Not Goes Here */
not_->expr_->accept(this);
}
void Skeleton::visitEMul(EMul *e_mul)
{
/* Code For EMul Goes Here */
e_mul->expr_1->accept(this);
e_mul->mulop_->accept(this);
e_mul->expr_2->accept(this);
}
void Skeleton::visitEAdd(EAdd *e_add)
{
/* Code For EAdd Goes Here */
e_add->expr_1->accept(this);
e_add->addop_->accept(this);
e_add->expr_2->accept(this);
}
void Skeleton::visitERel(ERel *e_rel)
{
/* Code For ERel Goes Here */
e_rel->expr_1->accept(this);
e_rel->relop_->accept(this);
e_rel->expr_2->accept(this);
}
void Skeleton::visitEAnd(EAnd *e_and)
{
/* Code For EAnd Goes Here */
e_and->expr_1->accept(this);
e_and->expr_2->accept(this);
}
void Skeleton::visitEOr(EOr *e_or)
{
/* Code For EOr Goes Here */
e_or->expr_1->accept(this);
e_or->expr_2->accept(this);
}
void Skeleton::visitPlus(Plus *plus)
{
/* Code For Plus Goes Here */
}
void Skeleton::visitMinus(Minus *minus)
{
/* Code For Minus Goes Here */
}
void Skeleton::visitTimes(Times *times)
{
/* Code For Times Goes Here */
}
void Skeleton::visitDiv(Div *div)
{
/* Code For Div Goes Here */
}
void Skeleton::visitMod(Mod *mod)
{
/* Code For Mod Goes Here */
}
void Skeleton::visitLTH(LTH *lth)
{
/* Code For LTH Goes Here */
}
void Skeleton::visitLE(LE *le)
{
/* Code For LE Goes Here */
}
void Skeleton::visitGTH(GTH *gth)
{
/* Code For GTH Goes Here */
}
void Skeleton::visitGE(GE *ge)
{
/* Code For GE Goes Here */
}
void Skeleton::visitEQU(EQU *equ)
{
/* Code For EQU Goes Here */
}
void Skeleton::visitNE(NE *ne)
{
/* Code For NE Goes Here */
}
void Skeleton::visitListTopDef(ListTopDef *list_top_def)
{
for (ListTopDef::iterator i = list_top_def->begin() ; i != list_top_def->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListArg(ListArg *list_arg)
{
for (ListArg::iterator i = list_arg->begin() ; i != list_arg->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListClassBlockDef(ListClassBlockDef *list_class_block_def)
{
for (ListClassBlockDef::iterator i = list_class_block_def->begin() ; i != list_class_block_def->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListStmt(ListStmt *list_stmt)
{
for (ListStmt::iterator i = list_stmt->begin() ; i != list_stmt->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListItem(ListItem *list_item)
{
for (ListItem::iterator i = list_item->begin() ; i != list_item->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListType(ListType *list_type)
{
for (ListType::iterator i = list_type->begin() ; i != list_type->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListExpr(ListExpr *list_expr)
{
for (ListExpr::iterator i = list_expr->begin() ; i != list_expr->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitInteger(Integer x)
{
/* Code for Integer Goes Here */
}
void Skeleton::visitChar(Char x)
{
/* Code for Char Goes Here */
}
void Skeleton::visitDouble(Double x)
{
/* Code for Double Goes Here */
}
void Skeleton::visitString(String x)
{
/* Code for String Goes Here */
}
void Skeleton::visitIdent(Ident x)
{
/* Code for Ident Goes Here */
}
#ifndef TYPECHECK_HEADER
#define TYPECHECK_HEADER
/* You might want to change the above name. */
#include "Absyn.h"
class Skeleton : public Visitor
{
public:
void visitProgram(Program *p);
void visitTopDef(TopDef *p);
void visitFunDef(FunDef *p);
void visitArg(Arg *p);
void visitClassDef(ClassDef *p);
void visitClassBlock(ClassBlock *p);
void visitClassBlockDef(ClassBlockDef *p);
void visitBlock(Block *p);
void visitStmt(Stmt *p);
void visitItem(Item *p);
void visitType(Type *p);
void visitExpr(Expr *p);
void visitAddOp(AddOp *p);
void visitMulOp(MulOp *p);
void visitRelOp(RelOp *p);
void visitProg(Prog *p);
void visitFnDef(FnDef *p);
void visitClDef(ClDef *p);
void visitFuncDef(FuncDef *p);
void visitAr(Ar *p);
void visitClassDefN(ClassDefN *p);
void visitClassDefE(ClassDefE *p);
void visitClassBl(ClassBl *p);
void visitClassMthd(ClassMthd *p);
void visitClassFld(ClassFld *p);
void visitBlk(Blk *p);
void visitEmpty(Empty *p);
void visitBStmt(BStmt *p);
void visitDecl(Decl *p);
void visitNoInit(NoInit *p);
void visitInit(Init *p);
void visitAss(Ass *p);
void visitTableAss(TableAss *p);
void visitTableIncr(TableIncr *p);
void visitTableDecr(TableDecr *p);
void visitIncr(Incr *p);
void visitDecr(Decr *p);
void visitRet(Ret *p);
void visitVRet(VRet *p);
void visitCond(Cond *p);
void visitCondElse(CondElse *p);
void visitWhile(While *p);
void visitSExp(SExp *p);
void visitForEach(ForEach *p);
void visitInt(Int *p);
void visitStr(Str *p);
void visitBool(Bool *p);
void visitVoid(Void *p);
void visitArray(Array *p);
void visitClassT(ClassT *p);
void visitFun(Fun *p);
void visitEVar(EVar *p);
void visitELitInt(ELitInt *p);
void visitELitTrue(ELitTrue *p);
void visitELitFalse(ELitFalse *p);
void visitEApp(EApp *p);
void visitEString(EString *p);
void visitENewArray(ENewArray *p);
void visitENewClass(ENewClass *p);
void visitEClsMmbr(EClsMmbr *p);
void visitEClsMthd(EClsMthd *p);
void visitNull(Null *p);
void visitEIndexAcc(EIndexAcc *p);
void visitECast(ECast *p);
void visitNeg(Neg *p);
void visitNot(Not *p);
void visitEMul(EMul *p);
void visitEAdd(EAdd *p);
void visitERel(ERel *p);
void visitEAnd(EAnd *p);
void visitEOr(EOr *p);
void visitPlus(Plus *p);
void visitMinus(Minus *p);
void visitTimes(Times *p);
void visitDiv(Div *p);
void visitMod(Mod *p);
void visitLTH(LTH *p);
void visitLE(LE *p);
void visitGTH(GTH *p);
void visitGE(GE *p);
void visitEQU(EQU *p);
void visitNE(NE *p);
void visitListTopDef(ListTopDef *p);
void visitListArg(ListArg *p);
void visitListClassBlockDef(ListClassBlockDef *p);
void visitListStmt(ListStmt *p);
void visitListItem(ListItem *p);
void visitListType(ListType *p);
void visitListExpr(ListExpr *p);
void visitPIdent(PIdent *p);
void visitInteger(Integer x);
void visitChar(Char x);
void visitDouble(Double x);
void visitString(String x);
void visitIdent(Ident x);
};
#endif
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