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!


In reply to Re^2: converting context free grammar to BNF by nido203
in thread converting context free grammar to BNF by nido203

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.