Skip to content
Snippets Groups Projects
Commit f7ade625 authored by pycsham's avatar pycsham
Browse files

Modified scanner and cfg for some bugs for false positives

parent 097f4d64
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ idToTokenDict = dict({ ...@@ -31,7 +31,7 @@ idToTokenDict = dict({
'if': 'IF', 'if': 'IF',
'implements': 'IMPLEMENTS', 'implements': 'IMPLEMENTS',
'import': 'IMPORT', 'import': 'IMPORT',
'instaceof': 'INSTANCEOF', 'instanceof': 'INSTANCEOF',
'int': 'INT', 'int': 'INT',
'interface': 'INTERFACE', 'interface': 'INTERFACE',
'native': 'NATIVE', 'native': 'NATIVE',
...@@ -493,7 +493,7 @@ def scan(input): ...@@ -493,7 +493,7 @@ def scan(input):
return (None, "wrong keyword in comp id") return (None, "wrong keyword in comp id")
if i is not 0 and (t == 'Class' or t == 'class'): if i is not 0 and (t == 'Class' or t == 'class'):
return (None, "wrong keyword in comp id") return (None, "wrong keyword in comp id")
# Checking if the multi line comment has a closing tag # Checking if the multi line comment has a closing tag
if token.name == 'LCOMMENT': if token.name == 'LCOMMENT':
multiLineCommentFlag = True multiLineCommentFlag = True
......
...@@ -7,7 +7,7 @@ from Parsing import parse ...@@ -7,7 +7,7 @@ from Parsing import parse
def allFiles(testDir): def allFiles(testDir):
return [testDir + f for f in listdir(testDir) if isfile(join(testDir, f)) and f.startswith('J1')] return [testDir + f for f in listdir(testDir) if isfile(join(testDir, f)) and f.startswith('Je')]
def main(): def main():
...@@ -17,21 +17,21 @@ def main(): ...@@ -17,21 +17,21 @@ def main():
print("**********************************************************") print("**********************************************************")
for f in testFiles: for f in testFiles:
print(f) # print(f)
# Scanning # Scanning
content = open(f, "r").read() content = open(f, "r").read()
(tokens, errorString) = scan(content) (tokens, errorString) = scan(content)
# Error in Scanning # Error in Scanning
if tokens is None: if tokens is None:
print("ERROR in Scanning: " + errorString) # print("ERROR in Scanning: " + errorString)
print("**********************************************************") print("**********************************************************")
continue continue
s = "All Tokens: " # s = "All Tokens: "
for token in tokens: # for token in tokens:
if (token.name and token.lex): # if (token.name and token.lex):
s += '(' + token.name + ',' + token.lex + '), ' # s += '(' + token.name + ',' + token.lex + '), '
# print(s) # print(s)
# Parsing # Parsing
...@@ -44,10 +44,11 @@ def main(): ...@@ -44,10 +44,11 @@ def main():
# Error in Parsing # Error in Parsing
if steps is None: if steps is None:
print("ERROR in Parsing: ", errorString) # print("ERROR in Parsing: ", errorString)
print("**********************************************************") # print("**********************************************************")
continue continue
print(f)
print("Succeeded")
# print("All Steps:") # print("All Steps:")
# print(steps) # print(steps)
......
...@@ -162,7 +162,7 @@ primaryNoArrayAccess ...@@ -162,7 +162,7 @@ primaryNoArrayAccess
arrayID arrayID
methodOrFieldID methodOrFieldID
start start
205 200
start BOF packageDcl importDcls topDcls EOF start BOF packageDcl importDcls topDcls EOF
packageDcl PACKAGE name SEMICO packageDcl PACKAGE name SEMICO
packageDcl PACKAGE ID SEMICO packageDcl PACKAGE ID SEMICO
...@@ -197,7 +197,6 @@ constructorDcl methodMod ID LPAREN params RPAREN methodBody ...@@ -197,7 +197,6 @@ constructorDcl methodMod ID LPAREN params RPAREN methodBody
methodDcl methodMod methodHead methodBody methodDcl methodMod methodHead methodBody
methodHead type ID LPAREN params RPAREN methodHead type ID LPAREN params RPAREN
methodHead VOID ID LPAREN params RPAREN methodHead VOID ID LPAREN params RPAREN
methodMod
methodMod PUBLIC methodMod PUBLIC
methodMod PUBLIC FINAL methodMod PUBLIC FINAL
methodMod PUBLIC STATIC methodMod PUBLIC STATIC
...@@ -208,9 +207,6 @@ methodMod PROTECTED FINAL ...@@ -208,9 +207,6 @@ methodMod PROTECTED FINAL
methodMod PROTECTED STATIC methodMod PROTECTED STATIC
methodMod PROTECTED ABSTRACT methodMod PROTECTED ABSTRACT
methodMod PROTECTED STATIC NATIVE methodMod PROTECTED STATIC NATIVE
methodMod STATIC
methodMod STATIC NATIVE
methodMod FINAL
methodMod ABSTRACT methodMod ABSTRACT
methodBody block methodBody block
methodBody SEMICO methodBody SEMICO
...@@ -358,7 +354,6 @@ multExpr unaryExpr ...@@ -358,7 +354,6 @@ multExpr unaryExpr
multExpr multExpr MULT unaryExpr multExpr multExpr MULT unaryExpr
multExpr multExpr DIV unaryExpr multExpr multExpr DIV unaryExpr
multExpr multExpr MOD unaryExpr multExpr multExpr MOD unaryExpr
unaryExpr ADD unaryExpr
unaryExpr SUB unaryExpr unaryExpr SUB unaryExpr
unaryExpr unaryNotPlusMinus unaryExpr unaryNotPlusMinus
unaryNotPlusMinus postfixExpr unaryNotPlusMinus postfixExpr
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment