Question

I am parsing an expression with Cayenne, so I have the tokens (org.apache.cayenne.exp.parser.Token) resulting from the parsing.

I would like to know at what position in the parsed expression the token was found. My problem is that I am not able to find a method that returns this information. Does anyone know if that is possible ?

This is an example of what I do:

String expression = "A > 100"; // This gives 3 tokens, at positions 0, 2 and 4 respectively.

ExpressionParser parser = new ExpressionParser(new StringReader(expression));

Token token = parser.getNextToken();

while (token != null && token.toString().length() > 0)
{
    // Here I'd like to know at what position token was found in expression .

    ....
    ....
    token = parser.getNextToken();
}
Était-ce utile?

La solution

My apologies, I don't know how I missed that. The information is in field Token.beginColumn. There is also Token.endColumn

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top