Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaME-suitable grammar compiler recommendations?

I want to parse some data, and I have a BNF grammar to parse it with. Can anyone recommend any grammar compilers capable of generating code that can be used on a mobile device?

Since this is for JavaME, the generated code must be:

  • Hopefully pretty small
  • Low dependencies on exotic Java libraries
  • Not dependant on any runtime jar files.
like image 310
izb Avatar asked Dec 20 '25 13:12

izb


2 Answers

I have used JFlex before, and I know it satisfies your second and third requirements. But I don't know how big the generated code might be. According to the manual, it generates a packed DFA table by default, so it might not be too bad.

like image 67
Michael Myers Avatar answered Dec 23 '25 08:12

Michael Myers


The first question is do you have an existing grammar definition? When I've ported a LALR grammar to Java, I've used JFlex/CUP.

If your starting from scratch, I'd suggest you use JavaCC/FreeCC, which is an LL(k) parser. It's quite well documented and there are not runtime dependencies.

like image 44
brianegge Avatar answered Dec 23 '25 08:12

brianegge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!