From e3a0ea5bf12fa167fe0c0f4f7f43e5df30bbe873 Mon Sep 17 00:00:00 2001 From: afonsofrancof Date: Sat, 27 May 2023 21:41:23 +0100 Subject: [PATCH] novos testes e new line mal feito --- src/example.toml | 5 ++--- src/lexer.py | 6 +++++- src/parser.py | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/example.toml b/src/example.toml index 2191afa..a4b0e7f 100644 --- a/src/example.toml +++ b/src/example.toml @@ -75,12 +75,11 @@ contributors = [ ] [fruie] -apple.color = "red" apple.taste.sweet = true [fruie.apple.color] -test="oi" -[fruie.apple.taste] +test={"oi" = 14} +[fruie.apple.color.test] test2="oi" [fruie.apple.texture] # you can add sub-tables diff --git a/src/lexer.py b/src/lexer.py index 8f4ebcb..50ad46b 100644 --- a/src/lexer.py +++ b/src/lexer.py @@ -16,8 +16,12 @@ tokens = [ "INF", "NAN", "COMMENT", + "NEWLINE", ] +def t_NEWLINE(t): + r"\n+\s*" + return t # needs to check if datetime is valid def t_DATETIME(t): @@ -115,7 +119,7 @@ def t_error(t): t.lexer.skip(1) -t_ignore = "\n\t " +t_ignore = "\t " literals = "[]{},=" diff --git a/src/parser.py b/src/parser.py index f695745..0a05862 100644 --- a/src/parser.py +++ b/src/parser.py @@ -16,11 +16,11 @@ def p_content_single(p): def p_tomlEntries_table(p): - """tomlEntries : table""" + """tomlEntries : table NEWLINE""" def p_tomlEntries_object(p): - """tomlEntries : object""" + """tomlEntries : object NEWLINE""" def p_table_simple(p):