#!/path_to_perl use Parse::RecDescent; $::RD_ERRORS = 1; #Parser dies when it encounters an error $::RD_WARN = 1; #Enable warnings - warn on unused rules &c. $::RD_HINT = 1; # Give out hints to help fix problems. my $grammar = <<'END_OF_GRAMMAR'; # What you said... start : '(' section(s) ')' section : '(' id entry(s) ')' entry : '(' section | keypair ')' keypair : '(' key value ')' END_OF_GRAMMAR my $text; while (<BRD>) { my $new_line = $_; chomp; $text = "$text $new_line"; } my $parser = Parse::RecDescent->new($grammar) or die "Ha Ha, something + is wrong with the syntax, good luck finding the issue!\n"; defined $parser->section($text) or die "It helps if there is a section + to find...";
I'm just writing, I havent tested anything yet, so I'm sure there are a few issues still in my understanding:) Starting to read Why won't this basic Parse::RecDescent example work?
In reply to Re^2: Parsing a file with parentheses to build a hash
by xcellsior
in thread Parsing a file with parentheses to build a hash
by xcellsior
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |