Search in sources :

Example 1 with FunctionReference

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

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 = takeToken();
    Token functionOrVariableName = eatToken(TokenKind.IDENTIFIER);
    SpelNodeImpl[] args = maybeEatMethodArgs();
    if (args == null) {
        push(new VariableReference(functionOrVariableName.stringValue(), t.startPos, functionOrVariableName.endPos));
        return true;
    }
    push(new FunctionReference(functionOrVariableName.stringValue(), t.startPos, functionOrVariableName.endPos, args));
    return true;
}
Also used : SpelNodeImpl(cn.taketoday.expression.spel.ast.SpelNodeImpl) VariableReference(cn.taketoday.expression.spel.ast.VariableReference) FunctionReference(cn.taketoday.expression.spel.ast.FunctionReference)

Example 2 with FunctionReference

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

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 = takeToken();
    Token functionOrVariableName = eatToken(TokenKind.IDENTIFIER);
    SpelNodeImpl[] args = maybeEatMethodArgs();
    if (args == null) {
        push(new VariableReference(functionOrVariableName.stringValue(), t.startPos, functionOrVariableName.endPos));
        return true;
    }
    push(new FunctionReference(functionOrVariableName.stringValue(), t.startPos, functionOrVariableName.endPos, args));
    return true;
}
Also used : SpelNodeImpl(cn.taketoday.expression.spel.ast.SpelNodeImpl) VariableReference(cn.taketoday.expression.spel.ast.VariableReference) FunctionReference(cn.taketoday.expression.spel.ast.FunctionReference)

Aggregations

FunctionReference (cn.taketoday.expression.spel.ast.FunctionReference)2 SpelNodeImpl (cn.taketoday.expression.spel.ast.SpelNodeImpl)2 VariableReference (cn.taketoday.expression.spel.ast.VariableReference)2