diff --git a/src/interpreted/parser.py b/src/interpreted/parser.py index 70ab284..e8cf247 100644 --- a/src/interpreted/parser.py +++ b/src/interpreted/parser.py @@ -15,6 +15,7 @@ Compare, Constant, Continue, + Decorator, Dict, Expression, ExprStmt, @@ -35,7 +36,6 @@ UnaryOp, While, alias, - Decorator ) from interpreted.tokenizer import EOF, Token, TokenType, index_to_line_column, tokenize @@ -177,7 +177,7 @@ def expect_op(self, op: str) -> None: if not self.match_op(op): token = self.peek() raise ParseError(f"Expected '{op}', found '{token.string}'", self.index) - + def expect_name(self, name: str) -> None: if not self.match_name(name): token = self.peek() @@ -196,7 +196,7 @@ def parse_statement(self) -> Statement: while self.match_type(TokenType.NEWLINE): pass - if self.peek().string == '@': + if self.peek().string == "@": decorators = self.parse_decorators() self.expect_name("def") function_def = self.parse_function_def() @@ -205,7 +205,7 @@ def parse_statement(self) -> Statement: if self.match_name("def", "if", "for", "while"): return self.parse_multiline_statement() return self.parse_single_line_statement() - + def parse_decorators(self) -> list[Decorator]: decorators = [] while self.match_op("@"): @@ -214,7 +214,7 @@ def parse_decorators(self) -> list[Decorator]: decorators.append(Decorator(value=expression)) return decorators - + def parse_multiline_statement(self) -> FunctionDef | For | If | While: keyword = self.current().string if keyword == "def":