feat(parser): add midas lexer to test script
This commit is contained in:
15
test.py
15
test.py
@@ -1,9 +1,12 @@
|
|||||||
import importlib
|
import importlib
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from lexer.annotations import AnnotationLexer
|
from lexer.annotations import AnnotationLexer
|
||||||
|
from lexer.midas import MidasLexer
|
||||||
from lexer.token import Token
|
from lexer.token import Token
|
||||||
|
|
||||||
|
|
||||||
|
# Frame annotation
|
||||||
mod = importlib.import_module("examples.00_syntax_prototype.01_simple_types")
|
mod = importlib.import_module("examples.00_syntax_prototype.01_simple_types")
|
||||||
|
|
||||||
annotation: str = mod.__annotations__["df"]
|
annotation: str = mod.__annotations__["df"]
|
||||||
@@ -12,4 +15,14 @@ tokens: list[Token] = lexer.process()
|
|||||||
print([
|
print([
|
||||||
f"{t.type.name}('{t.lexeme}')"
|
f"{t.type.name}('{t.lexeme}')"
|
||||||
for t in tokens
|
for t in tokens
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# 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
|
||||||
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user