BNFC / bnfc

BNF Converter
http://bnfc.digitalgrammars.com/
583 stars 162 forks source link

Layout: allow other list delimiters #355

Open andreasabel opened 3 years ago

andreasabel commented 3 years ago

Currently, the delimiters for lists with layout are hardwired to the Haskell ones, { ; }.

This could be relaxed, by analysing which form of list layout keywords are followed.

For the top level layout, the separator should be picked up from the entry point. Actually, we should be able to specify for each entrypoint whether it has top-level layout or not.

The layout processor would remember with each layout block which layout keyword introduced the block. There would be a map from layout keywords to the respective delimiters (layoutOpen, layoutClose, layoutSep) so that the correct delimiters can be inserted. Explicit blocks need not remember the delimiters, as we are not checking well-bracketness in this phase.

For finding out the delimiters from the LBNF grammar, we need to implement a FOLLOW analysis.

andreasabel commented 3 years ago

For finding out the delimiters from the LBNF grammar, we need to implement a FOLLOW analysis.

Possibly reuse the analysis functionality of https://github.com/nedervold/context-free-grammar, as this package is maintained again (nedervold/context-free-grammar#3).