Type: New Feature
Resolution: Won't Do
Affects Version/s: None
Fix Version/s: None
QA Risk Assessment:Needs Assessment
I'd like to be able to match context-free languages using the type system. Most of the pieces are there, but it needs a Concat or Combinator type. Here's how I see it working.
The Concat type would take multiple Scalars and all of its sub-types (converted to match strings), other Concat types, Undef and Optional where Undef matches the empty string, plus Variant types containing all these types (or maybe a new type of restricted Variant). The type would concatenate its parameter types to create a recognizer for larger strings. For example the following would match the strings 'foo bar' and 'foobar'.
This could also be used to match complete contex-free languages. Take the textbook example of balanced parentheses.
S → SS
S → (S)
S → ε
Or in BNF
This could be expressed using Puppet type aliases as follows.
This alone could match some really complex things, like a user-defined subset of JSON, however it would be very difficult and ugly without PUP-7033.