I'm trying to use ANTLR in python3 for the first time (previously used it from Java) and I've run into a problem when trying to parse input that is not from a file, but from a string inside my program.
I've followed the wiki entry here:
https://github.com/antlr/antlr4/blob/master/doc/python-target.mdThat works, but it uses a FileStream as input, which requires the input to be in a file on disk. What I would like to do instead is parsing a normal python string. From what I've found so far, the StringIO class emulates the input stream behaviour of files - but apparently, it is not enough and cannot be used as the input for the Lexer. When I try to use a StringIO(myString) as the input for the Lexer, this crashes in Lexer.py, line 111, in nextToken:
tokenStartMarker = self._input.mark()
AttributeError: '_io.StringIO' object has no attribute 'mark'
The way I understand is that apparently a FileStream object would have this attribute "mark", but a StringIO object doesn't have it?
Am I doing this completely wrong? Surely there must be a way to use ANTLR in Python without needing to access an external file.