feat(parser): add a test script for the annotation lexer
This commit is contained in:
@@ -9,6 +9,8 @@ class TokenType(Enum):
|
|||||||
# Punctuation
|
# Punctuation
|
||||||
LEFT_PAREN = auto()
|
LEFT_PAREN = auto()
|
||||||
RIGHT_PAREN = auto()
|
RIGHT_PAREN = auto()
|
||||||
|
LEFT_BRACKET = auto()
|
||||||
|
RIGHT_BRACKET = auto()
|
||||||
COLON = auto()
|
COLON = auto()
|
||||||
COMMA = auto()
|
COMMA = auto()
|
||||||
UNDERSCORE = auto()
|
UNDERSCORE = auto()
|
||||||
|
|||||||
15
test.py
Normal file
15
test.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import importlib
|
||||||
|
|
||||||
|
from lexer.annotations import AnnotationLexer
|
||||||
|
from lexer.token import Token
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
])
|
||||||
Reference in New Issue
Block a user