diff --git a/Scanning.py b/Scanning.py index 24226b443011e851e38d9977236fd218e9ef6e64..db411940755520a0d7ae971b2e5243f62cad36f7 100644 --- a/Scanning.py +++ b/Scanning.py @@ -304,16 +304,33 @@ def JoosTransition(input, state): elif (state == 'STRINGESC'): if input == 'u': return 'UNICODE' #going to be discarded + if input.isdigit() and 0 <= int(input) <= 7: + return 'LSTRING' if input not in ('n', 'r', 't', 'v', '\\','\'', '"', '?', 'b' ): return None return 'LSTRING' + elif(state == 'CHAROCTAVEESC'): + if input.isdigit() and 0 <= int(input) <= 7: + return 'CHAROCTAVEESC1' + if (input == '\''): + return 'LITERALCHAR' + return None + elif(state == 'CHAROCTAVEESC1'): + if input.isdigit() and 0 <= int(input) <= 7: + return 'CHAREND' + if (input == '\''): + return 'LITERALCHAR' + return None + # char literal elif (state == 'LCHAR'): if (input == '\\'): return 'CHARESC' return 'CHAREND' elif (state == 'CHARESC'): + if input.isdigit() and 0 <= int(input) <= 7: + return 'CHAROCTAVEESC' if input not in ('n', 'r', 't', 'v', '\\','\'', '"', '?', 'b' ): return None return 'CHAREND' @@ -452,7 +469,9 @@ def SMM(input, dfa): if (state in dfa.accept): scanned.append(Token(state, seenInput)) else: - return (None, ord(input[0])) + if input: + m = ord(input[0]) + return (None, m) return (scanned, "success")