Package org.antlr.runtime

Examples of org.antlr.runtime.RuleReturnScope


        }
    }

    private ISqlJetTableDef createTableSafe(String sql, boolean internal) 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


     * @return
     * @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();

        if (alterTableDef.getNewTableName() != null) {
            b.append(inputStream.substring(0, nameToken.getStartIndex() - 1));
View Full Code Here

     * @param alterTableName
     * @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);
        b.append(inputStream.substring(nameToken.getStopIndex() + 1, stopToken.getStopIndex()));
        return b.toString();
View Full Code Here

        }
    }

    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

        }
    }


    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

            db.getMutex().leave();
        }
    }

    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

    return ruleMethod.invoke(parser);
  }

  @Test public void test_grammarSpec1() throws Exception {
    // gunit test on line 15
    RuleReturnScope rstruct = (RuleReturnScope)execParser("grammarSpec", "parser grammar P; a : A;", 15);
    Object actual = ((Tree)rstruct.getTree()).toStringTree();
    Object expecting = "(PARSER_GRAMMAR P (RULES (RULE a (BLOCK (ALT A)))))";
    assertEquals("testing rule grammarSpec", expecting, actual);
  }
View Full Code Here

    assertEquals("testing rule grammarSpec", expecting, actual);
  }

  @Test public void test_grammarSpec2() throws Exception {
    // gunit test on line 18
    RuleReturnScope rstruct = (RuleReturnScope)execParser("grammarSpec", "\n    parser grammar P;\n    tokens { A, B }\n    @header {foo}\n    a : A;\n    ", 18);
    Object actual = ((Tree)rstruct.getTree()).toStringTree();
    Object expecting = "(PARSER_GRAMMAR P (tokens { A B) (@ header {foo}) (RULES (RULE a (BLOCK (ALT A)))))";
    assertEquals("testing rule grammarSpec", expecting, actual);
  }
View Full Code Here

    assertEquals("testing rule grammarSpec", expecting, actual);
  }

  @Test public void test_grammarSpec3() throws Exception {
    // gunit test on line 30
    RuleReturnScope rstruct = (RuleReturnScope)execParser("grammarSpec", "\n    parser grammar P;\n    @header {foo}\n    tokens { A,B }\n    a : A;\n    ", 30);
    Object actual = ((Tree)rstruct.getTree()).toStringTree();
    Object expecting = "(PARSER_GRAMMAR P (@ header {foo}) (tokens { A B) (RULES (RULE a (BLOCK (ALT A)))))";
    assertEquals("testing rule grammarSpec", expecting, actual);
  }
View Full Code Here

    assertEquals("testing rule grammarSpec", expecting, actual);
  }

  @Test public void test_grammarSpec4() throws Exception {
    // gunit test on line 42
    RuleReturnScope rstruct = (RuleReturnScope)execParser("grammarSpec", "\n    parser grammar P;\n    import A=B, C;\n    a : A;\n    ", 42);
    Object actual = ((Tree)rstruct.getTree()).toStringTree();
    Object expecting = "(PARSER_GRAMMAR P (import (= A B) C) (RULES (RULE a (BLOCK (ALT A)))))";
    assertEquals("testing rule grammarSpec", expecting, actual);
  } @Test public void test_delegateGrammars1() throws Exception {
View Full Code Here

TOP

Related Classes of org.antlr.runtime.RuleReturnScope

Copyright © 2018 www.massapicom. 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.