parameterizedExamples

Example of parameterized rules. Pick and chose the ones you need.

enum parameterizedExamples = ` Parameterized: # Standard list: skip spaces, drop the separator # Minimum one Elem List(Elem, Sep) < Elem (:Sep Elem)* # A list accepting 0 element as a valid input List0(Elem, Sep) < List(Elem, Sep)? # Standard comma-separated list CommaList(Elem) < List(Elem, ',') # Standard space-separated list SpaceList(Elem) < List(Elem, ' ') # Standard array rule: [1, 2, ... ]. Array(Elem) < :'[' List0(Elem, ',') :']' # Apply Pattern until End Until(Pattern, End) <- (!End Pattern)* :End # Everything but the End marker. Concatenates the entire match But(End) <~ Until(., End) # Input delimited by a begin and a close marker Delimited(Begin, Close) <- :Begin But(Close) # Standard double-quoted string String <- Delimited(doublequote, doublequote) # Line (everything to the end of the line) Line <- Delimited(eps, endOfLine) # Line comment LineComment <- Delimited(:"//", endOfLine) `;

Meta