Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
latte
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zygzagZ
latte
Commits
0cd3f111
Commit
0cd3f111
authored
Dec 10, 2020
by
zygzagZ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nowa wersja gramatyki
parent
513b2d53
Changes
13
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
964 additions
and
1529 deletions
+964
-1529
.gitignore
.gitignore
+1
-0
Absyn.cpp
Absyn.cpp
+151
-395
Absyn.h
Absyn.h
+62
-142
Lexer.cpp
Lexer.cpp
+130
-125
Parser.cpp
Parser.cpp
+412
-445
Parser.h
Parser.h
+3
-2
Printer.cpp
Printer.cpp
+84
-224
Printer.h
Printer.h
+8
-19
Skeleton.cpp
Skeleton.cpp
+31
-78
Skeleton.h
Skeleton.h
+5
-10
TypeCheck.cpp
TypeCheck.cpp
+69
-71
TypeCheck.h
TypeCheck.h
+4
-9
TypeDefs.h
TypeDefs.h
+4
-9
No files found.
.gitignore
View file @
0cd3f111
t.cpp
t.e
*.o
*.l
*.y
...
...
Absyn.cpp
View file @
0cd3f111
This diff is collapsed.
Click to expand it.
Absyn.h
View file @
0cd3f111
...
...
@@ -60,9 +60,6 @@ public:
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
;
...
...
@@ -80,18 +77,16 @@ public:
virtual
void
visitClassT
(
ClassT
*
p
)
=
0
;
virtual
void
visitFun
(
Fun
*
p
)
=
0
;
virtual
void
visitEVar
(
EVar
*
p
)
=
0
;
virtual
void
visitEIndexAcc
(
EIndexAcc
*
p
)
=
0
;
virtual
void
visitEClsMmbr
(
EClsMmbr
*
p
)
=
0
;
virtual
void
visitEApp
(
EApp
*
p
)
=
0
;
virtual
void
visitELitInt
(
ELitInt
*
p
)
=
0
;
virtual
void
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
visitNullCast
(
NullCast
*
p
)
=
0
;
virtual
void
visitNeg
(
Neg
*
p
)
=
0
;
virtual
void
visitNot
(
Not
*
p
)
=
0
;
virtual
void
visitEMul
(
EMul
*
p
)
=
0
;
...
...
@@ -131,7 +126,7 @@ public:
class
Visitable
{
public:
public:
virtual
~
Visitable
()
{}
virtual
void
accept
(
Visitor
*
v
)
=
0
;
};
...
...
@@ -508,60 +503,14 @@ public:
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
_
;
Expr
*
expr
_
;
Incr
(
const
Incr
&
);
Incr
&
operator
=
(
const
Incr
&
);
Incr
(
PIdent
*
p1
);
Incr
(
Expr
*
p1
);
~
Incr
();
virtual
void
accept
(
Visitor
*
v
);
virtual
Incr
*
clone
()
const
;
...
...
@@ -571,11 +520,11 @@ public:
class
Decr
:
public
Stmt
{
public:
PIdent
*
pident
_
;
Expr
*
expr
_
;
Decr
(
const
Decr
&
);
Decr
&
operator
=
(
const
Decr
&
);
Decr
(
PIdent
*
p1
);
Decr
(
Expr
*
p1
);
~
Decr
();
virtual
void
accept
(
Visitor
*
v
);
virtual
Decr
*
clone
()
const
;
...
...
@@ -831,6 +780,52 @@ public:
void
swap
(
EVar
&
);
};
class
EIndexAcc
:
public
Expr
{
public:
Expr
*
expr_1
;
Expr
*
expr_2
;
EIndexAcc
(
const
EIndexAcc
&
);
EIndexAcc
&
operator
=
(
const
EIndexAcc
&
);
EIndexAcc
(
Expr
*
p1
,
Expr
*
p2
);
~
EIndexAcc
();
virtual
void
accept
(
Visitor
*
v
);
virtual
EIndexAcc
*
clone
()
const
;
void
swap
(
EIndexAcc
&
);
};
class
EClsMmbr
:
public
Expr
{
public:
Expr
*
expr_
;
PIdent
*
pident_
;
EClsMmbr
(
const
EClsMmbr
&
);
EClsMmbr
&
operator
=
(
const
EClsMmbr
&
);
EClsMmbr
(
Expr
*
p1
,
PIdent
*
p2
);
~
EClsMmbr
();
virtual
void
accept
(
Visitor
*
v
);
virtual
EClsMmbr
*
clone
()
const
;
void
swap
(
EClsMmbr
&
);
};
class
EApp
:
public
Expr
{
public:
Expr
*
expr_
;
ListExpr
*
listexpr_
;
EApp
(
const
EApp
&
);
EApp
&
operator
=
(
const
EApp
&
);
EApp
(
Expr
*
p1
,
ListExpr
*
p2
);
~
EApp
();
virtual
void
accept
(
Visitor
*
v
);
virtual
EApp
*
clone
()
const
;
void
swap
(
EApp
&
);
};
class
ELitInt
:
public
Expr
{
public:
...
...
@@ -871,21 +866,6 @@ public:
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:
...
...
@@ -929,78 +909,18 @@ public:
void
swap
(
ENewClass
&
);
};
class
EClsMmbr
:
public
Expr
class
NullCast
:
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
E
Cast
&
);
ECast
&
operator
=
(
const
E
Cast
&
);
ECast
(
PIdent
*
p1
,
Expr
*
p2
);
~
E
Cast
();
NullCast
(
const
Null
Cast
&
);
NullCast
&
operator
=
(
const
Null
Cast
&
);
NullCast
(
Expr
*
p1
);
~
Null
Cast
();
virtual
void
accept
(
Visitor
*
v
);
virtual
E
Cast
*
clone
()
const
;
void
swap
(
E
Cast
&
);
virtual
Null
Cast
*
clone
()
const
;
void
swap
(
Null
Cast
&
);
};
class
Neg
:
public
Expr
...
...
Lexer.cpp
View file @
0cd3f111
This diff is collapsed.
Click to expand it.
Parser.cpp
View file @
0cd3f111
This diff is collapsed.
Click to expand it.
Parser.h
View file @
0cd3f111
...
...
@@ -107,8 +107,9 @@ Program* pProgram(const char *str);
#define _SYMB_40 299
#define _SYMB_41 300
#define _SYMB_42 301
#define _STRING_ 302
#define _INTEGER_ 303
#define _SYMB_43 302
#define _STRING_ 303
#define _INTEGER_ 304
extern
YYSTYPE
yylval
;
...
...
Printer.cpp
View file @
0cd3f111
This diff is collapsed.
Click to expand it.
Printer.h
View file @
0cd3f111
...
...
@@ -58,9 +58,6 @@ class PrintAbsyn : public Visitor
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
);
...
...
@@ -85,18 +82,16 @@ class PrintAbsyn : public Visitor
void
visitListType
(
ListType
*
p
);
void
visitExpr
(
Expr
*
p
);
/* abstract class */
void
visitEVar
(
EVar
*
p
);
void
visitEIndexAcc
(
EIndexAcc
*
p
);
void
visitEClsMmbr
(
EClsMmbr
*
p
);
void
visitEApp
(
EApp
*
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
visitNullCast
(
NullCast
*
p
);
void
visitNeg
(
Neg
*
p
);
void
visitNot
(
Not
*
p
);
void
visitEMul
(
EMul
*
p
);
...
...
@@ -231,9 +226,6 @@ class ShowAbsyn : public Visitor
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
);
...
...
@@ -258,18 +250,16 @@ class ShowAbsyn : public Visitor
void
visitListType
(
ListType
*
p
);
void
visitExpr
(
Expr
*
p
);
/* abstract class */
void
visitEVar
(
EVar
*
p
);
void
visitEIndexAcc
(
EIndexAcc
*
p
);
void
visitEClsMmbr
(
EClsMmbr
*
p
);
void
visitEApp
(
EApp
*
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
visitNullCast
(
NullCast
*
p
);
void
visitNeg
(
Neg
*
p
);
void
visitNot
(
Not
*
p
);
void
visitEMul
(
EMul
*
p
);
...
...
@@ -370,4 +360,3 @@ class ShowAbsyn : public Visitor
#endif
Skeleton.cpp
View file @
0cd3f111
...
...
@@ -162,39 +162,11 @@ void Skeleton::visitAss(Ass *ass)
}
void
Skeleton
::
visitTableAss
(
TableAss
*
table_ass
)
{
/* Code For TableAss Goes Here */
table_ass
->
pident_
->
accept
(
this
);
table_ass
->
expr_1
->
accept
(
this
);
table_ass
->
expr_2
->
accept
(
this
);
}
void
Skeleton
::
visitTableIncr
(
TableIncr
*
table_incr
)
{
/* Code For TableIncr Goes Here */
table_incr
->
pident_
->
accept
(
this
);
table_incr
->
expr_
->
accept
(
this
);
}
void
Skeleton
::
visitTableDecr
(
TableDecr
*
table_decr
)
{
/* Code For TableDecr Goes Here */
table_decr
->
pident_
->
accept
(
this
);
table_decr
->
expr_
->
accept
(
this
);
}
void
Skeleton
::
visitIncr
(
Incr
*
incr
)
{
/* Code For Incr Goes Here */
incr
->
pident
_
->
accept
(
this
);
incr
->
expr
_
->
accept
(
this
);
}
...
...
@@ -202,7 +174,7 @@ void Skeleton::visitDecr(Decr *decr)
{
/* Code For Decr Goes Here */
decr
->
pident
_
->
accept
(
this
);
decr
->
expr
_
->
accept
(
this
);
}
...
...
@@ -346,25 +318,21 @@ void Skeleton::visitEVar(EVar *e_var)
}
void
Skeleton
::
visitELitInt
(
ELitInt
*
e_lit_int
)
{
/* Code For ELitInt Goes Here */
visitInteger
(
e_lit_int
->
integer_
);
}
void
Skeleton
::
visitELitTrue
(
ELitTrue
*
e_lit_true
)
void
Skeleton
::
visitEIndexAcc
(
EIndexAcc
*
e_index_acc
)
{
/* Code For E
LitTrue
Goes Here */
/* Code For E
IndexAcc
Goes Here */
e_index_acc
->
expr_1
->
accept
(
this
);
e_index_acc
->
expr_2
->
accept
(
this
);
}
void
Skeleton
::
visitE
LitFalse
(
ELitFalse
*
e_lit_false
)
void
Skeleton
::
visitE
ClsMmbr
(
EClsMmbr
*
e_cls_mmbr
)
{
/* Code For E
LitFalse
Goes Here */
/* Code For E
ClsMmbr
Goes Here */
e_cls_mmbr
->
expr_
->
accept
(
this
);
e_cls_mmbr
->
pident_
->
accept
(
this
);
}
...
...
@@ -372,77 +340,63 @@ void Skeleton::visitEApp(EApp *e_app)
{
/* Code For EApp Goes Here */
e_app
->
pident
_
->
accept
(
this
);
e_app
->
expr
_
->
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
)
void
Skeleton
::
visitELitInt
(
ELitInt
*
e_lit_int
)
{
/* Code For E
NewArray
Goes Here */
/* Code For E
LitInt
Goes Here */
e_new_array
->
type_
->
accept
(
this
);
e_new_array
->
expr_
->
accept
(
this
);
visitInteger
(
e_lit_int
->
integer_
);
}
void
Skeleton
::
visitE
NewClass
(
ENewClass
*
e_new_class
)
void
Skeleton
::
visitE
LitTrue
(
ELitTrue
*
e_lit_true
)
{
/* Code For E
NewClass
Goes Here */
/* Code For E
LitTrue
Goes Here */
e_new_class
->
pident_
->
accept
(
this
);
}
void
Skeleton
::
visitE
ClsMmbr
(
EClsMmbr
*
e_cls_mmbr
)
void
Skeleton
::
visitE
LitFalse
(
ELitFalse
*
e_lit_false
)
{
/* Code For E
ClsMmbr
Goes Here */
/* Code For E
LitFalse
Goes Here */
e_cls_mmbr
->
expr_
->
accept
(
this
);
e_cls_mmbr
->
pident_
->
accept
(
this
);
}
void
Skeleton
::
visitE
ClsMthd
(
EClsMthd
*
e_cls_mthd
)
void
Skeleton
::
visitE
String
(
EString
*
e_string
)
{
/* Code For E
ClsMthd
Goes Here */
/* Code For E
String
Goes Here */
e_cls_mthd
->
expr_
->
accept
(
this
);
e_cls_mthd
->
pident_
->
accept
(
this
);
e_cls_mthd
->
listexpr_
->
accept
(
this
);
visitString
(
e_string
->
string_
);
}
void
Skeleton
::
visit
Null
(
Null
*
null
)
void
Skeleton
::
visit
ENewArray
(
ENewArray
*
e_new_array
)
{
/* Code For
Null
Goes Here */
/* Code For
ENewArray
Goes Here */
e_new_array
->
type_
->
accept
(
this
);
e_new_array
->
expr_
->
accept
(
this
);
}
void
Skeleton
::
visitE
IndexAcc
(
EIndexAcc
*
e_index_acc
)
void
Skeleton
::
visitE
NewClass
(
ENewClass
*
e_new_class
)
{
/* Code For E
IndexAcc
Goes Here */
/* Code For E
NewClass
Goes Here */
e_index_acc
->
pident_
->
accept
(
this
);
e_index_acc
->
expr_
->
accept
(
this
);
e_new_class
->
pident_
->
accept
(
this
);
}
void
Skeleton
::
visit
ECast
(
ECast
*
e
_cast
)
void
Skeleton
::
visit
NullCast
(
NullCast
*
null
_cast
)
{
/* Code For
E
Cast Goes Here */
/* Code For
Null
Cast Goes Here */
e_cast
->
pident_
->
accept
(
this
);
e_cast
->
expr_
->
accept
(
this
);
null_cast
->
expr_
->
accept
(
this
);
}
...
...
@@ -671,4 +625,3 @@ void Skeleton::visitIdent(Ident x)
}
Skeleton.h
View file @
0cd3f111
...
...
@@ -40,9 +40,6 @@ public:
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
);
...
...
@@ -60,18 +57,16 @@ public:
void
visitClassT
(
ClassT
*
p
);
void
visitFun
(
Fun
*
p
);
void
visitEVar
(
EVar
*
p
);
void
visitEIndexAcc
(
EIndexAcc
*
p
);
void
visitEClsMmbr
(
EClsMmbr
*
p
);
void
visitEApp
(
EApp
*
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
visitNullCast
(
NullCast
*
p
);
void
visitNeg
(
Neg
*
p
);
void
visitNot
(
Not
*
p
);
void
visitEMul
(
EMul
*
p
);
...
...
TypeCheck.cpp
View file @
0cd3f111
...
...
@@ -122,51 +122,23 @@ void TypeCheck::visitDecl(Decl *decl)
el
->
expr_
->
accept
(
this
);
VarInfoPtr
var
=
make_shared
<
VarInfo
>
(
el
->
pident_
,
type
);
scope
.
currentBinding
.
variables
<<
var
;
scope
.
currentBinding
->
variables
<<
var
;
}
}
void
TypeCheck
::
visitAss
(
Ass
*
ass
)
{
auto
var
=
scope
.
currentBinding
.
variables
[]
// auto var = scope.currentBinding->
variables[]
ass
->
expr_1
->
accept
(
this
);
ass
->
expr_2
->
accept
(
this
);
}
void
TypeCheck
::
visitTableAss
(
TableAss
*
table_ass
)
{
/* Code For TableAss Goes Here */
table_ass
->
pident_
->
accept
(
this
);
table_ass
->
expr_1
->
accept
(
this
);
table_ass
->
expr_2
->
accept
(
this
);
}
void
TypeCheck
::
visitTableIncr
(
TableIncr
*
table_incr
)
{
/* Code For TableIncr Goes Here */
table_incr
->
pident_
->
accept
(
this
);
table_incr
->
expr_
->
accept
(
this
);
}
void
TypeCheck
::
visitTableDecr
(
TableDecr
*
table_decr
)
{
/* Code For TableDecr Goes Here */
table_decr
->
pident_
->
accept
(
this
);
table_decr
->
expr_
->
accept
(
this
);
}
void
TypeCheck
::
visitIncr
(
Incr
*
incr
)
{
/* Code For Incr Goes Here */
incr
->
pident
_
->
accept
(
this
);
incr
->
expr
_
->
accept
(
this
);
}
...
...
@@ -174,7 +146,7 @@ void TypeCheck::visitDecr(Decr *decr)
{
/* Code For Decr Goes Here */
decr
->
pident
_
->
accept
(
this
);
decr
->
expr
_
->
accept
(
this
);
}
...
...
@@ -301,6 +273,33 @@ void TypeCheck::visitEVar(EVar *e_var)
}
void
TypeCheck
::
visitEIndexAcc
(
EIndexAcc
*
e_index_acc
)
{
/* Code For EIndexAcc Goes Here */
e_index_acc
->
expr_1
->
accept
(
this
);
e_index_acc
->
expr_2
->
accept
(
this
);
}
void
TypeCheck
::
visitEClsMmbr
(
EClsMmbr
*
e_cls_mmbr
)
{
/* Code For EClsMmbr Goes Here */
e_cls_mmbr
->
expr_
->
accept
(
this
);
e_cls_mmbr
->
pident_
->
accept
(
this
);
}
void
TypeCheck
::
visitEApp
(
EApp
*
e_app
)
{
/* Code For EApp Goes Here */
e_app
->
expr_
->
accept
(
this
);
e_app
->
listexpr_
->
accept
(
this
);
}
void
TypeCheck
::
visitELitInt
(
ELitInt
*
e_lit_int
)
{
visitInteger
(
e_lit_int
->
integer_
);
...
...
@@ -317,15 +316,6 @@ void TypeCheck::visitELitFalse(ELitFalse *e_lit_false)
lastType
=
make_shared
<
Bool
>
();
}
void
TypeCheck
::
visitEApp
(
EApp
*
e_app
)
{
/* Code For EApp Goes Here */
e_app
->
pident_
->
accept
(
this
);
e_app
->
listexpr_
->
accept
(
this
);
}
void
TypeCheck
::
visitEString
(
EString
*
e
)
{
/* Code For EString Goes Here */
...
...
@@ -359,48 +349,56 @@ void TypeCheck::visitENewClass(ENewClass *e_new_class)
lastType
=
make_shared
<
ClassT
>
(
e_new_class
->
pident_
);
}
void
TypeCheck
::
visit
EClsMmbr
(
EClsMmbr
*
e_cls_mmbr
)
void
TypeCheck
::
visit
NullCast
(
NullCast
*
null_cast
)
{
/* Code For
EClsMmbr
Goes Here */
/* Code For
NullCast
Goes Here */
e_cls_mmbr
->
expr_
->
accept
(
this
);
e_cls_mmbr
->
pident_
->
accept
(
this
);
null_cast
->
expr_
->
accept
(
this
);
}
void
TypeCheck
::
visitEClsMthd
(
EClsMthd
*
e_cls_mthd
)
{
/* Code For EClsMthd
Goes Here */
// void TypeCheck::visitEClsMmbr(EClsMmbr *e_cls_mmbr
)
//
{
// /* Code For EClsMmbr
Goes Here */
e_cls_mthd
->
expr_
->
accept
(
this
);
e_cls_mthd
->
pident_
->
accept
(
this
);
e_cls_mthd
->
listexpr_
->
accept
(
this
);
// e_cls_mmbr->expr_->accept(this);
// e_cls_mmbr->pident_->accept(this);
}
//
}
void
TypeCheck
::
visitNull
(
Null
*
e
)
{
PIdent
*
ident
=
new
PIdent
(
"null"
,
e
->
lineno
);
lastType
=
make_shared
<
ClassT
>
(
ident
);
// TODO
}
// void TypeCheck::visitEClsMthd(EClsMthd *e_cls_mthd)
// {
// /* Code For EClsMthd Goes Here */
void
TypeCheck
::
visitEIndexAcc
(
EIndexAcc
*
e_index_acc
)
{
/* Code For EIndexAcc Goes Here */
// e_cls_mthd->expr_->accept(this);
// e_cls_mthd->pident_->accept(this);
// e_cls_mthd->listexpr_->accept(this);
e_index_acc
->
pident_
->
accept
(
this
);
e_index_acc
->
expr_
->
accept
(
this
);
throw
UndefinedError
(
e_index_acc
->
pident_
);
// TODO
}
// }
void
TypeCheck
::
visitECast
(
ECast
*
e_cast
)
{
/* Code For ECast Goes Here */
// void TypeCheck::visitNull(Null *e)
// {
// PIdent *ident = new PIdent("null", e->lineno);
// lastType = make_shared<ClassT>(ident); // TODO
// }
e_cast
->
pident_
->
accept
(
this
);
e_cast
->
expr_
->
accept
(
this
);
lastType
=
make_shared
<
ClassT
>
(
e_cast
->
pident_
);
}
// void TypeCheck::visitEIndexAcc(EIndexAcc *e_index_acc)
// {
// /* Code For EIndexAcc Goes Here */
// e_index_acc->pident_->accept(this);
// e_index_acc->expr_->accept(this);
// throw UndefinedError(e_index_acc->pident_); // TODO
// }
// void TypeCheck::visitECast(ECast *e_cast)
// {
// /* Code For ECast Goes Here */
// e_cast->pident_->accept(this);
// e_cast->expr_->accept(this);
// lastType = make_shared<ClassT>(e_cast->pident_);
// }
void
TypeCheck
::
visitNeg
(
Neg
*
e
)
{
...
...
TypeCheck.h
View file @
0cd3f111
...
...
@@ -37,9 +37,6 @@ protected:
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
);
...
...
@@ -57,18 +54,16 @@ protected:
void
visitClassT
(
ClassT
*
p
);
void
visitFun
(
Fun
*
p
);
void
visitEVar
(
EVar
*
p
);
void
visitEIndexAcc
(
EIndexAcc
*
p
);
void
visitEClsMmbr
(
EClsMmbr
*
p
);
void
visitEApp
(
EApp
*
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
visitNullCast
(
NullCast
*
p
);
void
visitNeg
(
Neg
*
p
);
void
visitNot
(
Not
*
p
);
void
visitEMul
(
EMul
*
p
);
...
...
TypeDefs.h
View file @
0cd3f111
...
...
@@ -48,9 +48,6 @@ class Decl;
using
NoInit
=
Item
;
using
Init
=
Item
;
class
Ass
;
class
TableAss
;
class
TableIncr
;
class
TableDecr
;
class
Incr
;
class
Decr
;
class
Ret
;
...
...
@@ -68,18 +65,16 @@ class Array;
class
ClassT
;
class
Fun
;
class
EVar
;
class
EIndexAcc
;
class
EClsMmbr
;
class
EApp
;
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
NullCast
;
class
Neg
;
class
Not
;
class
EMul
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment