Examples of CommonTree


Examples of org.antlr.runtime.tree.CommonTree

    }

    private ISqlJetIndexDef createIndexSafe(String sql) throws SqlJetException {

        final ParserRuleReturnScope parseIndex = parseIndex(sql);
        final CommonTree ast = (CommonTree) parseIndex.getTree();

        final SqlJetIndexDef indexDef = new SqlJetIndexDef(ast, 0);

        if (null == indexDef.getName())
            throw new SqlJetException(SqlJetErrorCode.ERROR);
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

     * @param alterTableDef
     * @return
     */
    private String getAlterTableName(SqlJetAlterTableDef alterTableDef) {
        final ParserRuleReturnScope parsedSql = alterTableDef.getParsedSql();
        final CommonTree ast = (CommonTree) parsedSql.getTree();
        final CommonToken stopToken = (CommonToken) parsedSql.getStop();
        final CommonToken nameToken = (CommonToken) ((CommonTree) ast.getChild(ast.getChildCount() - 1)).getToken();
        final CharStream inputStream = nameToken.getInputStream();
        return inputStream.substring(nameToken.getStartIndex(), stopToken.getStopIndex());
    }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

     * @throws SqlJetException
     */
    private String getTableAlteredSql(String sql, SqlJetAlterTableDef alterTableDef) throws SqlJetException {

        final RuleReturnScope parsedSQL = parseTable(sql);
        final CommonTree ast = (CommonTree) parsedSQL.getTree();
        final CommonToken nameToken = (CommonToken) ((CommonTree) ast.getChild(1)).getToken();
        final CharStream inputStream = nameToken.getInputStream();
        final CommonToken stopToken = (CommonToken) parsedSQL.getStop();

        final StringBuilder b = new StringBuilder();

View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

     * @return
     * @throws SqlJetException
     */
    private String getAlteredIndexSql(String sql, String alterTableName) throws SqlJetException {
        final RuleReturnScope parsedSQL = parseIndex(sql);
        final CommonTree ast = (CommonTree) parsedSQL.getTree();
        final CommonToken nameToken = (CommonToken) ((CommonTree) ast.getChild(2)).getToken();
        final CharStream inputStream = nameToken.getInputStream();
        final CommonToken stopToken = (CommonToken) parsedSQL.getStop();
        final StringBuilder b = new StringBuilder();
        b.append(inputStream.substring(0, nameToken.getStartIndex() - 1));
        b.append(alterTableName);
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    }

    private ISqlJetVirtualTableDef createVirtualTableSafe(String sql, int page) throws SqlJetException {

        final RuleReturnScope parseTable = parseTable(sql);
        final CommonTree ast = (CommonTree) parseTable.getTree();

        if (!isCreateVirtualTable(ast)) {
            throw new SqlJetException(SqlJetErrorCode.ERROR);
        }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    }


    private ISqlJetViewDef createViewSafe(String sql) throws SqlJetException {
        final RuleReturnScope parseView = parseView(sql);
        final CommonTree ast = (CommonTree) parseView.getTree();
       
        sql = sql.trim();
        if (sql.endsWith(";")) {
            sql = sql.substring(0, sql.length() - 1);
        }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

        }
    }

    private ISqlJetTriggerDef createTriggerSafe(String sql) throws SqlJetException {
        final RuleReturnScope parseView = parseTrigger(sql);
        final CommonTree ast = (CommonTree) parseView.getTree();
       
        sql = sql.trim();
        if (sql.endsWith(";")) {
            sql = sql.substring(0, sql.length() - 1);
        }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    private final boolean not;

    public SqlJetBetweenExpression(CommonTree ast) throws SqlJetException {
        assert "between".equalsIgnoreCase(ast.getText());
        int idx = 0;
        CommonTree child = (CommonTree) ast.getChild(idx++);
        if ("not".equalsIgnoreCase(child.getText())) {
            not = true;
            child = (CommonTree) ast.getChild(idx++);
        } else {
            not = false;
        }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

    }

    public SqlJetIndexDef(CommonTree ast, int page) {
        super(null, null, page);

        CommonTree optionsNode = (CommonTree) ast.getChild(0);
        unique = hasOption(optionsNode, "unique");
        ifNotExists = hasOption(optionsNode, "exists");

        CommonTree nameNode = (CommonTree) ast.getChild(1);
        setName(nameNode.getText());
        databaseName = nameNode.getChildCount() > 0 ? nameNode.getChild(0).getText() : null;

        CommonTree tableNameNode = (CommonTree) ast.getChild(2);
        setTableName(tableNameNode.getText());

        List<ISqlJetIndexedColumn> columns = new ArrayList<ISqlJetIndexedColumn>();
        CommonTree defNode = (CommonTree) ast.getChild(3);
        for (int i = 0; i < defNode.getChildCount(); i++) {
            columns.add(new SqlJetIndexedColumn((CommonTree) defNode.getChild(i)));
        }
        this.columns = Collections.unmodifiableList(columns);
    }
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree

        this.columns = Collections.unmodifiableList(columns);
    }

    private boolean hasOption(CommonTree optionsNode, String name) {
        for (int i = 0; i < optionsNode.getChildCount(); i++) {
            CommonTree optionNode = (CommonTree) optionsNode.getChild(i);
            if (name.equalsIgnoreCase(optionNode.getText())) {
                return true;
            }
        }
        return false;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.