lark-parser / lark

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

Ability to inline branches not documented in the grammar reference #1384

Open kpet opened 5 months ago

kpet commented 5 months ago

The JSON tutorial states:

The question-mark prefixing value (”?value”) tells the tree-builder to inline this branch if it has only one member. In this case, value will always have only one member, and will always be inlined.

Unless I've missed something, this feature is not documented in the grammar reference.

erezsh commented 5 months ago

No, it's mentioned here: https://lark-parser.readthedocs.io/en/latest/tree_construction.html

But you might be right, that the grammar reference should mention it too.

kpet commented 5 months ago

Indeed it is, I'd missed that. I remembered reading about the feature in the tutorial but when I found a need for it in my grammar and wanted to look at the reference, I naturally found myself going to the grammar reference. Either way, I found the info in the tutorial in the end.

(BTW, I didn't open with this but: great project, thank you very much, it's made something really easy for me :))

nchammas commented 5 months ago

I submitted #1381 for a similar reason, though that was just to make the features stand out more in the Tree Construction Reference, rather than add them to the Grammar Reference.