Runtime parser generator for Java?

A

Aleksi Kallio

I need to do reliable input parsing of complex input strings, for
security purposes. Regexes are too weak for this. The easy way to do it
is to write context-free grammars and have a tool to validate input
against my grammar.

The issue is that I would like to keep my grammar flexible. All parser
generators for Java that I have found are, obviously, tools that
generate Java code. For me, loading grammar at runtime and creating
parser on fly to some appropriate memory structure would be the correct
solution. I do not want to generate a java-file, compile and load it.

Is there a tool that does the job? All I need is true/false if input
adheres to syntax. Informative error messages are a bonus.
 
P

Piotr Kobzda

pleksi said:
I need to do reliable input parsing of complex input strings, for
security purposes. Regexes are too weak for this. The easy way to do it
is to write context-free grammars and have a tool to validate input
against my grammar.

The issue is that I would like to keep my grammar flexible. All parser
generators for Java that I have found are, obviously, tools that
generate Java code. For me, loading grammar at runtime and creating
parser on fly to some appropriate memory structure would be the correct
solution. I do not want to generate a java-file, compile and load it.

Is there a tool that does the job? All I need is true/false if input
adheres to syntax. Informative error messages are a bonus.

I don't know a parser generators which works the way you expect.
Nevertheless, using a JavaCompilerTool (from Java 6) you can generate
java-file, compile and load it -- all in memory. See example:
http://groups.google.com/group/pl.comp.lang.java/msg/d37010d1cce043d0


piotr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top