Skip to content
Snippets Groups Projects
Commit feca561c authored by Xun Yang's avatar Xun Yang
Browse files

octal in scanner

parent 1c0b3741
No related branches found
No related tags found
No related merge requests found
...@@ -304,16 +304,33 @@ def JoosTransition(input, state): ...@@ -304,16 +304,33 @@ def JoosTransition(input, state):
elif (state == 'STRINGESC'): elif (state == 'STRINGESC'):
if input == 'u': if input == 'u':
return 'UNICODE' #going to be discarded 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' ): if input not in ('n', 'r', 't', 'v', '\\','\'', '"', '?', 'b' ):
return None return None
return 'LSTRING' 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 # char literal
elif (state == 'LCHAR'): elif (state == 'LCHAR'):
if (input == '\\'): if (input == '\\'):
return 'CHARESC' return 'CHARESC'
return 'CHAREND' return 'CHAREND'
elif (state == 'CHARESC'): elif (state == 'CHARESC'):
if input.isdigit() and 0 <= int(input) <= 7:
return 'CHAROCTAVEESC'
if input not in ('n', 'r', 't', 'v', '\\','\'', '"', '?', 'b' ): if input not in ('n', 'r', 't', 'v', '\\','\'', '"', '?', 'b' ):
return None return None
return 'CHAREND' return 'CHAREND'
...@@ -452,7 +469,9 @@ def SMM(input, dfa): ...@@ -452,7 +469,9 @@ def SMM(input, dfa):
if (state in dfa.accept): if (state in dfa.accept):
scanned.append(Token(state, seenInput)) scanned.append(Token(state, seenInput))
else: else:
return (None, ord(input[0])) if input:
m = ord(input[0])
return (None, m)
return (scanned, "success") return (scanned, "success")
......
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