tokenizer: Allow escaped newlines

The docs said multi-line strings were possible by escaping the newline
character, but this was not actually implemented.

Fixes #132.
This commit is contained in:
James Westman 2023-10-26 18:50:07 -05:00
parent 9543b78138
commit 2faa9207de
4 changed files with 22 additions and 2 deletions

View file

@ -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_]+"),