I’ve been looking for a parser module akin to Lark that I can use in IronPython. End goal is to develop a grammar that gets translated into a geometric structure via grasshopper. Not far from the L-System type plug-ins available at Food4Rhino, but different enough to need to create my own.
Lark is Python 3+ only. Suggestion for alternatives? I’m a little rusty on both python and parsing. I need to parse a context free grammar, so regular expressions aren’t enough.
So I downloaded the “lark_parser-0.12.0-py2.py3-none-any” distro which should work with py2 and therefore IronPython, and I put it in a site where it is in my path now. Restarted Rhino. It appears to see it, but I get this runtime error when it attempts to load the module from within a Grasshopper script…
Runtime error (ImportException): No module named exceptions
line 12, in , …\lark_parser-0.12.0-py2.py3-none-any\lark\parsers\lalr_parser.py"
line 6, in , “…\lark_parser-0.12.0-py2.py3-none-any\lark\parser_frontends.py”
line 16, in , “…\lark_parser-0.12.0-py2.py3-none-any\lark\load_grammar.py”
line 12, in , “…\lark_parser-0.12.0-py2.py3-none-any\lark\lark.py”
line 8, in , “…\lark_parser-0.12.0-py2.py3-none-any\lark_init_.py”
line 13, in script (this is the line where I import lark)
I had to put the lark_parser-0.12.0-py2.py3-none-any folder directly in the path to get this error. Wasn’t enough to put the parent folder that it sits in in the path. Seems to be a path thing. There is an exceptions.py file in same folder as init.py.