From 47654120e2b3303e9925df5f9ebb1f5416830063 Mon Sep 17 00:00:00 2001 From: afonsofrancof Date: Sat, 20 May 2023 16:05:10 +0100 Subject: [PATCH] Strings and ID's. Need to remember to keep a dictionary of already defined keys and to check if type isn't changed --- src/example.toml | 3 +++ src/lexer.py | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/example.toml b/src/example.toml index 07a4c85..8c07ef4 100644 --- a/src/example.toml +++ b/src/example.toml @@ -2,5 +2,8 @@ title = "TOML Example" [owner] name = """Tom Preston-Werner test""" +othername = """Tom \"The killer\" or \"yo\" or +'you' Preston-Werner""" date = 2010-04-23 time = 21:30:00 +lol."yo" = "test" diff --git a/src/lexer.py b/src/lexer.py index 2f45e11..19d41a9 100644 --- a/src/lexer.py +++ b/src/lexer.py @@ -19,12 +19,12 @@ tokens = [ def t_MLSTR(t): - r"\"\"\"[^\"]+\"\"\"" + r"(\"\"\"(?:[^\"\\]|\\.)+\"\"\")|(\'\'\'(?:[^\'\\]|\\.)+\'\'\')" return t # STR needs to be the first one to catch def t_STR(t): - r"\"[^\"]+\"" + r"(\"(?:[^\"\\]|\\.)+\")|(\'[^\']+\')" return t @@ -91,7 +91,7 @@ def t_BOOL(t): # ID needs to be the last so it doesnt catch everything (literally) def t_ID(t): - r"[\w_]+(\.[\w_]+)*" + r"([\w_]+|\"[\w_]+\"|\'[\w_]+\')(.([\w_]+|\"[\w_]+\"|\'[\w_]+\'))*" return t