grammar InvoiceDSL { token TOP { ^ <invoice>+ % \n* $ } token invoice { <header> \n <line>+ } token header { 'invoice' \h+ <id=string> \h+ 'for' \h+ <client=string> } token line { \h**4 <entry> \n? } token entry { | <item> | <tax> | <discount> } token item { 'item' \h+ <desc=string> \h+ <price=num> \h+ 'x' \h+ <qty=int> } token tax { 'tax' \h+ <percent=num> '%' } token discount { 'discount' \h+ <percent=num> '%' } token string { \" <( <-["]>* )> \" } token num { \d+ [ '.' \d+ ]? } token int { \d+ } }