Search in sources :

Example 1 with InternalParseException

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

the class InternalSpelExpressionParser method doParseExpression.

@Override
protected SpelExpression doParseExpression(String expressionString, @Nullable ParserContext context) throws ParseException {
    try {
        this.expressionString = expressionString;
        Tokenizer tokenizer = new Tokenizer(expressionString);
        this.tokenStream = tokenizer.process();
        this.tokenStreamLength = this.tokenStream.size();
        this.tokenStreamPointer = 0;
        this.constructedNodes.clear();
        SpelNodeImpl ast = eatExpression();
        Assert.state(ast != null, "No node");
        Token t = peekToken();
        if (t != null) {
            throw new SpelParseException(t.startPos, SpelMessage.MORE_INPUT, toString(nextToken()));
        }
        Assert.isTrue(this.constructedNodes.isEmpty(), "At least one node expected");
        return new SpelExpression(expressionString, ast, this.configuration);
    } catch (InternalParseException ex) {
        throw ex.getCause();
    }
}
Also used : SpelParseException(cn.taketoday.expression.spel.SpelParseException) InternalParseException(cn.taketoday.expression.spel.InternalParseException) SpelNodeImpl(cn.taketoday.expression.spel.ast.SpelNodeImpl)

Example 2 with InternalParseException

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

the class InternalSpelExpressionParser method eatConstructorArgs.

private void eatConstructorArgs(List<SpelNodeImpl> accumulatedArguments) {
    if (!peekToken(TokenKind.LPAREN)) {
        throw new InternalParseException(new SpelParseException(this.expressionString, positionOf(peekToken()), SpelMessage.MISSING_CONSTRUCTOR_ARGS));
    }
    consumeArguments(accumulatedArguments);
    eatToken(TokenKind.RPAREN);
}
Also used : InternalParseException(cn.taketoday.expression.spel.InternalParseException) SpelParseException(cn.taketoday.expression.spel.SpelParseException)

Example 3 with InternalParseException

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

the class InternalSpelExpressionParser method doParseExpression.

@Override
protected SpelExpression doParseExpression(String expressionString, @Nullable ParserContext context) throws ParseException {
    try {
        this.expressionString = expressionString;
        Tokenizer tokenizer = new Tokenizer(expressionString);
        this.tokenStream = tokenizer.process();
        this.tokenStreamLength = this.tokenStream.size();
        this.tokenStreamPointer = 0;
        this.constructedNodes.clear();
        SpelNodeImpl ast = eatExpression();
        Assert.state(ast != null, "No node");
        Token t = peekToken();
        if (t != null) {
            throw new SpelParseException(t.startPos, SpelMessage.MORE_INPUT, toString(nextToken()));
        }
        Assert.isTrue(this.constructedNodes.isEmpty(), "At least one node expected");
        return new SpelExpression(expressionString, ast, this.configuration);
    } catch (InternalParseException ex) {
        throw ex.getCause();
    }
}
Also used : SpelParseException(cn.taketoday.expression.spel.SpelParseException) InternalParseException(cn.taketoday.expression.spel.InternalParseException) SpelNodeImpl(cn.taketoday.expression.spel.ast.SpelNodeImpl)

Example 4 with InternalParseException

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

the class InternalSpelExpressionParser method eatConstructorArgs.

private void eatConstructorArgs(List<SpelNodeImpl> accumulatedArguments) {
    if (!peekToken(TokenKind.LPAREN)) {
        throw new InternalParseException(new SpelParseException(this.expressionString, positionOf(peekToken()), SpelMessage.MISSING_CONSTRUCTOR_ARGS));
    }
    consumeArguments(accumulatedArguments);
    eatToken(TokenKind.RPAREN);
}
Also used : InternalParseException(cn.taketoday.expression.spel.InternalParseException) SpelParseException(cn.taketoday.expression.spel.SpelParseException)

Aggregations

InternalParseException (cn.taketoday.expression.spel.InternalParseException)4 SpelParseException (cn.taketoday.expression.spel.SpelParseException)4 SpelNodeImpl (cn.taketoday.expression.spel.ast.SpelNodeImpl)2