mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
cleanup: Format using black
This commit is contained in:
parent
4b42016837
commit
af03c2ac0f
36 changed files with 928 additions and 616 deletions
|
@ -26,27 +26,27 @@ from .errors import CompileError
|
|||
|
||||
|
||||
class TokenType(Enum):
|
||||
EOF = 0
|
||||
IDENT = 1
|
||||
QUOTED = 2
|
||||
NUMBER = 3
|
||||
OP = 4
|
||||
WHITESPACE = 5
|
||||
COMMENT = 6
|
||||
PUNCTUATION = 7
|
||||
EOF = 0
|
||||
IDENT = 1
|
||||
QUOTED = 2
|
||||
NUMBER = 3
|
||||
OP = 4
|
||||
WHITESPACE = 5
|
||||
COMMENT = 6
|
||||
PUNCTUATION = 7
|
||||
|
||||
|
||||
_tokens = [
|
||||
(TokenType.IDENT, r"[A-Za-z_][\d\w\-_]*"),
|
||||
(TokenType.QUOTED, r'"(\\"|[^"\n])*"'),
|
||||
(TokenType.QUOTED, r"'(\\'|[^'\n])*'"),
|
||||
(TokenType.NUMBER, r"[-+]?[\d_]+(\.[\d_]+)?"),
|
||||
(TokenType.NUMBER, r"0x[A-Fa-f0-9]+"),
|
||||
(TokenType.WHITESPACE, r"\s+"),
|
||||
(TokenType.COMMENT, r"\/\*[\s\S]*?\*\/"),
|
||||
(TokenType.COMMENT, r"\/\/[^\n]*"),
|
||||
(TokenType.OP, r"[:=\.=\|<>\+\-/\*]+"),
|
||||
(TokenType.PUNCTUATION, r"\(|\)|\{|\}|;|\[|\]|\,"),
|
||||
(TokenType.IDENT, r"[A-Za-z_][\d\w\-_]*"),
|
||||
(TokenType.QUOTED, r'"(\\"|[^"\n])*"'),
|
||||
(TokenType.QUOTED, r"'(\\'|[^'\n])*'"),
|
||||
(TokenType.NUMBER, r"[-+]?[\d_]+(\.[\d_]+)?"),
|
||||
(TokenType.NUMBER, r"0x[A-Fa-f0-9]+"),
|
||||
(TokenType.WHITESPACE, r"\s+"),
|
||||
(TokenType.COMMENT, r"\/\*[\s\S]*?\*\/"),
|
||||
(TokenType.COMMENT, r"\/\/[^\n]*"),
|
||||
(TokenType.OP, r"[:=\.=\|<>\+\-/\*]+"),
|
||||
(TokenType.PUNCTUATION, r"\(|\)|\{|\}|;|\[|\]|\,"),
|
||||
]
|
||||
_TOKENS = [(type, re.compile(regex)) for (type, regex) in _tokens]
|
||||
|
||||
|
@ -59,7 +59,7 @@ class Token:
|
|||
self.string = string
|
||||
|
||||
def __str__(self):
|
||||
return self.string[self.start:self.end]
|
||||
return self.string[self.start : self.end]
|
||||
|
||||
def get_number(self):
|
||||
if self.type != TokenType.NUMBER:
|
||||
|
@ -86,7 +86,9 @@ def _tokenize(ui_ml: str):
|
|||
break
|
||||
|
||||
if not matched:
|
||||
raise CompileError("Could not determine what kind of syntax is meant here", i, i)
|
||||
raise CompileError(
|
||||
"Could not determine what kind of syntax is meant here", i, i
|
||||
)
|
||||
|
||||
yield Token(TokenType.EOF, i, i, ui_ml)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue