Parse::YALALR - Yet Another LALR parser
From the command line: % yalalr [--lang=c] [--lang=perl] grammar.y In a program: use Parse::YALALR::Build; use Parse::YALALR::Run; open(GRAMMAR, "<expr.y") or die "open expr.y: $!"; $builder = Parse::YALALR::Build->new("perl", \*GRAMMAR); $builder->build_table(); $parser = $builder->{parser}; @inputstream = ([number=>10], ["'+'"=> undef ], [number=>20]); $_->[0] = $parser->{symmap}->get_index($_->[0]) foreach (@inputstream); Parse::YALALR::Run::run_parser($parser, \@inputstream);
Generates an LALR parser from an input grammar. Really just intended as a companion to Parse::Vipar, but (sorta) works standalone. Does not yet generate a standalone parser.
run_parser will also accept a CODE ref to use as a lexer. Every invocation should return a pair (token, value). The above example is equivalent to
$lexer = { my $i = 0; sub { my ($t,$v)=@{$inputstream[$i++]}; ($parser->get_index($t), $v) } }; Parse::YALALR::Run::run_parser($parser, $lexer);
Steve Fink <steve@fink.com>
Parse::YALALR
To install item, copy and paste the appropriate command in to your terminal.
cpanm
cpanm item
CPAN shell
perl -MCPAN -e shell install item
For more information on module installation, please visit the detailed CPAN module installation guide.