From b4d4877e07747582c0eddc14d06e3b498cabfbec Mon Sep 17 00:00:00 2001 From: James Westman Date: Fri, 12 Nov 2021 09:42:48 -0600 Subject: [PATCH] Fix bugs in the tokenizer - Fix bug where empty strings were not recognized - Add an end index to the tokenizer's compile error --- gtkblueprinttool/tokenizer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtkblueprinttool/tokenizer.py b/gtkblueprinttool/tokenizer.py index 80d6fe8..0368899 100644 --- a/gtkblueprinttool/tokenizer.py +++ b/gtkblueprinttool/tokenizer.py @@ -47,8 +47,8 @@ class TokenType(Enum): _tokens = [ (TokenType.DIRECTIVE, r"@[\d\w\-_]+"), (TokenType.IDENT, r"[A-Za-z_][\d\w\-_]*"), - (TokenType.QUOTED, r'"(\\"|[^"\n])+"'), - (TokenType.QUOTED, r"'(\\'|[^'\n])+'"), + (TokenType.QUOTED, r'"(\\"|[^"\n])*"'), + (TokenType.QUOTED, r"'(\\'|[^'\n])*'"), (TokenType.NUMBER, r"[-+]?[\d_]+(\.[\d_]+)?"), (TokenType.NUMBER, r"0x[A-Fa-f0-9]+"), (TokenType.OPEN_PAREN, r"\("), @@ -107,7 +107,7 @@ def _tokenize(ui_ml: str): break if not matched: - raise CompileError("Could not determine what kind of syntax is meant here", i) + raise CompileError("Could not determine what kind of syntax is meant here", i, i) yield Token(TokenType.EOF, i, i, ui_ml)