Files
ziffers-python/ziffers/parser.py
2023-02-05 16:22:01 +01:00

20 lines
378 B
Python

from rich import print
from .mapper import *
from pathlib import Path
from lark import Lark
grammar_path = Path(__file__).parent
grammar = grammar_path / "ziffers.lark"
ziffers_parser = Lark.open(
grammar,
rel_to=__file__,
start="root",
parser="lalr",
transformer=ZiffersTransformer(),
)
def parse_expression(expr):
return ziffers_parser.parse(expr)