Search in sources :

Example 1 with Identifier

use of cn.taketoday.expression.spel.ast.Identifier in project today-framework by TAKETODAY.

the class InternalSpelExpressionParser method eatPossiblyQualifiedId.

/**
 * Eat an identifier, possibly qualified (meaning that it is dotted).
 * TODO AndyC Could create complete identifiers (a.b.c) here rather than a sequence of them? (a, b, c)
 */
private SpelNodeImpl eatPossiblyQualifiedId() {
    Deque<SpelNodeImpl> qualifiedIdPieces = new ArrayDeque<>();
    Token node = peekToken();
    while (isValidQualifiedId(node)) {
        nextToken();
        if (node.kind != TokenKind.DOT) {
            qualifiedIdPieces.add(new Identifier(node.stringValue(), node.startPos, node.endPos));
        }
        node = peekToken();
    }
    if (qualifiedIdPieces.isEmpty()) {
        if (node == null) {
            throw internalException(this.expressionString.length(), SpelMessage.OOD);
        }
        throw internalException(node.startPos, SpelMessage.NOT_EXPECTED_TOKEN, "qualified ID", node.kind.toString().toLowerCase());
    }
    return new QualifiedIdentifier(qualifiedIdPieces.getFirst().getStartPosition(), qualifiedIdPieces.getLast().getEndPosition(), qualifiedIdPieces.toArray(new SpelNodeImpl[0]));
}
Also used : SpelNodeImpl(cn.taketoday.expression.spel.ast.SpelNodeImpl) QualifiedIdentifier(cn.taketoday.expression.spel.ast.QualifiedIdentifier) Identifier(cn.taketoday.expression.spel.ast.Identifier) QualifiedIdentifier(cn.taketoday.expression.spel.ast.QualifiedIdentifier) ArrayDeque(java.util.ArrayDeque)

Example 2 with Identifier

use of cn.taketoday.expression.spel.ast.Identifier in project today-infrastructure by TAKETODAY.

the class InternalSpelExpressionParser method eatPossiblyQualifiedId.

/**
 * Eat an identifier, possibly qualified (meaning that it is dotted).
 * TODO AndyC Could create complete identifiers (a.b.c) here rather than a sequence of them? (a, b, c)
 */
private SpelNodeImpl eatPossiblyQualifiedId() {
    Deque<SpelNodeImpl> qualifiedIdPieces = new ArrayDeque<>();
    Token node = peekToken();
    while (isValidQualifiedId(node)) {
        nextToken();
        if (node.kind != TokenKind.DOT) {
            qualifiedIdPieces.add(new Identifier(node.stringValue(), node.startPos, node.endPos));
        }
        node = peekToken();
    }
    if (qualifiedIdPieces.isEmpty()) {
        if (node == null) {
            throw internalException(this.expressionString.length(), SpelMessage.OOD);
        }
        throw internalException(node.startPos, SpelMessage.NOT_EXPECTED_TOKEN, "qualified ID", node.kind.toString().toLowerCase());
    }
    return new QualifiedIdentifier(qualifiedIdPieces.getFirst().getStartPosition(), qualifiedIdPieces.getLast().getEndPosition(), qualifiedIdPieces.toArray(new SpelNodeImpl[0]));
}
Also used : SpelNodeImpl(cn.taketoday.expression.spel.ast.SpelNodeImpl) QualifiedIdentifier(cn.taketoday.expression.spel.ast.QualifiedIdentifier) Identifier(cn.taketoday.expression.spel.ast.Identifier) QualifiedIdentifier(cn.taketoday.expression.spel.ast.QualifiedIdentifier) ArrayDeque(java.util.ArrayDeque)

Aggregations

Identifier (cn.taketoday.expression.spel.ast.Identifier)2 QualifiedIdentifier (cn.taketoday.expression.spel.ast.QualifiedIdentifier)2 SpelNodeImpl (cn.taketoday.expression.spel.ast.SpelNodeImpl)2 ArrayDeque (java.util.ArrayDeque)2