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
3b5eed03
Commit
3b5eed03
authored
5 years ago
by
Xun Yang
Browse files
Options
Downloads
Patches
Plain Diff
some more node changes
parent
c62c25f3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
LineNodes.py
+1
-1
1 addition, 1 deletion
LineNodes.py
MemberNodes.py
+2
-2
2 additions, 2 deletions
MemberNodes.py
UnitNodes.py
+30
-0
30 additions, 0 deletions
UnitNodes.py
with
33 additions
and
3 deletions
LineNodes.py
+
1
−
1
View file @
3b5eed03
from
AST
import
ASTNode
,
getParseTreeNodes
,
getTypeName
from
Environment
import
Env
from
WordNodes
import
Expr
Node
from
WordNodes
import
makeNodeFrom
Expr
# containing line level nodes: block, for/while/if, declaration
...
...
This diff is collapsed.
Click to expand it.
MemberNodes.py
+
2
−
2
View file @
3b5eed03
from
AST
import
ASTNode
,
getParseTreeNodes
,
getTypeName
from
LineNodes
import
BlockNode
from
WordNodes
import
Expr
Node
from
WordNodes
import
makeNodeFrom
Expr
from
Environment
import
Env
from
collections
import
OrderedDict
...
...
@@ -33,7 +33,7 @@ class FieldNode(ASTNode):
nameNodes
=
getParseTreeNodes
([
'
variableInit
'
],
node
)
for
n
in
nameNodes
:
self
.
fieldInit
=
Expr
Node
(
n
)
self
.
fieldInit
=
makeNodeFrom
Expr
(
n
)
if
self
.
fieldInit
:
self
.
children
.
append
(
self
.
fieldInit
)
...
...
This diff is collapsed.
Click to expand it.
UnitNodes.py
0 → 100644
+
30
−
0
View file @
3b5eed03
from
AST
import
ASTNode
,
getParseTreeNodes
,
getTypeName
from
Environment
import
Env
# literals
class
LiteralNode
(
ASTNode
):
toLiType
=
dict
({
'
LITERALBOOL
'
:
'
bool
'
,
'
LITERALCHAR
'
:
'
char
'
,
'
LITERALSTRING
'
:
'
String
'
,
'
NULL
'
:
'
null
'
,
'
NUM
'
:
'
int
'
,
'
ZERO
'
:
'
int
'
})
# always list all fields in the init method to show the class structure
def
__init__
(
self
,
parseTree
):
self
.
parseTree
=
parseTree
self
.
liType
=
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
.
liType
==
'
int
'
:
self
.
value
=
int
(
self
.
value
)
if
self
.
liType
==
'
LITERALBOOL
'
:
if
self
.
value
==
'
false
'
:
self
.
value
=
False
else
:
self
.
value
=
True
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