Text Parser for IronPython that I can use in Grasshopper

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.

V/r - Mike

a py 2 compatible version is here. maybe it included what you need to do

Ahhh, I was looking at the most recent version, only P3 compatible. Giving it a try…

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

Traceback:
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)

Any thoughts?

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.

Rhino 8 supports CPython 3. That is one possibility

2 Likes

if the error doesn’t tell you what type of error it is, i’m just as lost as you are…

If I bump up to Rhino 8, while the scripting component in Grasshopper use CPython?

Will, the error is that it is not seeing the exceptions.py file ultimately. My fellow Python wizard here is puzzled too.

I followed these instructions to the letter…
http://wiki.bk.tudelft.nl/toi-pedia/Installing_IronPython_modules_for_Grasshopper

There is a new CPython component for grasshopper in Rhino 8

1 Like

Downloaded the WIP, and easily got the Lark parser to load up in RhinoCode and work in Grasshopper. Nice!