fix string id e tal
This commit is contained in:
parent
47654120e2
commit
3ccb736eb9
3 changed files with 16 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
__pycache__/
|
||||
Session.vim
|
||||
|
|
|
@ -6,4 +6,4 @@ othername = """Tom \"The killer\" or \"yo\" or
|
|||
'you' Preston-Werner"""
|
||||
date = 2010-04-23
|
||||
time = 21:30:00
|
||||
lol."yo" = "test"
|
||||
"lol".yo = "test"
|
||||
|
|
27
src/lexer.py
27
src/lexer.py
|
@ -15,17 +15,9 @@ tokens = [
|
|||
"INF",
|
||||
"NAN",
|
||||
"COMMENT",
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
def t_MLSTR(t):
|
||||
r"(\"\"\"(?:[^\"\\]|\\.)+\"\"\")|(\'\'\'(?:[^\'\\]|\\.)+\'\'\')"
|
||||
return t
|
||||
|
||||
# STR needs to be the first one to catch
|
||||
def t_STR(t):
|
||||
r"(\"(?:[^\"\\]|\\.)+\")|(\'[^\']+\')"
|
||||
return t
|
||||
|
||||
|
||||
# needs to check if datetime is valid
|
||||
|
@ -45,6 +37,19 @@ def t_TIME(t):
|
|||
r"\d{2}:\d{2}:\d{2}(\.\d{1,6})?"
|
||||
return t
|
||||
|
||||
# ID needs to be the last so it doesnt catch everything (literally)
|
||||
def t_ID(t):
|
||||
r"(([\w_]+)|(\"[\w_]+\"\.|\'[\w_]+\'\.)([\w_]+|\"[\w_]+\"|\'[\w_]+\'))(\.([\w_]+|\"[\w_]+\"|\'[\w_]+\'))*"
|
||||
return t
|
||||
|
||||
def t_MLSTR(t):
|
||||
r"(\"\"\"(?:[^\"\\]|\\.)+\"\"\")|(\'\'\'(?:[^\'\\]|\\.)+\'\'\')"
|
||||
return t
|
||||
|
||||
# STR needs to be the first one to catch
|
||||
def t_STR(t):
|
||||
r"(?<!^)(\"(?:[^\"\\]|\\.)+\")|(\'[^\']+\')"
|
||||
return t
|
||||
|
||||
# needs number grouping (example : flt8 = 224_617.445_991_228)
|
||||
def t_FLOAT(t):
|
||||
|
@ -89,10 +94,6 @@ def t_BOOL(t):
|
|||
return t
|
||||
|
||||
|
||||
# ID needs to be the last so it doesnt catch everything (literally)
|
||||
def t_ID(t):
|
||||
r"([\w_]+|\"[\w_]+\"|\'[\w_]+\')(.([\w_]+|\"[\w_]+\"|\'[\w_]+\'))*"
|
||||
return t
|
||||
|
||||
|
||||
def t_COMMENT(t):
|
||||
|
|
Loading…
Reference in a new issue