Search in sources :

Example 1 with VariableReference

use of org.springframework.expression.spel.ast.VariableReference in project spring-framework by spring-projects.

the class InternalSpelExpressionParser method maybeEatFunctionOrVar.

// functionOrVar
// : (POUND ID LPAREN) => function
// | var
//
// function : POUND id=ID methodArgs -> ^(FUNCTIONREF[$id] methodArgs);
// var : POUND id=ID -> ^(VARIABLEREF[$id]);
private boolean maybeEatFunctionOrVar() {
    if (!peekToken(TokenKind.HASH)) {
        return false;
    }
    Token t = nextToken();
    Token functionOrVariableName = eatToken(TokenKind.IDENTIFIER);
    SpelNodeImpl[] args = maybeEatMethodArgs();
    if (args == null) {
        push(new VariableReference(functionOrVariableName.data, toPos(t.startPos, functionOrVariableName.endPos)));
        return true;
    }
    push(new FunctionReference(functionOrVariableName.data, toPos(t.startPos, functionOrVariableName.endPos), args));
    return true;
}
Also used : SpelNodeImpl(org.springframework.expression.spel.ast.SpelNodeImpl) VariableReference(org.springframework.expression.spel.ast.VariableReference) FunctionReference(org.springframework.expression.spel.ast.FunctionReference)

Aggregations

FunctionReference (org.springframework.expression.spel.ast.FunctionReference)1 SpelNodeImpl (org.springframework.expression.spel.ast.SpelNodeImpl)1 VariableReference (org.springframework.expression.spel.ast.VariableReference)1