Thank you so much guys, I learned some things that were confusing me and turns out that it is ok to just use Parse::RecDescent without BNF. This really helps. I have just one question. As I must use Parse::RecDescent and not Marpa, I need to parse Abstract syntax tree and copy data from dumper to array and then export it to JSON format. The code is this:
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 (WHADVP (WRB Where))(SQ (VBZ is)(N +P (NNP Inoco))(VP (VBN based)))(. ?))"); print Dumper($result);
In reply to Re^2: converting context free grammar to BNF
by nido203
in thread converting context free grammar to BNF
by nido203
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |