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
Invalid C# code being generated #3000
Comments
As far as I can tell LexBasic.g4 only contains fragments so it is not a valid standalone lexer grammar.
Also you are combining the official antlr with the tools from Sam Harwell.
This combination is not supported.
Suggest you move this topic to the google discussion group.
… Le 11 déc. 2020 à 12:45, Ozzah ***@***.***> a écrit :
I'm trying to use ANTLR4.9 to build the ANTLR4 lexer/parser grammar from the antlr/grammars-v4 <https://github.com/antlr/grammars-v4/tree/master/antlr/antlr4> repo. ANTLR does generate the C# files without warnings or errors, however there is an invalid
const int
;
in the generated LexBasic.cs <https://gist.github.com/Ozzah/7dadb5f782015b9f779190dcaa94d974#file-lexbasic-cs-L35-L36> file.
In this example, I'm using antlr-4.9-complete.jar (SHA-1: 05f8b86f121c4239939b95b0eed0411dec3917e7) with the command
java -jar antlr-4.9-complete.jar -Dlanguage=CSharp -o Generated -visitor LexBasic.g4
to build just this one file. I have also tried building the whole ANTLR4 grammar set together. I've used the dotnet-based compiler using
<PropertyGroup>
<Antlr4UseCSharpGenerator>True</Antlr4UseCSharpGenerator>
</PropertyGroup>
and I've also tried building ANTLR4.9.1 from source. Everything results in the same invalid LexBasic.cs file.
Looking at the LexBasic.g4 <https://github.com/antlr/grammars-v4/blob/master/antlr/antlr4/LexBasic.g4> file, I can't see anything immediately obvious as out of place that could cause this.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#3000>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAZNQJGDJGOA4PIL3CPH3Z3SUGPWRANCNFSM4UWBI4WA>.
|
It's the bug because ANTLR should throw clear error messages instead of invalid code generating. |
@ericvergnaud ok, well if I go
then I get the same syntax error in LexBasic.cs, and there is no combination with Sam Harwell's tool. |
Consider the following grammar: lexer grammar Lexer; ANTLR produces the following error:
But If we are trying to generate lexer for the following code: lexer grammar Lexer;
fragment FRAGMENT: 'FRAGMENT'; ANTLR does not show any error and produces invalid code at least for C# runtime. Obviously, it's a bug. |
…ToolSyntaxErrors testA, fix antlr#3000
…end TestToolSyntaxErrors testA, fix antlr#3000", fix antlr#3147 This reverts commit 67f6089.
I'm trying to use ANTLR4.9 to build the ANTLR4 lexer/parser grammar from the antlr/grammars-v4 repo. ANTLR does generate the C# files without warnings or errors, however there is an invalid
in the generated LexBasic.cs file.
In this example, I'm using
antlr-4.9-complete.jar
(SHA-1: 05f8b86f121c4239939b95b0eed0411dec3917e7) with the commandto build just this one file. I have also tried building the whole ANTLR4 grammar set together. I've used the dotnet-based compiler using
and I've also tried building ANTLR4.9.1 from source. Everything results in the same invalid LexBasic.cs file.
Looking at the LexBasic.g4 file, I can't see anything immediately obvious as out of place that could cause this.
The text was updated successfully, but these errors were encountered: