antlr parsing extern "C"

  antlr, antlr4, c++, python-3.x

I use antlr4 to parse C++ using antrl visitors, when I have extern "C" in my code I will get the following error,

line 1:7 no viable alternative at input 'extern"C"'
line 10:0 mismatched input '}' expecting <EOF>

This is the sample code I fail to parse using antlr,

extern "C" {

#include <stdio.h>
#include <stdlib.h>

    extern void foo( char* a, int b);
    extern void bar( char* a, int* b, int* c, int* d, int e); 

}

I tried to remove parsing extern "C" from the grammar by removing linkageSpecification from g4 file but I still get the same error!

Any help either to solve the issue for parsing extern "C" or removing the grammar for it from the grammar file is really appreciated.

Thanks

Source: Windows Questions C++

LEAVE A COMMENT