unseemly icon indicating copy to clipboard operation
unseemly copied to clipboard

Parse zero repetitions of something correctly

Open paulstansifer opened this issue 6 years ago • 1 comments

When we assemble a Node from its constituent Ast, we should check to see if any Named names in its grammar are absent from the parse result so far. If so, we should store them as zero copies of a repeated term because that's (presumably) what they are.

(They could also be under a branch of an Alt, but this seems like it's still an improvement in this case.)

See the TODO in earley::c_parse, in the Scope case.

End-to-end test that otherwise fails:

assert_m!(eval_unseemly_program("( .[ a : struct {} . a]. *[extra : five]*)"), Ok(_));

paulstansifer avatar Jun 29 '19 11:06 paulstansifer

The proposed method isn't a complete fix; what if we have Star(Star(Named(...))? You might have 5 copies at the first layer, each of which has zero copies, or you might have zero copies at the first layer (and the difference might matter).

The current representation for EnvMBEs is bad (#45), but I've made it more possible to represent zero-repetition repeats in this commit: https://github.com/paulstansifer/unseemly/commit/4973d811fe2485bdfbc388cae9160cfd6415e226

paulstansifer avatar May 16 '22 01:05 paulstansifer