I want to generate an antlr lexer at runtime — that is, generate the grammar and from the grammar generate the lexer class, and its supporting bits at runtime. I am happy to feed it into the the java compiler, which is accessible at runtime.
Share
Here’s a quick and dirty way to:
.gfile given a String as grammar-source,.gfile,.javafiles,Main.java
Which, after compiling and running it like this (on *nix):
or on Windows
, produces the following output: