Strings and ID's.

Need to remember to keep a dictionary of already defined keys and to check if type isn't changed
This commit is contained in:
Afonso Franco 2023-05-20 16:05:10 +01:00
parent 0a2c82a6d9
commit 47654120e2
Signed by: afonso
SSH key fingerprint: SHA256:JiuxZNdA5bRWXPMUJChI0AQ75yC+cXY4xM0IaVwEVys
2 changed files with 6 additions and 3 deletions

View file

@ -2,5 +2,8 @@ title = "TOML Example"
[owner] [owner]
name = """Tom Preston-Werner name = """Tom Preston-Werner
test""" test"""
othername = """Tom \"The killer\" or \"yo\" or
'you' Preston-Werner"""
date = 2010-04-23 date = 2010-04-23
time = 21:30:00 time = 21:30:00
lol."yo" = "test"

View file

@ -19,12 +19,12 @@ tokens = [
def t_MLSTR(t): def t_MLSTR(t):
r"\"\"\"[^\"]+\"\"\"" r"(\"\"\"(?:[^\"\\]|\\.)+\"\"\")|(\'\'\'(?:[^\'\\]|\\.)+\'\'\')"
return t return t
# STR needs to be the first one to catch # STR needs to be the first one to catch
def t_STR(t): def t_STR(t):
r"\"[^\"]+\"" r"(\"(?:[^\"\\]|\\.)+\")|(\'[^\']+\')"
return t return t
@ -91,7 +91,7 @@ def t_BOOL(t):
# ID needs to be the last so it doesnt catch everything (literally) # ID needs to be the last so it doesnt catch everything (literally)
def t_ID(t): def t_ID(t):
r"[\w_]+(\.[\w_]+)*" r"([\w_]+|\"[\w_]+\"|\'[\w_]+\')(.([\w_]+|\"[\w_]+\"|\'[\w_]+\'))*"
return t return t