diff --git a/blueprintcompiler/tokenizer.py b/blueprintcompiler/tokenizer.py index 33ae272..6cc0761 100644 --- a/blueprintcompiler/tokenizer.py +++ b/blueprintcompiler/tokenizer.py @@ -39,8 +39,8 @@ class TokenType(Enum): _tokens = [ (TokenType.IDENT, r"[A-Za-z_][\d\w\-_]*"), - (TokenType.QUOTED, r'"(\\.|[^\\"\n])*"'), - (TokenType.QUOTED, r"'(\\.|[^\\'\n])*'"), + (TokenType.QUOTED, r'"(\\(.|\n)|[^\\"\n])*"'), + (TokenType.QUOTED, r"'(\\(.|\n)|[^\\'\n])*'"), (TokenType.NUMBER, r"0x[A-Za-z0-9_]+"), (TokenType.NUMBER, r"[\d_]+(\.[\d_]+)?"), (TokenType.NUMBER, r"\.[\d_]+"), diff --git a/blueprintcompiler/utils.py b/blueprintcompiler/utils.py index 25803d7..6f2bd40 100644 --- a/blueprintcompiler/utils.py +++ b/blueprintcompiler/utils.py @@ -124,6 +124,7 @@ def unescape_quote(string: str) -> str: string = string[1:-1] REPLACEMENTS = { + "\n": "\n", "\\": "\\", "n": "\n", "t": "\t", diff --git a/tests/samples/multiline_string.blp b/tests/samples/multiline_string.blp new file mode 100644 index 0000000..ec4c8f8 --- /dev/null +++ b/tests/samples/multiline_string.blp @@ -0,0 +1,6 @@ +using Gtk 4.0; + +Label { + label: "Hello,\ +world!"; +} diff --git a/tests/samples/multiline_string.ui b/tests/samples/multiline_string.ui new file mode 100644 index 0000000..38750d7 --- /dev/null +++ b/tests/samples/multiline_string.ui @@ -0,0 +1,13 @@ + + + + + + Hello, +world! + +