loomis53 has asked for the wisdom of the Perl Monks concerning the following question:
THX for any help!!!#!perl -w use strict; use Parse::RecDescent; $::RD_AUTOACTION = q { [@item[0..$#item]] }; my $grammar = q{ Document : Element(s) Element : Header Body Header : Element_Type Options(?) Element_Type: 'Q::' | 'T::' Options : '(' Arg(s) ')' Arg : /\b(\w+)\s*=\s*(\w+)\s*/xms Open_body : '{' Close_body : '}' Body : Open_body Line(s) Close_body <commit> Line : Element | Text | Text Line Text : /[\s\w]*[^\}]/xms }; my $survey_parser = Parse::RecDescent->new($grammar); undef $/; my $doc = <DATA>; my $tree = $survey_parser->Document($doc); die "no trees" if ! $tree; use Data::Dumper; print Dumper($tree); __DATA__ Q:: (arg1=val arg2=val) { Some text here T:: (arg=value) { Text here } Q:: (argn=etc) { T:: { optional args not included } } }
2006-05-26 Retitled by Arunbear, as per Monastery guidelines
Original title: 'P::RD help'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: nested parsing with Parse::RecDescent
by philcrow (Priest) on May 26, 2006 at 12:14 UTC | |
by loomis53 (Novice) on May 26, 2006 at 15:04 UTC | |
|
Re: nested parsing with Parse::RecDescent
by blazar (Canon) on May 26, 2006 at 09:49 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |