$grammar = <<'__END_OF_GRAMMAR__'; { use strict; use warnings; $skip = qr/[ \t]*/; } # Returns a ref to an array of lines. parse : line(s?) /$/ { $item[1] } # Returns a ref to an array of atoms and lists. line : term(s?) /\n/ { $item[1] } # Returns an atom or a list. # An atom looks like: [ atom => "text" ] # A list is a ref to an array of atoms and/or lists. term : '{' term(s?) '}' { [ list => $item[2] ] } | /[^{} \t\n]+/ { [ atom => $item[1] ] } __END_OF_GRAMMAR__