parsing - Read/parse a ABNF grammar with tags in C++ from a file -



parsing - Read/parse a ABNF grammar with tags in C++ from a file -

i have file contains abnf grammar tags in simplified example:

$name = bertha {userid=013} | bob {userid=429} | ( ben | benjamin ) {userid=265}; $greet = hi | hello | greetings; $s = $greet $name;

now task obtain userid parsing given sentence grammar. example, parsing sentence

greetings bob

should give userid 429. grammars have read in @ runtime because can alter between runs.

my approach following:

parse grammar 1 or multiple trees, putting tags @ leaves or nodes belong to

parse sentence this/those tree(s) build tree creates given sentence(i'm thinking using earley this)

use tree obtain tags (unlike in example, there multiple different tags in such tree)

my question is, there software components can utilize or @ to the lowest degree modify solve task? steps 1 , 2 seem quite generic (1. reading abnf grammar c++ internal representation (e.g. trees); 2. early-algorithm (or that) working internal representation 1.) , writing complete, fault-proof abnf parser step 1 time consuming task me.

i know voicexml grammars work this, unable find parser them. find parser generators generate c++ code single grammar, not practical me because grammars not known @ compile time.

any ideas?

back in 2001 wrote c++ library generate parser rules specified @ run-time. available on sourceforge project buildparse lgpl license. i've used in couple of other projects, , updated work c++ of 2009. if doesn't matter if parser fast, might work or save work rolling own.

basically, you'd need parser parse grammar info structures buildparse uses (you can utilize buildparse well) , run buildparse parser generator generate can recognize tokens.

c++ parsing tags grammar abnf

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -