parglare
parglare copied to clipboard
Import grammar from Python package
Currently grammar can be imported from file system by giving relative path from the importing grammar. In some use-cases one would want to import grammar deployed with some Python package.
In that case additional import variant could be used in the form:
import some.python.module.grammar as a;
grammar
should be a python variable of type string, on the module some.python.module
, containing a path to the grammar file, like:
grammar = os.path.join(os.path.dirname(__file__), 'grammar.pg')