in reply to Re: converting context free grammar to BNF
in thread converting context free grammar to BNF
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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: converting context free grammar to BNF
by haukex (Archbishop) on May 31, 2016 at 18:42 UTC | |
by nido203 (Novice) on Jun 03, 2016 at 17:57 UTC | |
by haukex (Archbishop) on Jun 04, 2016 at 09:45 UTC | |
by nido203 (Novice) on Jun 04, 2016 at 13:43 UTC |