You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
InmemantlrToolhere, 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.
The text was updated successfully, but these errors were encountered:
Lizurt
changed the title
InmemantlrTool uses only terminal-defined package names, ignoring @header-defined ones
InmemantlrTool uses only terminal-defined package names, ignoring action-defined ones
Oct 2, 2022
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:GenericParser
may throw an exception, for example, here, becauseSpecialClassLoader
can't find a class with a name which doesn't includes packages.m
may contain full class names here, but the method parametername
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 aboutlexerName
orparserName
.The text was updated successfully, but these errors were encountered: