'Antlr4 generated files contain errors when moved from the gen to the src directory on INTELLIJ

I have tested a small project with a hello world grammar on intellij (windows) and moved the antlr4 generated files from gen to src to be able to create a "Mylistener" class and everything works well. Now i am trying a new project to modify postgresql grammar by adding a clause to the select statement so i copied postgresql lexer and parser from https://github.com/antlr/grammars-v4/tree/master/sql/postgresql i added my new clause and generated the files with antlr4 and everything worked well (i was able to see my new clause in the parsing tree even if i had an error saying "empty or bad grammar") but when i configured antlr to generate the files in the src directory (like i did in the hello world project), all the classes come with errors and when i build the project i have 100 erros like this :

Error:(14, 39) java: cannot find symbol symbol: class PostgreSQLParserBase Error:(753, 9) java: method does not override or implement a method from a supertype Error:(14, 39) java: cannot find symbol symbol: class PostgreSQLParserBase Error:(753, 9) java: method does not override or implement a method from a supertype Error:(781, 17) java: cannot find symbol symbol: variable _interp location: class PostgreSQLParser Error:(781, 50) java: incompatible types: PostgreSQLParser cannot be converted to org.antlr.v4.runtime.Parser Error:(788, 77) java: cannot find symbol symbol: variable EOF location: class PostgreSQLParser

All the errors are about some symbols that are not found in class PostgreSQL. I searched many similar questions here but i don't understand where the problem is (i have antlr jar as a project library ). Any help is welcomed.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source