Commit 37c6faa0 authored by zygzagZ's avatar zygzagZ

Separate typedefs

parent e9518825
...@@ -1313,94 +1313,50 @@ ForEach *ForEach::clone() const ...@@ -1313,94 +1313,50 @@ ForEach *ForEach::clone() const
/******************** 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::Init(PIdent *p1, Expr *p2) Item::Item(PIdent *p1, Expr *p2)
{ {
pident_ = p1; pident_ = p1;
expr_ = p2; expr_ = p2;
} }
Init::Init(const Init & other) Item::Item(const Item & other)
{ {
pident_ = other.pident_->clone(); pident_ = other.pident_->clone();
expr_ = other.expr_->clone(); expr_ = other.expr_->clone();
} }
Init &Init::operator=(const Init & other) Item &Item::operator=(const Item & other)
{ {
Init tmp(other); Item tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;
} }
void Init::swap(Init & other) void Item::swap(Item & other)
{ {
std::swap(pident_, other.pident_); std::swap(pident_, other.pident_);
std::swap(expr_, other.expr_); std::swap(expr_, other.expr_);
} }
Init::~Init() Item::~Item()
{ {
delete(pident_); delete(pident_);
delete(expr_); delete(expr_);
} }
void Init::accept(Visitor *v) void Item::accept(Visitor *v)
{ {
v->visitInit(this); v->visitItem(this);
} }
Init *Init::clone() const Item *Item::clone() const
{ {
return new Init(*this); return new Item(*this);
} }
......
...@@ -20,101 +20,7 @@ typedef std::string Ident; ...@@ -20,101 +20,7 @@ typedef std::string Ident;
/******************** Forward Declarations ********************/ /******************** Forward Declarations ********************/
class Program; #include "TypeDefs.h"
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;
class Binding;
class VarInfo;
class FunctionInfo;
class ClassInfo;
/******************** Visitor Interfaces ********************/ /******************** Visitor Interfaces ********************/
...@@ -304,8 +210,16 @@ public: ...@@ -304,8 +210,16 @@ public:
class Item : public Visitable class Item : public Visitable
{ {
public: public:
virtual Item *clone() const = 0; PIdent *pident_;
Expr *expr_;
Item(const Item &);
Item &operator=(const Item &);
Item(PIdent *p1, Expr *p2 = nullptr);
~Item();
virtual void accept(Visitor *v);
virtual Item *clone() const;
void swap(Item &);
}; };
class Type : public Visitable class Type : public Visitable
...@@ -363,6 +277,8 @@ public: ...@@ -363,6 +277,8 @@ public:
virtual void accept(Visitor *v); virtual void accept(Visitor *v);
virtual PIdent *clone() const; virtual PIdent *clone() const;
void swap(PIdent &); void swap(PIdent &);
operator std::string() const { return string_; }
}; };
class Prog : public Program class Prog : public Program
...@@ -770,34 +686,6 @@ public: ...@@ -770,34 +686,6 @@ public:
void swap(ForEach &); 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 class Int : public Type
{ {
......
...@@ -10,16 +10,6 @@ FunctionInfo::FunctionInfo(FuncDef *expr, ClassInfoPtr klass) ...@@ -10,16 +10,6 @@ FunctionInfo::FunctionInfo(FuncDef *expr, ClassInfoPtr klass)
} }
ClassInfo::ClassInfo(PIdent *ident, ClassInfoPtr parent /*= nullptr*/)
: VarInfo(ident),
parent(parent),
functions(parent ? parent->functions : nullptr),
variables(parent ? parent->variables : nullptr)
{
};
Binding::Binding(shared_ptr<Binding> parent) Binding::Binding(shared_ptr<Binding> parent)
: variables(parent->variables), : variables(parent->variables),
parent(parent) parent(parent)
...@@ -28,6 +18,15 @@ Binding::Binding(shared_ptr<Binding> parent) ...@@ -28,6 +18,15 @@ Binding::Binding(shared_ptr<Binding> parent)
} }
ClassInfo::ClassInfo(PIdent *ident, ClassInfoPtr parent /*= nullptr*/)
: VarInfo(ident),
Binding(parent),
functions(parent ? parent->functions : nullptr)
{
};
Scope::Scope() Scope::Scope()
: currentClass(nullptr) : currentClass(nullptr)
{ {
......
...@@ -5,24 +5,15 @@ ...@@ -5,24 +5,15 @@
#include <memory> #include <memory>
#include <set> #include <set>
using namespace std; using namespace std;
class VarInfo;
class FunctionInfo;
class ClassInfo;
class Binding;
class Type;
using VarInfoPtr = shared_ptr<VarInfo>;
using FunctionInfoPtr = shared_ptr<FunctionInfo>;
using ClassInfoPtr = shared_ptr<ClassInfo>;
using BindingPtr = shared_ptr<Binding>;
#include "InfoList.h" #include "InfoList.h"
class VarInfo { class VarInfo {
public: public:
VarInfo(string n, int l = -1, Type* type = NULL) : name(n), type(type), lineLocation(l) {} VarInfo(PIdent* ident, Type* type = NULL) : ident(ident), name(ident->string_), type(type), lineLocation(ident->integer_) {}
VarInfo(PIdent* ident, Type* type = NULL) : VarInfo(ident->string_, ident->integer_, type) {}
VarInfo(Ar* arg) : VarInfo(arg->pident_, arg->type_) {} VarInfo(Ar* arg) : VarInfo(arg->pident_, arg->type_) {}
PIdent *ident;
string name; string name;
Type *type; Type *type;
int lineLocation; int lineLocation;
...@@ -38,28 +29,30 @@ public: ...@@ -38,28 +29,30 @@ public:
Block * block; Block * block;
vector<VarInfoPtr> arguments; vector<VarInfoPtr> arguments;
weak_ptr<ClassInfo> klass; weak_ptr<ClassInfo> klass;
weak_ptr<Binding> binding;
FunctionInfo(FuncDef *expr, ClassInfoPtr klass = nullptr); FunctionInfo(FuncDef *expr, ClassInfoPtr klass = nullptr);
FunctionInfo(PIdent *ident, ClassInfoPtr klass = nullptr) : VarInfo(ident), block(NULL), klass(klass) {}; FunctionInfo(PIdent *ident, ClassInfoPtr klass = nullptr) : VarInfo(ident), block(NULL), klass(klass) {};
}; };
class ClassInfo : public VarInfo
{ class Binding {
ClassInfoPtr parent;
public: public:
InfoList<FunctionInfo> functions;
InfoList<VarInfo> variables; InfoList<VarInfo> variables;
BindingPtr parent;
Binding(BindingPtr parent);
ClassInfo(PIdent *ident, ClassInfoPtr parent = nullptr); BindingPtr getParent() const { return parent; };
ClassInfoPtr getParent() const { return parent; };
}; };
class ClassInfo : public VarInfo, public Binding
{
public:
InfoList<FunctionInfo> functions;
class Binding { ClassInfo(PIdent *ident, ClassInfoPtr parent = nullptr);
InfoList<VarInfo> variables;
BindingPtr parent; ClassInfoPtr getParent() const { return static_pointer_cast<ClassInfo>(parent); };
Binding(BindingPtr parent);
}; };
...@@ -67,6 +60,7 @@ class Scope { ...@@ -67,6 +60,7 @@ class Scope {
public: public:
InfoList<ClassInfo> classes; InfoList<ClassInfo> classes;
InfoList<FunctionInfo> functions; InfoList<FunctionInfo> functions;
BindingPtr currentBinding;
ClassInfoPtr currentClass; ClassInfoPtr currentClass;
FunctionInfoPtr currentFunction; FunctionInfoPtr currentFunction;
Scope(); Scope();
......
#ifndef INFOLIST_HEADER
#define INFOLIST_HEADER
#include "Info.h" #include "Info.h"
#include "ParseError.h"
#include "TypeDefs.h"
template<typename T> template<typename T>
struct Compare struct Compare
{ {
using is_transparent = void; using is_transparent = void;
bool operator() (const T& a, const T& b) const { return a->name < b->name; }
bool operator() (const T& a, const T& b) const { bool operator() (const T& a, const string &b) const { return a->name < b; }
return a->name < b->name; bool operator() (const string &a, const T& b) const { return a < b->name; }
} // bool operator() (const T& a, const PIdent *b) const { return a->name < b->string_; }
// bool operator() (const PIdent *a, const T& b) const { return a->string_ < b->name; }
bool operator() (const T& a, const string &b) const {
return a->name < b;
}
bool operator() (const string &a, const T& b) const {
return a < b->name;
}
}; };
...@@ -26,9 +24,11 @@ class InfoList : public set<TPtr, Compare<TPtr>> { ...@@ -26,9 +24,11 @@ class InfoList : public set<TPtr, Compare<TPtr>> {
public: public:
InfoList<T> *parent; InfoList<T> *parent;
InfoList(InfoList<T> *parent = nullptr) : parent(parent) {}; InfoList(InfoList<T> *parent = nullptr) : parent(parent) {};
TPtr operator[](string name) const { TPtr operator[](PIdent *ident) const {
TPtr ret = local(name); TPtr ret = local(ident->string_);
return ret ? ret : parent ? (*parent)[name] : nullptr; if (ret) return ret;
if (parent) return (*parent)[ident];
throw UndefinedError(ident);
} }
TPtr local(string name) const { TPtr local(string name) const {
...@@ -37,7 +37,10 @@ public: ...@@ -37,7 +37,10 @@ public:
} }
void add(TPtr obj) { void add(TPtr obj) {
this->emplace(obj); auto ret = this->emplace(obj);
if (!ret.second) {
throw RedefinedError(obj->ident, *ret.first);
}
} }
InfoList<T>& operator<<(TPtr obj) { InfoList<T>& operator<<(TPtr obj) {
...@@ -45,3 +48,5 @@ public: ...@@ -45,3 +48,5 @@ public:
return *this; return *this;
} }
}; };
#endif
CC=g++ CC=g++
CCFLAGS=-g -W -Wall -O3 -std=c++2a -Wno-unused-parameter CCFLAGS=-g -W -Wall -O0 -std=c++2a -Wno-unused-parameter
FLEX=flex FLEX=flex
FLEX_OPTS=-PGrammar FLEX_OPTS=-PGrammar
......
#include "ParseError.h" #include "ParseError.h"
#include "Info.h" #include "Info.h"
#include "Printer.h" #include "Printer.h"
#include <sstream> #include <sstream>
......
#ifndef ERROR_HEADER #ifndef PARSEERROR_HEADER
#define ERROR_HEADER #define PARSEERROR_HEADER
#include "Absyn.h" #include "TypeDefs.h"
#include "Info.h"
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <memory> #include <memory>
#include <vector>
using namespace std; using namespace std;
// class VarInfo;
// using VarInfoPtr = shared_ptr<VarInfo>;
class ParseError : std::runtime_error { class ParseError : std::runtime_error {
protected: protected:
string msg; string msg;
......
...@@ -8,19 +8,14 @@ void TypeCheck::visitFunDef(FunDef *t) {} //abstract class ...@@ -8,19 +8,14 @@ void TypeCheck::visitFunDef(FunDef *t) {} //abstract class
void TypeCheck::visitArg(Arg *t) {} //abstract class void TypeCheck::visitArg(Arg *t) {} //abstract class
void TypeCheck::visitClassDef(ClassDef *t) { void TypeCheck::visitClassDef(ClassDef *t) {
const string name = t->getName()->string_; const string name = t->getName()->string_;
ClassInfoPtr c = scope.classes[name];
if (c) {
throw RedefinedError(t->getName(), c);
}
ClassInfoPtr parent = NULL; ClassInfoPtr parent = NULL;
if (t->getParent()) { if (t->getParent()) {
const string parentName = t->getParent()->string_; parent = scope.classes[t->getParent()];
parent = scope.classes[parentName];
if (!parent) { if (!parent) {
throw UndefinedError(t->getParent()); throw UndefinedError(t->getParent());
} }
} }
c = make_shared<ClassInfo>(t->getName(), parent); auto c = make_shared<ClassInfo>(t->getName(), parent);
scope.classes << c; scope.classes << c;
scope.currentClass = c; scope.currentClass = c;
...@@ -28,9 +23,6 @@ void TypeCheck::visitClassDef(ClassDef *t) { ...@@ -28,9 +23,6 @@ void TypeCheck::visitClassDef(ClassDef *t) {
scope.currentClass = NULL; scope.currentClass = NULL;
} }
void TypeCheck::visitClassBlock(ClassBlock *t) {} //abstract class
void TypeCheck::visitClassBlockDef(ClassBlockDef *t) {} //abstract class
void TypeCheck::visitBlock(Block *t) {} //abstract class
void TypeCheck::visitStmt(Stmt *t) {} //abstract class void TypeCheck::visitStmt(Stmt *t) {} //abstract class
void TypeCheck::visitItem(Item *t) {} //abstract class void TypeCheck::visitItem(Item *t) {} //abstract class
void TypeCheck::visitType(Type *t) {} //abstract class void TypeCheck::visitType(Type *t) {} //abstract class
...@@ -41,11 +33,8 @@ void TypeCheck::visitRelOp(RelOp *t) {} //abstract class ...@@ -41,11 +33,8 @@ void TypeCheck::visitRelOp(RelOp *t) {} //abstract class
void TypeCheck::visitPIdent(PIdent *p_ident) void TypeCheck::visitPIdent(PIdent *p_ident)
{ {
/* Code For PIdent Goes Here */
visitString(p_ident->string_); visitString(p_ident->string_);
visitInteger(p_ident->integer_); visitInteger(p_ident->integer_);
} }
void TypeCheck::visitProg(Prog *prog) void TypeCheck::visitProg(Prog *prog)
...@@ -74,13 +63,7 @@ void TypeCheck::visitClDef(ClDef *cl_def) ...@@ -74,13 +63,7 @@ void TypeCheck::visitClDef(ClDef *cl_def)
void TypeCheck::visitFuncDef(FuncDef *def) void TypeCheck::visitFuncDef(FuncDef *def)
{ {
const string name = def->pident_->string_; FunctionInfoPtr f = make_shared<FunctionInfo>(def->pident_, scope.currentClass);
FunctionInfoPtr f = scope.functions[name];
if (f) {
throw RedefinedError(def->pident_, f);
}
f = make_shared<FunctionInfo>(def->pident_, scope.currentClass);
f->block = def->block_; f->block = def->block_;
auto &targetVector = scope.currentClass ? scope.currentClass->functions : scope.functions; auto &targetVector = scope.currentClass ? scope.currentClass->functions : scope.functions;
...@@ -133,34 +116,33 @@ void TypeCheck::visitClassFld(ClassFld *class_fld) ...@@ -133,34 +116,33 @@ void TypeCheck::visitClassFld(ClassFld *class_fld)
void TypeCheck::visitBlk(Blk *blk) void TypeCheck::visitBlk(Blk *blk)
{ {
/* Code For Blk Goes Here */ BindingPtr binding = blk->binding.lock();
if (!binding) {
blk->liststmt_->accept(this); binding = make_shared<Binding>(scope.currentBinding);
blk->binding = binding;
} }
void TypeCheck::visitEmpty(Empty *empty) scope.currentBinding = binding;
{
/* Code For Empty Goes Here */
blk->liststmt_->accept(this);
scope.currentBinding = binding->getParent();
} }
void TypeCheck::visitBStmt(BStmt *b_stmt) void TypeCheck::visitBStmt(BStmt *b_stmt)
{ {
/* Code For BStmt Goes Here */
b_stmt->block_->accept(this); b_stmt->block_->accept(this);
} }
void TypeCheck::visitDecl(Decl *decl) void TypeCheck::visitDecl(Decl *decl)
{ {
/* Code For Decl Goes Here */ /* Code For Decl Goes Here */
decl->type_->accept(this); decl->type_->accept(this);
decl->listitem_->accept(this);
for (auto el : *decl->listitem_) {
el->pident_->accept(this);
el->expr_->accept(this);
}
} }
void TypeCheck::visitAss(Ass *ass) void TypeCheck::visitAss(Ass *ass)
...@@ -278,23 +260,6 @@ void TypeCheck::visitForEach(ForEach *for_each) ...@@ -278,23 +260,6 @@ void TypeCheck::visitForEach(ForEach *for_each)
} }
void TypeCheck::visitNoInit(NoInit *no_init)
{
/* Code For NoInit Goes Here */
no_init->pident_->accept(this);
}
void TypeCheck::visitInit(Init *init)
{
/* Code For Init Goes Here */
init->pident_->accept(this);
init->expr_->accept(this);
}
void TypeCheck::visitInt(Int *int_) void TypeCheck::visitInt(Int *int_)
{ {
/* Code For Int Goes Here */ /* Code For Int Goes Here */
...@@ -606,37 +571,16 @@ void TypeCheck::visitInteger(Integer x) ...@@ -606,37 +571,16 @@ void TypeCheck::visitInteger(Integer x)
/* Code for Integer Goes Here */ /* Code for Integer Goes Here */
} }
void TypeCheck::visitChar(Char x)
{
/* Code for Char Goes Here */
}
void TypeCheck::visitDouble(Double x)
{
/* Code for Double Goes Here */
}
void TypeCheck::visitString(String x) void TypeCheck::visitString(String x)
{ {
/* Code for String Goes Here */ /* Code for String Goes Here */
} }
void TypeCheck::visitIdent(Ident x)
{
/* Code for Ident Goes Here */
}
TypeCheck::TypeCheck() TypeCheck::TypeCheck()
: state(initialized) : state(initialized)
{ {
} }
void TypeCheck::check(Visitable *v) void TypeCheck::check(Visitable *v)
{ {
if (state != State::initialized) { if (state != State::initialized) {
...@@ -646,9 +590,13 @@ void TypeCheck::check(Visitable *v) ...@@ -646,9 +590,13 @@ void TypeCheck::check(Visitable *v)
v->accept(this); v->accept(this);
for (auto c : scope.classes) { for (auto c : scope.classes) {
for (auto f : c->functions) { scope.currentClass = c;
for (auto f : c->functions) {
checkFunction(f);
} }
scope.currentClass = nullptr;
} }
} }
...@@ -656,6 +604,13 @@ void TypeCheck::checkFunction(FunctionInfoPtr f) ...@@ -656,6 +604,13 @@ void TypeCheck::checkFunction(FunctionInfoPtr f)
{ {
scope.currentFunction = f; scope.currentFunction = f;
BindingPtr binding = make_shared<Binding>(nullptr);
f->binding = binding;
for (auto arg : f->arguments) {
binding->variables << arg;
}
f->block->accept(this); f->block->accept(this);
scope.currentFunction = nullptr; scope.currentFunction = nullptr;
......
...@@ -28,11 +28,7 @@ protected: ...@@ -28,11 +28,7 @@ protected:
void visitFunDef(FunDef *p); void visitFunDef(FunDef *p);
void visitArg(Arg *p); void visitArg(Arg *p);
void visitClassDef(ClassDef *p); void visitClassDef(ClassDef *p);
void visitClassBlock(ClassBlock *p);
void visitClassBlockDef(ClassBlockDef *p);
void visitBlock(Block *p);
void visitStmt(Stmt *p); void visitStmt(Stmt *p);
void visitItem(Item *p);
void visitType(Type *p); void visitType(Type *p);
void visitExpr(Expr *p); void visitExpr(Expr *p);
void visitAddOp(AddOp *p); void visitAddOp(AddOp *p);
...@@ -49,11 +45,8 @@ protected: ...@@ -49,11 +45,8 @@ protected:
void visitClassMthd(ClassMthd *p); void visitClassMthd(ClassMthd *p);
void visitClassFld(ClassFld *p); void visitClassFld(ClassFld *p);
void visitBlk(Blk *p); void visitBlk(Blk *p);
void visitEmpty(Empty *p);
void visitBStmt(BStmt *p); void visitBStmt(BStmt *p);
void visitDecl(Decl *p); void visitDecl(Decl *p);
void visitNoInit(NoInit *p);
void visitInit(Init *p);
void visitAss(Ass *p); void visitAss(Ass *p);
void visitTableAss(TableAss *p); void visitTableAss(TableAss *p);
void visitTableIncr(TableIncr *p); void visitTableIncr(TableIncr *p);
...@@ -94,6 +87,33 @@ protected: ...@@ -94,6 +87,33 @@ protected:
void visitERel(ERel *p); void visitERel(ERel *p);
void visitEAnd(EAnd *p); void visitEAnd(EAnd *p);
void visitEOr(EOr *p); void visitEOr(EOr *p);
void 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 visitString(String x);
// abstract
// topdefs
void visitBlock(Block *t) {};
void visitClassBlock(ClassBlock *p) {};
void visitClassBlockDef(ClassBlockDef *p) {};
void visitItem(Item *p);
// stmts
void visitEmpty(Empty *p) {};
void visitNoInit(NoInit *p) {};
void visitInit(Init *p) {};
// exprs
void visitPlus(Plus *p) {}; void visitPlus(Plus *p) {};
void visitMinus(Minus *p) {}; void visitMinus(Minus *p) {};
void visitTimes(Times *p) {}; void visitTimes(Times *p) {};
...@@ -105,20 +125,10 @@ protected: ...@@ -105,20 +125,10 @@ protected:
void visitGE(GE *p) {}; void visitGE(GE *p) {};
void visitEQU(EQU *p) {}; void visitEQU(EQU *p) {};
void visitNE(NE *p) {}; void visitNE(NE *p) {};
void visitListTopDef(ListTopDef *p);
void 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); // terminals
void visitChar(Char x); void visitDouble(Double x) {};
void visitDouble(Double x); void visitIdent(Ident x) {};
void visitString(String x);
void visitIdent(Ident x);
}; };
#endif #endif
#ifndef TYPEDEFS_HEADER
#define TYPEDEFS_HEADER
#include <memory>
using namespace std;
class VarInfo;
class FunctionInfo;
class ClassInfo;
class Binding;
class Type;
using VarInfoPtr = shared_ptr<VarInfo>;
using FunctionInfoPtr = shared_ptr<FunctionInfo>;
using ClassInfoPtr = shared_ptr<ClassInfo>;
using BindingPtr = shared_ptr<Binding>;
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;
using NoInit = Item;
using Init = Item;
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;
class Binding;
class VarInfo;
class FunctionInfo;
class ClassInfo;
#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