Update Kind of works, but I realized it allows continuation lines before a prop
use strict; use Parse::RecDescent; $::TestGrammar = <<'TG'; Output: PropLine(s) /\Z/ PropLine: CommentLine | SimpleProp | ContinuationLine CommentLine: /\#.*\n/ { print "RULE: $item{__RULE__}\n"; print "MATCH: $item{__PATTERN1__}\n"; } SimpleProp: VAR EQ VAL { print "RULE: $item{__RULE__}\n"; print "VAR: $item{VAR}\n"; print "EQ: $item{EQ}\n"; print "VAL: $item{VAL}\n\n"; } VAR: /^[^=\n]+/ EQ: '=' VAL: /.+/ ContinuationLine: VAL { print "RULE: $item{__RULE__}\n"; print "VAL: $item{VAL}\n\n"; } TG undef $/; my $foo = <DATA>; my $parser = Parse::RecDescent->new($::TestGrammar); defined $parser->Output($foo) or die "FAILURE"; __DATA__ # Comment Line # Comment #2 foo=this is property one but bar=does it grab this one too? baz=snark
In reply to Re: Modifying Parse::RecDescent Grammar to deal with multiline property file entries
by suaveant
in thread Modifying Parse::RecDescent Grammar to deal with multiline property file entries
by chahn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |