0

我正在用 Cayenne 解析一个表达式,所以我有解析产生的令牌 (org.apache.cayenne.exp.parser.Token)。

我想知道在解析表达式的哪个位置找到了令牌。我的问题是我找不到返回此信息的方法。有谁知道这是否可能?

这是我所做的一个例子:

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();
}
4

1 回答 1

0

对不起,我不知道我是怎么错过的。信息在字段中Token.beginColumn。还有Token.endColumn

于 2013-11-20T09:37:23.873 回答