maetl / calyx

A Ruby library for generating text with recursive template grammars.
MIT License
61 stars 5 forks source link

Improve the tree representation #14

Open maetl opened 8 years ago

maetl commented 8 years ago

Now that the evaluate method returns an unflattened tree structure with s-expression like data, I need to do some more work to determine what the tree representation should look like.

One particular question is whether the :choice and :concat nodes could be simplified in cases where there is only a single production rather than multiple choices.

The best way to resolve this is probably to try generating some interesting trees and seeing what is useful in practice.

maetl commented 7 years ago

Based on the work done to deal with #13, I’ve seen a few places in the AST where the tree could be pruned. Is mostly to do with unnecessary levels of nesting where the simplified form is semantically equivalent so removing these extraneous nodes is a good idea.