NAME

Parse::YALALR - Yet Another LALR parser

SYNOPSIS

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);

DESCRIPTION

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);

AUTHOR

Steve Fink <steve@fink.com>

SEE ALSO

Parse::YALALR