From 15b4de222317f2db531ff49153f1d50bae4ac470 Mon Sep 17 00:00:00 2001
From: pycsham <shampuiyanchloe@gmail.com>
Date: Mon, 10 Feb 2020 22:33:15 -0500
Subject: [PATCH] fixed the this keyword error

---
 Scanning.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Scanning.py b/Scanning.py
index 61a7b38..acacf01 100644
--- a/Scanning.py
+++ b/Scanning.py
@@ -86,7 +86,6 @@ wrongJavaKeyWordDict = {
     'try',
     'volatile',
     '_',
-    'this',
     'super',
     'Long',
     'Float'
@@ -131,6 +130,8 @@ JoosDFATokens = set([
     'MULT',           # *
     'DIV',            # /
     'MOD',            # %
+    'BITAND',         # &
+    'BITOR',          # |
 
     # Separators:
     'SEMICO',         # ;
@@ -428,7 +429,7 @@ def JoosTransition(input, state):
 #TODO: remove alphabets since it's unecessary in our DFA implementation
 specialChars = set(list(".;:,@{}()[]<>!?+-*/&|^%=''\"\\"))
 JoosAccept = JoosDFATokens.union({'WHITESPACE', 'COMMENT', 'NEWLINE', 'LCOMMENT', 'RCOMMENT', 'NEWLINEC', 'LCOM2', 'LCOM3'})
-JoosStates = JoosAccept.union({'START', 'PERIOD2', 'HALFCOMP', 'HEXLITERAL', 'OPDISCARD', 'BITAND', 'BITOR', 'FLOAT', 'UNICODE'})
+JoosStates = JoosAccept.union({'START', 'PERIOD2', 'HALFCOMP', 'HEXLITERAL', 'OPDISCARD', 'FLOAT', 'UNICODE'})
 JoosAlphabet = set(string.ascii_lowercase).union(set(string.ascii_uppercase)).union(set(string.digits)).union(specialChars)
 
 #########################  DFA  #######################################
@@ -507,10 +508,14 @@ def scan(input):
             # dealing with operators and seperators in Java but not in Joos
             elif token.name in wrongJavaOpDict:
                 return (None, "operator in Java but not in Joos")
+            # TODO: need to figure out what is allowed in compID and refactor this checking for explicit this calls
+            elif token.name == 'ID' and token.lex is 'this':
+                return (None, "explicit this call not allowed") 
 
             # Checking wrong keywords in compIDs
             elif token.name == 'COMPID':
                 temp = token.lex.split('.')
+                compIDIndexRange = len(temp)
                 for i, t in enumerate(temp):
                     if i == 0 and t in wrongJavaKeyWordDict:
                         return (None, "wrong keyword in comp id")
-- 
GitLab