lukaslueg / macro_railroad

A library to generate syntax diagrams for Rust macros.
MIT License
529 stars 11 forks source link

Make it visually easier to recognize similar sub-patterns #12

Closed Boscop closed 5 years ago

Boscop commented 5 years ago

In many macros, multiple branches share a lot of similar sub-patterns. It would be easier to visually read the diagrams if the similar sub-patterns were aligned. E.g. aligning the 4 occurrences of macro_name ! into one column in this example, and also aligning the 2 occurrences of values = vf ,.

And for macros where a sub-patterns appears verbatim in multiple branches of the macro (or multiple times in one branch), it would make sense to highlight that they are not just similar but the same, by factoring out that sub-pattern into its own sub-rule diagram (and then inserting the name of the sub-rule (or an arrow to the sub-rule diagram) in place of the occurrences of the sub-pattern).

lukaslueg commented 5 years ago

Moved to https://github.com/lukaslueg/railroad/issues/10 since this is generic