Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open source ABNF Parser implementation for Java? [closed]

Tags:

java

parsing

I need an Augmented Backus-Naur Form Parser (RFC 5234) in Java to validate some languages.

In the interest of not re-inventing the wheel, I would prefer to use an existing open source implementation of ABNF Parser if one already exists.

I need open source because it allows me to maintain the code as needed.

Does anyone know of any that exists?

like image 966
Jin Kim Avatar asked Mar 14 '11 18:03

Jin Kim


2 Answers

I have made the observation that Parse2 (see answer by Ralph) comes with some limitations:

  • aparse doesn't like the comments and they have to be removed manually prior to code generation
  • all statements need to end with a ; at the end of the line
  • aparse does not apply the "core" ABNF rules as defined RFC 5234 so they have to be copied from the RFC if your grammar is based on them
  • aparse does not like loops in the grammar ( e.g. S --> NT1 NT2 T1 ; NT1 --> S | T2 ; ...) and might run into endless loops.

These observations have been confirmed by the developer of Parse2. So in short: Parse2 can parse a subset of ABNF grammars, however it will most likely have problems if you find an existing ABNF grammar and try to feed it to the software.

If you specify the ABNF grammars yourself and keep these limitations in mind, this library should work for you. If you have to work with existing ABNF grammars you might have to put additional effort into the grammar prior to code generation.

PS: the Parse2 library source code is currently not available even though the compiled binary (java byte code) is available freely.

like image 143
Ray Avatar answered Oct 20 '22 22:10

Ray


Parse2 generates source java for a parser from ABNF.

like image 25
Ralph Avatar answered Oct 20 '22 21:10

Ralph