F
freesoft12
Hi,
I am new to Parse::RecDescent and I came across this problem of the
parser not being able to ignore the newline character. Is there a way
I can ask the parser to ignore all newlines?
Regards
John
### parser_test.pl ###
eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' && eval 'exec
perl -w -S $0 $argv:q' if 0;
#
use strict;
use diagnostics;
use Parse::RecDescent;
my $grammar = q {
start: identifier(s)
identifier : /\S+/
{ print $item[0]."\n"; }
};
my $parser = Parse::RecDescent->new($grammar);
open(IN,"data.txt") or die "Cannot open data.txt";
# slurp all the lines
my @lines = <IN>;
defined $parser->start(@lines) or die "Didn't match anything";
### end of parser
# data.txt
Head node1
Tail node2
I am new to Parse::RecDescent and I came across this problem of the
parser not being able to ignore the newline character. Is there a way
I can ask the parser to ignore all newlines?
Regards
John
### parser_test.pl ###
eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' && eval 'exec
perl -w -S $0 $argv:q' if 0;
#
use strict;
use diagnostics;
use Parse::RecDescent;
my $grammar = q {
start: identifier(s)
identifier : /\S+/
{ print $item[0]."\n"; }
};
my $parser = Parse::RecDescent->new($grammar);
open(IN,"data.txt") or die "Cannot open data.txt";
# slurp all the lines
my @lines = <IN>;
defined $parser->start(@lines) or die "Didn't match anything";
### end of parser
# data.txt
Head node1
Tail node2