-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Hello.
InmemantlrTool here, while setting lexer/parser, gets a package name using this logic which includes only a terminal-based package name, as noted multiple times in antlr4 lib.
But if we set those packages using .g4 actions like in this example:
...
@header {
package foo.bar;
}
...
GenericParser may throw an exception, for example, here, because SpecialClassLoader can't find a class with a name which doesn't includes packages. m may contain full class names here, but the method parameter name is only a class name without packages, because, as I said earlier, InmemantlrTool uses only terminal-defined packades.
We can workaround this by setting lexer or parser names (with packages) manually after a parser was compiled, but it doesn't seem like a good soltuion for me. But if it's intended and a good way to set up these names, it would be nice to have some notes in documentation or exceptions. Currently, this may lead to this exception: java.lang.NullPointerException: Cannot invoke "org.antlr.v4.runtime.Lexer.addErrorListener(org.antlr.v4.runtime.ANTLRErrorListener)" because "lex" is null which doesn't contain any hints about lexerName or parserName.