All I want to know/do is read in a file and parse it.The following code will read an input file, parse using Parse::RecDescent, then write the output to a file. I adapted the example code from Parse-RecDescent-FAQ (Super Search is your friend).
The input file consists of just a single line: aa
The output file also consists of just a single line: a
use strict; use warnings; use Parse::RecDescent; use File::Slurp; my $grammar = 'startrule: ( "a" | "aa" ) "a"'; my $parser = Parse::RecDescent->new($grammar); my $text = read_file('input.txt'); write_file('output.txt', $parser->startrule($text), "\n");
Hopefully, you can apply this trivial example to your code. (Keep in mind that this is the 1st time I've ever used Parse::RecDescent.)
In reply to Re^3: Parsing and Translation pt.2 (Parse::RecDescent)
by toolic
in thread Parsing and Translation pt.2
by speedyshady
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |