lark-parser / lark

Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.
MIT License
4.62k stars 395 forks source link

Lark.open_from_package() does not support namespace packages #1410

Closed michaeltryby closed 2 months ago

michaeltryby commented 2 months ago

Describe the bug

Lark.open_from_package() cannot load grammars located in namespace packages.

To Reproduce

Place a grammar in a namespace package and then try to load it using open_from_package(). Lark issues the following exception when it can't find the grammar file: lark.exceptions.GrammarError: Using an undefined rule: NonTerminal('start')

P.S. I love Lark!

MegaIng commented 2 months ago

The fact that it manges to raise this errors means it did find the grammar file, or it found a different grammar file. What does the grammar file contain?

michaeltryby commented 2 months ago

Thanks for the insight @MegaIng. Happy to report that I set up the namespace wrong. Lark.open_from_package() is working great.

Closing the issue.