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
0225b868
Commit
0225b868
authored
5 years ago
by
Nicholas Robinson
Browse files
Options
Downloads
Patches
Plain Diff
getParseTreeNodes & TypeNode name
- fixed getParseTreeNodes - fixed getting name for TypeNode
parent
f6057636
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
AST.py
+1
-1
1 addition, 1 deletion
AST.py
Environment.py
+4
-3
4 additions, 3 deletions
Environment.py
Test.py
+2
-2
2 additions, 2 deletions
Test.py
TypeNodes.py
+0
-4
0 additions, 4 deletions
TypeNodes.py
UnitNodes.py
+1
-0
1 addition, 0 deletions
UnitNodes.py
with
8 additions
and
10 deletions
AST.py
+
1
−
1
View file @
0225b868
...
...
@@ -95,5 +95,5 @@ def getParseTreeNodes(names, tree, terminateList = []):
elif
n
.
name
in
terminateList
:
continue
else
:
result
.
extend
(
getParseTreeNodes
(
names
,
n
))
result
.
extend
(
getParseTreeNodes
(
names
,
n
,
terminateList
))
return
result
This diff is collapsed.
Click to expand it.
Environment.py
+
4
−
3
View file @
0225b868
...
...
@@ -104,9 +104,8 @@ class GlobalEnv(Env):
# 1. enclosing class/interface
# - already did
# 2. single-type import
if
name
in
imported
:
if
name
in
self
.
map
:
return
self
.
map
.
get
(
name
)
if
name
in
imported
and
name
in
self
.
map
:
return
self
.
map
.
get
(
name
)
# 3. type in the current package
full
=
packageName
+
'
.
'
+
name
# print(full)
...
...
@@ -123,6 +122,8 @@ class GlobalEnv(Env):
for
i
in
implicitly
:
if
i
in
name
and
name
in
self
.
map
:
return
self
.
map
.
get
(
name
)
elif
(
i
+
name
)
in
self
.
map
:
return
self
.
map
.
get
(
i
+
name
)
raise
Exception
(
"
ERROR: Can
'
t find definition of {} in the Environment
"
.
format
(
key
))
...
...
This diff is collapsed.
Click to expand it.
Test.py
+
2
−
2
View file @
0225b868
...
...
@@ -45,9 +45,9 @@ def a2Multiple():
print
(
c
)
print
(
"
**********************************************************
"
)
# get all files from stdlib folder
#
testFiles = [join(dp, f) for dp, dn, filenames in walk('stdlib/2.0/java/') for f in filenames]
testFiles
=
[
join
(
dp
,
f
)
for
dp
,
dn
,
filenames
in
walk
(
'
stdlib/2.0/java/
'
)
for
f
in
filenames
]
# get all files in the folder recursively
testFiles
=
[
join
(
dp
,
f
)
for
dp
,
dn
,
filenames
in
walk
(
c
)
for
f
in
filenames
]
testFiles
+
=
[
join
(
dp
,
f
)
for
dp
,
dn
,
filenames
in
walk
(
c
)
for
f
in
filenames
]
run
(
testFiles
)
print
(
"
\n
\n\n
"
)
...
...
This diff is collapsed.
Click to expand it.
TypeNodes.py
+
0
−
4
View file @
0225b868
...
...
@@ -95,12 +95,8 @@ class ClassNode(ASTNode):
# 7. A class or interface must not declare two methods with the same signature (name and parameter types).
unique
=
[]
for
method
in
self
.
methods
:
# print(method.name)
key
=
(
method
.
name
,
method
.
paramTypes
)
if
key
in
unique
:
# print(self.methods)
# print(key)
# print(unique)
raise
Exception
(
"
ERROR: Class
'
{}
'
declares 2 methods with the same signature
'
{}
'"
.
format
(
self
.
name
,
key
[
0
]))
unique
.
append
(
key
)
...
...
This diff is collapsed.
Click to expand it.
UnitNodes.py
+
1
−
0
View file @
0225b868
...
...
@@ -63,6 +63,7 @@ class TypeNode(ASTNode):
nameNodes
=
getParseTreeNodes
([
'
BOOLEAN
'
,
'
BYTE
'
,
'
CHAR
'
,
'
INT
'
,
'
SHORT
'
],
parseTree
)
if
nameNodes
:
self
.
isPrimType
=
True
self
.
name
=
nameNodes
[
0
].
lex
else
:
self
.
name
=
getParseTreeNodes
([
'
ID
'
,
'
COMPID
'
],
parseTree
)[
0
].
lex
...
...
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