Examples
US POSTAL ADDRESS
Diagram(
Group(
Sequence(
Optional(
Sequence(
NonTerminal('Company Name', '', '', 'optional-path'),
Terminal(',', '', '', 'optional-path')
),
'skip'
),
NonTerminal('Addressee Name'),
Terminal(','),
NonTerminal('Street One'),
Terminal(','),
Optional(
Sequence(
NonTerminal('Street Two', '', '', 'optional-path'),
Terminal(',', '', '', 'optional-path')
),
'skip'),
NonTerminal('City'),
Terminal(','),
NonTerminal('State'),
Terminal(','),
NonTerminal('Postal Code')
),
'US Postal Address'
)
)
BUYING A CUPCAKE
Diagram(
Sequence(
Group(
Choice(
1,
NonTerminal('Cherry'),
NonTerminal('Chocolate'),
NonTerminal('Dark Chocolate')
),
'Which cupcake?'
),
Group(
Choice(
1,
NonTerminal('Vanilla'),
NonTerminal('Chocolate'),
NonTerminal('Strawberry')
),
'Which icing?'
),
Group(
ZeroOrMore(
NonTerminal('Rainbow Sprinkles','','','optional-path'),
Comment('Up to 4 shakes'),
'skip'
),
'Sprinkles?'
),
NonTerminal('Pay'),
NonTerminal('Eat'),
Comment('Yummm!')
)
)
Diagram(
Stack(
Group(
Sequence( NonTerminal( "Rhyme A Line" ), NonTerminal( "Rhyme B Line" ), NonTerminal( "Rhyme A Line" ), NonTerminal( "Rhyme B Line" ) ),
"Quatrain 1"
),
Group(
Sequence( NonTerminal( "Rhyme C Line" ), NonTerminal( "Rhyme D Line" ), NonTerminal( "Rhyme C Line" ), NonTerminal( "Rhyme D Line" ) ),
"Quatrain 2"
),
Group(
Sequence( NonTerminal( "Rhyme E Line" ), NonTerminal( "Rhyme F Line" ), NonTerminal( "Rhyme E Line" ), NonTerminal( "Rhyme F Line" ) ),
"Quatrain 3"
),
Group(
Sequence( NonTerminal( "Rhyme G Line" ), NonTerminal( "Rhyme G Line" ) ),
"Couplet"
)
)
)
NUMBER
Diagram(
Choice(1, '+', Skip(), '-'),
Choice(0,
Sequence(
OneOrMore( NonTerminal('digit') ),
'.',
OneOrMore( NonTerminal('digit') )
),
Sequence(
Optional( '.', 'skip' ),
OneOrMore( NonTerminal('digit') )
)
),
Choice(0,
Skip(),
Sequence(
Choice( 0, 'e', 'E' ),
Choice( 1, '+', Skip(), '-' ),
OneOrMore( NonTerminal('digit') )
)
)
)
STRING
Diagram(
Choice(0,
Sequence(
'"',
ZeroOrMore(
Choice(0,
NonTerminal('not " or \\'),
NonTerminal('escape'))),
'"'),
Sequence(
"'",
ZeroOrMore(
Choice(0,
NonTerminal("not ' or \\"),
NonTerminal('escape'))),
"'")))
URL
Diagram(
Choice(0, 'u', 'U'),
Choice(0, 'r', 'R'),
Choice(0, 'l', 'L'),
'(',
Choice(1,
Optional(NonTerminal('WS')),
Sequence(
Optional(NonTerminal('WS')),
NonTerminal('STRING', '#string'),
Optional(NonTerminal('WS'))),
Sequence(
Optional(NonTerminal('WS')),
OneOrMore(
Choice(0,
NonTerminal('not " \' ( ) WS or NPC'),
NonTerminal('escape'))),
Optional(NonTerminal('WS')))),
')')
UNICODE-RANGE
Diagram(
Choice(0,
'U',
'u'),
'+',
Choice(0,
Sequence(OneOrMore(NonTerminal('hex digit'), Comment('1-6 times'))),
Sequence(
ZeroOrMore(NonTerminal('hex digit'), Comment('1-5 times')),
OneOrMore('?', Comment('1 to (6 - digits) times'))),
Sequence(
OneOrMore(NonTerminal('hex digit'), Comment('1-6 times')),
'-',
OneOrMore(NonTerminal('hex digit'), Comment('1-6 times')))))
SQL STATEMENT
Diagram(
Stack(
Sequence(
'SELECT',
Optional(Terminal('DISTINCT','','','optional-path'), 'skip'),
Choice(0,
'*',
OneOrMore(
Sequence(NonTerminal('expression'), Optional(Sequence('AS', NonTerminal('output_name')))),
','
)
),
'FROM',
OneOrMore(NonTerminal('from_item'), ','),
Optional(Sequence('WHERE', NonTerminal('condition')))
),
Sequence(
Optional(Sequence('GROUP BY', NonTerminal('expression'))),
Optional(Sequence('HAVING', NonTerminal('condition'))),
Optional(Sequence(
Choice(0, 'UNION', 'INTERSECT', 'EXCEPT'),
Optional('ALL'),
NonTerminal('select')
))
),
Sequence(
Optional(Sequence(
'ORDER BY',
OneOrMore(Sequence(NonTerminal('expression'), Choice(0, Skip(), Terminal('ASC','','','optional-path'), Terminal('DESC','','','optional-path'))), ','))
),
Optional(Sequence(
'LIMIT',
Choice(0, NonTerminal('count'), 'ALL')
)),
Optional(Sequence('OFFSET', NonTerminal('start'), Optional('ROWS')))
)
)
)
SHIPMENT ADVICES
Diagram(
Stack(
Sequence(
NonTerminal('customerId'),
NonTerminal('batchId'),
NonTerminal('batchDate')
),
OneOrMore(
Group(
Stack(
NonTerminal('customerOrder'),
Optional(
Group(
Sequence(
NonTerminal('name', '', '', 'optional-path'),
NonTerminal('purchaseOrder', '', '', 'optional-path'),
Optional(
NonTerminal('purchaseOrderDate', '', '', 'optional-path'),
'skip'
)
),
'tradingPartner'
),
'skip'
),
Group(
Sequence(
NonTerminal('carrier'),
NonTerminal('service')
),
'transport'
),
Group(
Sequence(
Optional(
NonTerminal('companyName', '', '', 'optional-path'),
'skip'
),
NonTerminal('contactName'),
NonTerminal('streetOne'),
Optional(
NonTerminal('streetTwo', '', '', 'optional-path'),
'skip'
),
NonTerminal('city'),
NonTerminal('state'),
NonTerminal('postalCode'),
Optional(
NonTerminal('countryCode')
)
),
'shipToAddress'
),
OneOrMore(
Group(
Sequence(
NonTerminal('item'),
NonTerminal('quantity'),
NonTerminal('uom'),
Optional(
NonTerminal('lot', '', '', 'optional-path'),
'skip'
)
),
'detail'
)
)
),
'shipmentAdvice'
)
)
)
)