Search in sources :

Example 1 with ForBlockNode

use of org.seasar.doma.internal.jdbc.sql.node.ForBlockNode in project doma by domaframework.

the class SqlParser method parseForBlockComment.

protected void parseForBlockComment() {
    ForBlockNode forBlockNode = new ForBlockNode();
    appendNode(forBlockNode);
    push(forBlockNode);
    String expr = tokenType.extract(token);
    int pos = expr.indexOf(":");
    if (pos == -1) {
        throw new JdbcException(Message.DOMA2124, sql, tokenizer.getLineNumber(), tokenizer.getPosition());
    }
    String identifier = expr.substring(0, pos).trim();
    if (identifier.isEmpty()) {
        throw new JdbcException(Message.DOMA2125, sql, tokenizer.getLineNumber(), tokenizer.getPosition());
    }
    String expression = expr.substring(pos + 1).trim();
    if (expression.isEmpty()) {
        throw new JdbcException(Message.DOMA2126, sql, tokenizer.getLineNumber(), tokenizer.getPosition());
    }
    ForNode forNode = new ForNode(getLocation(), identifier, expression, token);
    forBlockNode.setForNode(forNode);
    push(forNode);
}
Also used : ForNode(org.seasar.doma.internal.jdbc.sql.node.ForNode) ForBlockNode(org.seasar.doma.internal.jdbc.sql.node.ForBlockNode) JdbcException(org.seasar.doma.jdbc.JdbcException)

Example 2 with ForBlockNode

use of org.seasar.doma.internal.jdbc.sql.node.ForBlockNode in project doma by domaframework.

the class SqlParser method validate.

protected void validate() {
    if (isAfterValueNode()) {
        ValueNode valueNode = pop();
        throw new JdbcException(Message.DOMA2110, sql, tokenizer.getLineNumber(), tokenizer.getPosition(), valueNode.getText());
    }
    if (isInIfBlockNode()) {
        removeNodesTo(IfBlockNode.class);
        IfBlockNode ifBlockNode = pop();
        SqlLocation location = ifBlockNode.getIfNode().getLocation();
        throw new JdbcException(Message.DOMA2133, sql, location.getLineNumber(), location.getPosition());
    }
    if (isInForBlockNode()) {
        removeNodesTo(ForBlockNode.class);
        ForBlockNode forBlockNode = pop();
        SqlLocation location = forBlockNode.getForNode().getLocation();
        throw new JdbcException(Message.DOMA2134, sql, location.getLineNumber(), location.getPosition());
    }
}
Also used : ForBlockNode(org.seasar.doma.internal.jdbc.sql.node.ForBlockNode) ValueNode(org.seasar.doma.internal.jdbc.sql.node.ValueNode) IfBlockNode(org.seasar.doma.internal.jdbc.sql.node.IfBlockNode) SqlLocation(org.seasar.doma.internal.jdbc.sql.node.SqlLocation) JdbcException(org.seasar.doma.jdbc.JdbcException)

Aggregations

ForBlockNode (org.seasar.doma.internal.jdbc.sql.node.ForBlockNode)2 JdbcException (org.seasar.doma.jdbc.JdbcException)2 ForNode (org.seasar.doma.internal.jdbc.sql.node.ForNode)1 IfBlockNode (org.seasar.doma.internal.jdbc.sql.node.IfBlockNode)1 SqlLocation (org.seasar.doma.internal.jdbc.sql.node.SqlLocation)1 ValueNode (org.seasar.doma.internal.jdbc.sql.node.ValueNode)1