The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Yacc - allow users to input grammars using a Yacc-like syntax

DESCRIPTION

This is an example of a syntax-directed translator. It is intended to be used as follows: write a yacc-style grammar in a separate file, with a line at the bottom that will call this module. Output the result to a file, and require the resultant perl data structure into your code. The name of the variable is "grammar" by default. Example:

use Parser::Input::Yacc;
use Scanner::Stream::String;

$grammar = new Scanner::Stream::String(<<'EOG');
start:   $SAMPLE  { print "sample\n"; }
       | $EXAMPLE { print "example\n"; }
       ;
EOG

Parser::Input::Yacc::Convert($grammar, "grammar");