paulstansifer / unseemly

Macros have types!
http://unseemly.github.io/
MIT License
129 stars 5 forks source link

Parsing: Replace `Biased` with a priority system. #50

Open paulstansifer opened 3 years ago

paulstansifer commented 3 years ago

Nested Alts and Biaseds are (a) hard to understand, and (b) impossible to add to, making ::=also limited in what it can do.

Instead:

That way, rules can be usefully prioritized when extending grammars.

This shouldn't be too hard. It will require adjusting LocalParse, but that it's just a matter of changing JustifiedByAtomPlanB and thinking through how prioritized and non-prioritized rules relate to each other. (Maybe they have priority 0, and you can set priorities both positive and negative?) Might also need to think about when a partial parse "loses" its priority.

paulstansifer commented 2 years ago

I don't like that this adds numbers to the core language. But I think it's the only reasonable approach.

I guess there's already numeric types, and one through ten, and anything_to_string even assumes base-10. But there's no way to relegate this to core_extra_forms.rs.