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
19eb00f4
Commit
19eb00f4
authored
5 years ago
by
pycsham
Browse files
Options
Downloads
Patches
Plain Diff
Fixed remaining definitve assignemnt issues. Passing 80% on local
parent
68c2b22e
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
AST.py
+1
-0
1 addition, 0 deletions
AST.py
LineNodes.py
+7
-2
7 additions, 2 deletions
LineNodes.py
Test.py
+7
-6
7 additions, 6 deletions
Test.py
with
15 additions
and
8 deletions
AST.py
+
1
−
0
View file @
19eb00f4
...
...
@@ -136,6 +136,7 @@ def getParseTreeNodes(names, tree, terminateList = []):
result
.
extend
(
getParseTreeNodes
(
names
,
n
,
terminateList
))
return
result
# Getting a list of nodes with the provided list of names of the nodes
def
getASTNode
(
names
,
AST
):
result
=
[]
if
not
AST
:
...
...
This diff is collapsed.
Click to expand it.
LineNodes.py
+
7
−
2
View file @
19eb00f4
from
AST
import
ASTNode
,
getParseTreeNodes
from
AST
import
ASTNode
,
getParseTreeNodes
,
getASTNode
from
Environment
import
Env
from
ExprPrimaryNodes
import
makeNodeFromExpr
,
makeNodeFromAllPrimary
,
MethodInvNode
,
ClassCreateNode
from
TheTypeNode
import
TypeNode
,
TypeStruct
...
...
@@ -113,7 +113,12 @@ class VarDclNode(ASTNode):
# Checking for definite assignment
if
checkAssign
:
if
not
self
.
variableInit
:
raise
Exception
(
"
ERROR: local variable declaration not assigned
"
)
raise
Exception
(
"
ERROR: local variable declaration {} is not assigned
"
.
format
(
self
.
name
))
# Checking if the local variable appears in it's own intializer
nameNodes
=
getASTNode
([
"
NameNode
"
],
self
.
variableInit
)
for
node
in
nameNodes
:
if
self
.
name
in
node
.
IDs
:
raise
Exception
(
"
ERROR: local variable {} appears in it
'
s own intialization
"
.
format
(
self
.
name
))
self
.
myType
=
self
.
dclType
.
myType
self
.
children
.
append
(
self
.
dclType
)
...
...
This diff is collapsed.
Click to expand it.
Test.py
+
7
−
6
View file @
19eb00f4
...
...
@@ -134,7 +134,7 @@ def run(testFiles):
parseTrees
.
append
((
f
,
tree
))
# for (n, t) in parseTrees:
# if n == "Tests/A
3
/J
1_accessstaticfield/Main
.java":
# if n == "
./
Tests/A
4
/J
e_8_DefiniteAssignment_InitToItself
.java":
# print(n)
# print(t)
try
:
...
...
@@ -142,11 +142,12 @@ def run(testFiles):
except
Exception
as
e
:
return
"
AST buidling:
"
+
e
.
args
[
0
]
# for (n, t) in ASTs:
# print(n)
# print("--------------------")
# t.printTree()
# print("\n \n\n \n")
for
(
n
,
t
)
in
ASTs
:
if
n
==
"
./Tests/A4/Je_8_DefiniteAssignment_ComplexInitializer.java
"
:
print
(
n
)
print
(
"
--------------------
"
)
t
.
printTree
()
print
(
"
\n
\n\n
\n
"
)
try
:
buildEnvAndLink
(
ASTs
)
...
...
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