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.
Piotr Kobzda - 16 Jun 2006 16:05 GMT
pleksi Kallio wrote:
> 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
[quoted text clipped - 9 lines]
> 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