nope/py-helpers/prepare_code/js/parser.py

14 lines
324 B
Python
Raw Normal View History

2022-07-17 20:24:55 +00:00
from lark import Lark
from pathlib import Path
# Define the Grammar File.
2022-07-21 21:31:19 +00:00
grammar_file_path = Path(__file__).parent.joinpath('grammar.js.lark')
2022-07-17 20:24:55 +00:00
def get_parser():
""" Helper, to generate a parser.
Returns:
A lark parser
"""
return Lark.open(grammar_file_path,debug = True, maybe_placeholders=True)