[ I originally posted this in comp.lang.perl.modules. A responder suggested I sent it to this address. ]
I'm trying to learn how to use Parse::RecDescent, so I tried the script demo_Cgrammar.pl that comes with the Parse::RecDescent distribution with Kernighan & Ritchie's canonical hello.c as input. Here's what I get: $ cat hello.c #include <stdio.h> main() { printf("Hello, world.\n"); } $ cc hello.c -o hello $ hello Hello, world. $ perl demo_Cgrammar.pl hello.c bad C code at ./demo_Cgrammar.pl line 13, <> chunk 1. Here's the gist of demo_Cgrammar.pl: use Parse::RecDescent; local $/; my $grammar = <DATA>; my $parser = Parse::RecDescent->new($grammar); my $text = <>; $tree = $parser->translation_unit($text) or die "bad C code"; use Data::Dumper 'Dumper'; print Dumper [ $tree ]; __DATA__ # C grammar, omitted ... Is this a bug in RecDescent, or in demo_Cgrammar.pl? TIA, -Irv