[ create a new paste ] login | about

Link: http://codepad.org/9TlTfIfd    [ raw code | output | fork ]

Perl, pasted on Jun 20:
#!/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");


Output:
1
2
Can't locate Parse/RecDescent.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i486-linux /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i486-linux /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl .) at line 4.
BEGIN failed--compilation aborted at line 4.


Create a new paste based on this one


Comments: