Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InmemantlrTool uses only terminal-defined package names, ignoring action-defined ones #47

Open
Lizurt opened this issue Sep 17, 2022 · 0 comments

Comments

@Lizurt
Copy link

Lizurt commented Sep 17, 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:

...
@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.

@Lizurt 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant