Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs444
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xun Yang
cs444
Commits
9ecbf314
Commit
9ecbf314
authored
5 years ago
by
Xun Yang
Browse files
Options
Downloads
Patches
Plain Diff
fix little stuff in Literal Node
parent
014420b3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
AST.py
+1
-0
1 addition, 0 deletions
AST.py
UnitNodes.py
+5
-5
5 additions, 5 deletions
UnitNodes.py
with
6 additions
and
5 deletions
AST.py
+
1
−
0
View file @
9ecbf314
...
...
@@ -55,6 +55,7 @@ class ASTNode():
pass
def
checkType
(
self
):
# self is type correct if all its children are type correct (no exception raised)
for
c
in
self
.
children
:
if
c
and
hasattr
(
c
,
'
checkType
'
):
c
.
checkType
()
...
...
This diff is collapsed.
Click to expand it.
UnitNodes.py
+
5
−
5
View file @
9ecbf314
...
...
@@ -10,9 +10,9 @@ from TheTypeNode import TypeNode
# literals
class
LiteralNode
(
ASTNode
):
toLiType
=
dict
({
'
LITERALBOOL
'
:
'
bool
'
,
'
LITERALBOOL
'
:
'
bool
ean
'
,
'
LITERALCHAR
'
:
'
char
'
,
'
LITERALSTRING
'
:
'
String
'
,
'
LITERALSTRING
'
:
'
java.lang.
String
'
,
'
NULL
'
:
'
null
'
,
'
NUM
'
:
'
int
'
,
'
ZERO
'
:
'
int
'
...
...
@@ -20,14 +20,14 @@ class LiteralNode(ASTNode):
# always list all fields in the init method to show the class structure
def
__init__
(
self
,
parseTree
):
self
.
parseTree
=
parseTree
self
.
liTyp
e
=
LiteralNode
.
toLiType
.
get
(
parseTree
.
children
[
0
].
name
)
# type of the literal
self
.
nam
e
=
LiteralNode
.
toLiType
.
get
(
parseTree
.
children
[
0
].
name
)
# type of the literal
self
.
value
=
parseTree
.
children
[
0
].
lex
# the value
self
.
env
=
None
self
.
children
=
[]
if
self
.
liTyp
e
==
'
int
'
:
if
self
.
nam
e
==
'
int
'
:
self
.
value
=
int
(
self
.
value
)
if
self
.
liTyp
e
==
'
LITERALBOOL
'
:
if
self
.
nam
e
==
'
LITERALBOOL
'
:
if
self
.
value
==
'
false
'
:
self
.
value
=
False
else
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment