my $grammar = <<'__END_OF_GRAMMAR__'; { use strict; use warnings; } list : '(' item(s) ')' { $item[2] } item : list { $item[1] } | word word : /[^()]*/ __END_OF_GRAMMAR__