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
541fddee
Commit
541fddee
authored
5 years ago
by
pycsham
Browse files
Options
Downloads
Patches
Plain Diff
fixed marmoset crash
parent
7cff7676
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Scanning.py
+0
-6
0 additions, 6 deletions
Scanning.py
Weeding.py
+8
-8
8 additions, 8 deletions
Weeding.py
joosc
+0
-0
0 additions, 0 deletions
joosc
joosc.py
+5
-1
5 additions, 1 deletion
joosc.py
with
13 additions
and
15 deletions
Scanning.py
+
0
−
6
View file @
541fddee
...
@@ -494,12 +494,6 @@ def scan(input):
...
@@ -494,12 +494,6 @@ def scan(input):
if
index
<
indexRange
-
1
:
if
index
<
indexRange
-
1
:
if
tokens
[
index
+
1
].
name
==
'
NUM
'
:
if
tokens
[
index
+
1
].
name
==
'
NUM
'
:
return
(
None
,
"
wrong integer literal: starts with 0
"
)
return
(
None
,
"
wrong integer literal: starts with 0
"
)
# Checking integer range (does not cover all edge cases)
elif
token
.
name
==
'
NUM
'
and
index
>
0
and
tokens
[
index
-
1
].
name
==
'
SUB
'
and
int
(
token
.
lex
)
>
2147483648
:
return
(
None
,
"
integer too small
"
)
elif
token
.
name
==
'
NUM
'
and
int
(
token
.
lex
)
>
2147483647
and
(
index
is
0
or
tokens
[
index
-
1
].
name
is
not
'
SUB
'
):
return
(
None
,
"
interger too large
"
)
# dealing with keywords in Java but not in Joos
# dealing with keywords in Java but not in Joos
elif
token
.
name
==
'
ID
'
and
token
.
lex
in
wrongJavaKeyWordDict
:
elif
token
.
name
==
'
ID
'
and
token
.
lex
in
wrongJavaKeyWordDict
:
...
...
This diff is collapsed.
Click to expand it.
Weeding.py
+
8
−
8
View file @
541fddee
...
@@ -5,7 +5,7 @@ import os
...
@@ -5,7 +5,7 @@ import os
def
weedTokens
(
tokens
,
file
):
def
weedTokens
(
tokens
,
file
):
result
=
fileNameCheck
(
tokens
,
file
)
result
=
fileNameCheck
(
tokens
,
file
)
result
+=
extendCheck
(
tokens
)
result
+=
extendCheck
(
tokens
)
result
+=
intRangeCheck
(
tokens
)
#
result += intRangeCheck(tokens)
return
result
return
result
...
@@ -33,13 +33,13 @@ def extendCheck(tokens):
...
@@ -33,13 +33,13 @@ def extendCheck(tokens):
check
=
True
check
=
True
return
""
return
""
def
intRangeCheck
(
tokens
):
#
def intRangeCheck(tokens):
for
index
,
t
oken
in
tokens
:
#
for index, t in
enumerate(
tokens
)
:
if
t
oken
.
name
==
'
NUM
'
and
index
>
0
and
t
okens
[
index
-
1
].
name
==
'
SUB
'
and
int
(
t
oken
.
lex
)
>
2147483648
:
#
if t.name == 'NUM' and index > 0 and t[index-1].name == 'SUB' and int(t.lex) > 2147483648:
return
(
"
ERROR: integer too small
"
)
#
return ("ERROR: integer too small")
if
t
oken
.
name
==
'
NUM
'
and
int
(
t
oken
.
lex
)
>
2147483647
and
(
index
is
0
or
t
okens
[
index
-
1
].
name
is
not
'
SUB
'
):
#
if t.name == 'NUM' and int(t.lex) > 2147483647 and (index is 0 or t[index-1].name is not 'SUB'):
return
(
"
ERROR: integer too large
"
)
#
return ("ERROR: integer too large")
return
""
#
return ""
######################## Weeding after parsing ################################
######################## Weeding after parsing ################################
...
...
This diff is collapsed.
Click to expand it.
joosc
100644 → 100755
+
0
−
0
View file @
541fddee
File mode changed from 100644 to 100755
This diff is collapsed.
Click to expand it.
joosc.py
+
5
−
1
View file @
541fddee
...
@@ -16,10 +16,12 @@ def main():
...
@@ -16,10 +16,12 @@ def main():
try
:
try
:
(
tokens
,
errorString
)
=
scan
(
content
)
(
tokens
,
errorString
)
=
scan
(
content
)
except
:
except
:
print
(
"
scan exception
"
)
return
42
return
42
# Error in Scanning
# Error in Scanning
if
tokens
is
None
:
if
tokens
is
None
:
print
(
"
scan failed
"
)
return
42
return
42
# Weed the tokens
# Weed the tokens
...
@@ -31,10 +33,12 @@ def main():
...
@@ -31,10 +33,12 @@ def main():
try
:
try
:
(
steps
,
error
)
=
parse
(
tokens
)
(
steps
,
error
)
=
parse
(
tokens
)
except
:
except
:
print
(
"
parse exception
"
)
return
42
return
42
if
steps
is
None
:
if
steps
is
None
:
print
(
error
)
print
(
"
parse failed
"
)
# print(error)
return
42
return
42
print
(
"
success in scanning and parsing
"
)
print
(
"
success in scanning and parsing
"
)
...
...
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