antlr4
antlr4 copied to clipboard
[Target: Cpp] fix Duplicate using namespace lines.
trafficstars
📛 Issue: https://github.com/antlr/antlr4/issues/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;