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