Hi! Sorry for so little information. I'm relatively new to this so I'm still discovering things. I'm using perl5. Bellow is the entire code. I'm trying to translate grammar to BNF
use Parse::RecDescent;
use Data::Dumper;
$::RD_AUTOACTION = q { [@item] };
$grammar = q{
start: seq
seq: '(' seqstr(s) ')'
seqstr: seq | tagstr
tagstr: OZN ( seq | rijec )
OZN: /[A-Z.,?'*:`*]+ /
rijec: /[\w-?,:<*`*]+/
};
my $parser=Parse::RecDescent->new($grammar);
my $result = $parser->start("(SBARQ (WHNP (WP Who))(SQ (VP (VBZ says)(
+, ,)(S (SBAR (`` ``)(IN If)(S (NP (PRP you))(VP (VBP do)(RB n<t)(VP (
+VB look)(ADJP (JJ good)))))(, ,)(S (NP (PRP we))(VP (VBP do)(RB n<t)(
+VP (VB look)(ADJP (JJ good)('' <<)))))))))(? ?))");
print Dumper($result);
I found something similar to code bellow on github and tried to modify it
use Grammar::BNF;
use Parse::RecDescent;
use Data::Dumper;
$::RD_AUTOACTION = q { [@item] };
my $g = Grammar::BNF.generate(Q:to<END>
<start> ::= <seq>
<seq> ::= '(' <seqstr(s)> ')'
<seqstr> ::= <seq> | <tagstr>
<tagstr> ::= <OZN> '(' <seq> | <rijec> ')'
<OZN> ::= /[A-Z.,?'*:`*]+ /
<rijec> ::= /[\w-?,:<*`*]+/
END
);
my $parser=Parse::RecDescent->new($g);
my $result = $parser->start("(SBARQ (WHNP (WP Who))(SQ (VP (VBZ says)(
+, ,)(S (SBAR (`` ``)(IN If)(S (NP (PRP you))(VP (VBP do)(RB n<t)(VP (
+VB look)(ADJP (JJ good)))))(, ,)(S (NP (PRP we))(VP (VBP do)(RB n<t)(
+VP (VB look)(ADJP (JJ good)('' <<)))))))))(? ?))");
print Dumper($result);
This is the message that shows:
"Can't locate Grammar/BNF.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at gramatika_bnf line 1.
BEGIN failed--compilation aborted at gramatika_bnf line 1."
It seems that i have been using wrong syntax but what shoud i'do to fix it? Should i have perl6?
Thank you for your time!
|