lark-parser / lark

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

How do weights work on Lark rules / terminals? #1491

Open FruitfulApproach opened 3 days ago

FruitfulApproach commented 3 days ago

I've googled around the docs and found no info on this and the issues forum posts about weights don't mention how they work.

So is .1 higher priority than .2 ?

I'm using Earley parser because the grammar is just too hard to disambiguate or remove collisions from when using LALR.

FruitfulApproach commented 3 days ago

I was thinking of using weights on various math operators. E.g. * will always have higher priority than + because in math that's how things are done conventionally.