I would like to use ANTLR4 to analyze COBOL files using a Python3 program. To do so, I would need to know the position on which the token (lets say a MOVE statement) occurs in the file (at least the line and if possible also the character position). I need this especially, because I want to resolve COPY statements (similar to #include <> in C) and make sure I know in which part I am, while parsing the file.
I already searched here and found similar questions, but they don't seem to work for the python implementation (anymore). E.g. this one: Previous Question about that topic, probably for Java
If I try this solution I get an error as soon as I call getStartIndex() or getSymbol() (AttributeError: 'StartRuleContext' object has no attribute 'getStartIndex').