From 6d885a044956bd9c9f73304e3363dc4570df5092 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Thu, 14 May 2026 01:12:05 +0200 Subject: [PATCH] feat(parser): use AST printer in test script --- test.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test.py b/test.py index abc3fc9..551e69a 100644 --- a/test.py +++ b/test.py @@ -1,10 +1,11 @@ import importlib from pathlib import Path +from core.ast.printer import AnnotationAstPrinter from lexer.annotations import AnnotationLexer from lexer.midas import MidasLexer from lexer.token import Token - +from parser.annotations import AnnotationParser # Frame annotation mod = importlib.import_module("examples.00_syntax_prototype.01_simple_types") @@ -12,17 +13,20 @@ mod = importlib.import_module("examples.00_syntax_prototype.01_simple_types") annotation: str = mod.__annotations__["df"] lexer: AnnotationLexer = AnnotationLexer(annotation, "01_simple_types.py") tokens: list[Token] = lexer.process() -print([ - f"{t.type.name}('{t.lexeme}')" - for t in tokens -]) +# print([f"{t.type.name}('{t.lexeme}')" for t in tokens]) + +parser = AnnotationParser(tokens) +parsed = parser.parse() +print(parsed) +for err in parser.errors: + print(err.get_report()) +printer = AnnotationAstPrinter() +if parsed is not None: + print(printer.print(parsed)) # Midas type definitions path: Path = Path("examples") / "00_syntax_prototype" / "02_custom_types.midas" definitions: str = path.read_text() midas_lexer: MidasLexer = MidasLexer(definitions, path.name) tokens = midas_lexer.process() -print([ - f"{t.type.name}('{t.lexeme}')" - for t in tokens -]) +# print([f"{t.type.name}('{t.lexeme}')" for t in tokens])