|
Lines 52-58
Link Here
|
| 52 |
'L': '[a-zA-Z_]', |
52 |
'L': '[a-zA-Z_]', |
| 53 |
'H': '[a-fA-F0-9]', |
53 |
'H': '[a-fA-F0-9]', |
| 54 |
'E': '[Ee][+-]?\s*{D}+', |
54 |
'E': '[Ee][+-]?\s*{D}+', |
| 55 |
'FS': '[FflL]', |
55 |
'FS': '([FfLl]|d[dfl]|D[DFL]|[fFdD][0-9]+x?)', |
| 56 |
'IS': '[uUlL]*', |
56 |
'IS': '[uUlL]*', |
| 57 |
} |
57 |
} |
| 58 |
# Helper: substitute {foo} with subs[foo] in string (makes regexes more lexy) |
58 |
# Helper: substitute {foo} with subs[foo] in string (makes regexes more lexy) |
|
Lines 226-235
Link Here
|
| 226 |
exp = m.group("exp") |
226 |
exp = m.group("exp") |
| 227 |
suf = m.group("suf") |
227 |
suf = m.group("suf") |
| 228 |
|
228 |
|
| 229 |
if dp or exp or (suf and suf in ("Ff")): |
229 |
if dp or exp or (suf and suf not in ("Ll")): |
| 230 |
s = m.group(0) |
230 |
s = m.group(0) |
| 231 |
if suf: |
231 |
if suf: |
| 232 |
s = s[:-1] |
232 |
s = s[:-len(suf)] |
| 233 |
# Attach a prefix so the parser can figure out if should become an |
233 |
# Attach a prefix so the parser can figure out if should become an |
| 234 |
# integer, float, or long |
234 |
# integer, float, or long |
| 235 |
t.value = "f" + s |
235 |
t.value = "f" + s |
|
Lines 240-247
Link Here
|
| 240 |
|
240 |
|
| 241 |
return t |
241 |
return t |
| 242 |
|
242 |
|
| 243 |
INT_LITERAL = sub(r"(?P<p1>(?:0x{H}+)|(?:{D}+))(?P<suf>{IS})") |
243 |
INT_LITERAL = sub(r"(?P<p1>(?:0x{H}+)|(?:0[0-7]+)|(?:[1-9]{D}+))(?P<suf>{IS})") |
| 244 |
|
|
|
| 245 |
|
244 |
|
| 246 |
@TOKEN(INT_LITERAL) |
245 |
@TOKEN(INT_LITERAL) |
| 247 |
def t_ANY_int(t): |
246 |
def t_ANY_int(t): |