#!/usr/bin/perl -w
use strict;
use Parse::RecDescent;
# Enable warnings within the Parse::RecDescent module.
$::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error
$::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c.
$::RD_HINT = 1; # Give out hints to help fix problems.
my $grammar = <<'_EOGRAMMAR_';
# Terminals (macros that can't expand further)
#
_A : 'A'
_B : 'B'
_C : 'C'
_D : 'D'
abcd : _A BCD_Star B_Opt
{ print "!!\n"; return "abcd"; }
BCD_Star : | BCD BCD_Star
BCD : _B _C _D
B_Opt : | _B
startrule: abcd(s /;/)
{ print ">abcd<\n"; }
_EOGRAMMAR_
my $grammar = Parse::RecDescent->new($grammar);
$grammar->startrule("ABCD");