Skip to content

Conversation

@cppenjoy
Copy link

@cppenjoy cppenjoy commented Dec 9, 2024

📛 Issue: #4733

A simple bug in the ANTLR4 code generator for C++.

If we generate a lexical analyzer for any ANTLR4 grammar using target C++, then we can see that the ANTLR4 code generator duplicates "using namespace std;" twice, which is not logical behavior.

For example, if we have a small grammar:

grammar main;

mainRule: token+;
Token: 'token';

Now let's try to generate a parser for this grammar:

antlr4 main.g4 -Dlanguage=Cpp

Then we will get a lexical file in the likeness:

#include "MainLexer.h"

using namespace antlr4;

using namespace antlr4;

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

Successfully merging this pull request may close these issues.

1 participant