New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a "Auto-Stack" that overflows a Sequence into a Stack #5

Open
lukaslueg opened this Issue Aug 12, 2018 · 0 comments

Comments

1 participant
@lukaslueg
Owner

lukaslueg commented Aug 12, 2018

Most syntax diagrams run long horizontally but not vertically. It's also true - and related - that most syntax diagrams are made up from long Sequences but few Choices (which in turn have long Sequences). An example are the bitflags()- and named-attrs-macros.

It would be very useful to have a AutoStack which acts like a Sequence, yet has a desired aspect ratio (think 16:9). If the resulting geometry runs too long horizontally, it overflows elements into a Stack until the desired aspect ratio is reached or no actions are possible. An example of a Stack is "06_create-virtual-table-stmt_diagram.txt", where a long-running Sequence (manually) overflows into a Stack of three lanes.

To avoid overflowing just one element into the most bottom lane (where the bottom lane is mostly just one element and a long connector), the algorithm probably looks something like:

  • Our input is the same as Sequence
  • Init Y to 1
  • As long as our Stack is wider than the threshold
    • Increment Y
    • Divide the input into Y parts of equal width and those as lanes in our Stack

It's Ok if the resulting AutoStack-struct is immutable, that is, we don't allow modifcation where we have to re-compute everything.

We'd then simply switch Sequence to AutoStack in macro_railroad's diagram generator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment