[antlr-interest] C target character position
A Z
asicaddress at gmail.com
Fri Nov 19 04:43:43 PST 2010
Hello,
I'm trying to record the offset of the start of a token, relative to the
beginning of the input buffer. My program passes a (char *) buffer to ANTLR
and then runs a simple grammar that builds a data structure containing the
element types and pointer to their position in the text buffer. The problem
is I can't find a way to get the true character offset from ANTLR in order
to set the pointer. Below it prints out the results of most of the values
for the ANTLR3_COMMON_TOKEN for the very first token. The two subsequent
values are the data member and the address of the character buffer. I would
expect start, getStartIndex and input->data to be the same but they are
different. How can I find the offset of a token, in terms of the number of
characters from the start of the stream?
Thanks
charPosition : -1
getCharPositionInLine : -1
getLine : 1
getStartIndex : 23213648
getStopIndex : 23213653
getTokenIndex : 0
index : 0
line : 1
lineStart : 23213648
start : 23213648
stop : 23213653
(pANTLR3_INPUT_STREAM)input->data 23217928
(uint8_t*)dataBuffer 23213624
More information about the antlr-interest
mailing list