mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Fix bugs in the tokenizer
- Fix bug where empty strings were not recognized - Add an end index to the tokenizer's compile error
This commit is contained in:
parent
f8478adf3a
commit
b4d4877e07
1 changed files with 3 additions and 3 deletions
|
@ -47,8 +47,8 @@ class TokenType(Enum):
|
||||||
_tokens = [
|
_tokens = [
|
||||||
(TokenType.DIRECTIVE, r"@[\d\w\-_]+"),
|
(TokenType.DIRECTIVE, r"@[\d\w\-_]+"),
|
||||||
(TokenType.IDENT, r"[A-Za-z_][\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"[-+]?[\d_]+(\.[\d_]+)?"),
|
||||||
(TokenType.NUMBER, r"0x[A-Fa-f0-9]+"),
|
(TokenType.NUMBER, r"0x[A-Fa-f0-9]+"),
|
||||||
(TokenType.OPEN_PAREN, r"\("),
|
(TokenType.OPEN_PAREN, r"\("),
|
||||||
|
@ -107,7 +107,7 @@ def _tokenize(ui_ml: str):
|
||||||
break
|
break
|
||||||
|
|
||||||
if not matched:
|
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)
|
yield Token(TokenType.EOF, i, i, ui_ml)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue