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

[Target: Cpp] fix Duplicate using namespace lines. #4745

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

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