Package org.antlr.runtime

Examples of org.antlr.runtime.ParserRuleReturnScope


        }
    }

    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


    /**
     * @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

      CommonTokenStream tokens = new CommonTokenStream(lexer);
      lexer.tokens = tokens;
      ToolANTLRParser p = new ToolANTLRParser(tokens, this);
      p.setTreeAdaptor(adaptor);
      try {
        ParserRuleReturnScope r = p.grammarSpec();
        GrammarAST root = (GrammarAST)r.getTree();
        if ( root instanceof GrammarRootAST) {
          ((GrammarRootAST)root).hasErrors = lexer.getNumberOfSyntaxErrors()>0 || p.getNumberOfSyntaxErrors()>0;
          assert ((GrammarRootAST)root).tokenStream == tokens;
          if ( grammarOptions!=null ) {
            ((GrammarRootAST)root).cmdLineOptions = grammarOptions;
View Full Code Here

    lexer.tokens = tokens;
    ToolANTLRParser p = new ToolANTLRParser(tokens, tool);
    p.setTreeAdaptor(adaptor);
    Token ruleStart = null;
    try {
      ParserRuleReturnScope r = p.rule();
      RuleAST tree = (RuleAST)r.getTree();
      ruleStart = (Token)r.getStart();
      GrammarTransformPipeline.setGrammarPtr(g, tree);
      GrammarTransformPipeline.augmentTokensWithOriginalPosition(g, tree);
      return tree;
    }
    catch (Exception e) {
View Full Code Here

   */
  protected String buildAST(String value) throws Exception {
    DateParser parser = buildParser(value);
    Class<?> klass = Class.forName("com.joestelmach.natty.generated.DateParser");
    Method meth = klass.getMethod(_ruleName, (Class<?>[]) null);
    ParserRuleReturnScope ret = (ParserRuleReturnScope) meth.invoke(parser, (Object[]) null);
   
    Tree tree = (Tree)ret.getTree();
    // rewrite the tree (temporary fix for http://www.antlr.org/jira/browse/ANTLR-427)
    CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
    TreeRewrite s = new TreeRewrite(nodes);
    tree = (CommonTree)s.downup(tree);
     
View Full Code Here

      List<Problem> errors = new ArrayList<Problem>();
      LessLexer lexer = createLexer(input, source, errors);

      CollectorTokenSource tokenSource = new CollectorTokenSource(lexer, KEEP_HIDDEN_TOKENS);
      LessParser parser = createParser(tokenSource, source, errors);
      ParserRuleReturnScope returnScope = inputType.parseTree(parser);
     
      HiddenTokenAwareTree ast = (HiddenTokenAwareTree) returnScope.getTree();
      merge(ast, tokenSource.getCollectedTokens());
      if (isDebug)
        DebugAndTestPrint.print(ast);
      return new ParseResultImpl(ast, new ArrayList<Problem>(errors));
    } catch (RecognitionException e) {
View Full Code Here

      parser.setErrorReporter(errorReporter);
      try {
        // "</CFSCRIPT>")
        // )
        // );
        ParserRuleReturnScope r = parser.scriptBlock();
        CommonTree tree = (CommonTree) r.getTree();
        // first item is EOF, so get kids to get kids
        if (tree == null) {
          ScriptItem errorNode = new ScriptItem(0, 0, 0, "error");
          errorNode.setItemData("Error creating outline: " + parserState.getMessages().toString());
          addDocItemToTree(errorNode);
View Full Code Here

    retval.start = input.LT(1);

    CommonTree root_0 = null;

    Token EOF2 = null;
    ParserRuleReturnScope logicalExpression1 = null;

    final CommonTree EOF2_tree = null;

    try {
      // ECalc.g:46:2: ( logicalExpression EOF !)
      // ECalc.g:46:5: logicalExpression EOF !
      {
        root_0 = (CommonTree) adaptor.nil();

        pushFollow(FOLLOW_logicalExpression_in_expression64);
        logicalExpression1 = logicalExpression();
        state._fsp--;

        adaptor.addChild(
            root_0,
            logicalExpression1.getTree());

        EOF2 = (Token) match(
            input,
            EOF,
            FOLLOW_EOF_in_expression66);
View Full Code Here

    retval.start = input.LT(1);

    CommonTree root_0 = null;

    Token OR4 = null;
    ParserRuleReturnScope booleanAndExpression3 = null;
    ParserRuleReturnScope booleanAndExpression5 = null;

    CommonTree OR4_tree = null;

    try {
      // ECalc.g:50:2: ( booleanAndExpression ( OR ^ booleanAndExpression
      // )* )
      // ECalc.g:50:4: booleanAndExpression ( OR ^ booleanAndExpression )*
      {
        root_0 = (CommonTree) adaptor.nil();

        pushFollow(FOLLOW_booleanAndExpression_in_logicalExpression80);
        booleanAndExpression3 = booleanAndExpression();
        state._fsp--;

        adaptor.addChild(
            root_0,
            booleanAndExpression3.getTree());

        // ECalc.g:50:25: ( OR ^ booleanAndExpression )*
        loop1: while (true) {
          int alt1 = 2;
          final int LA1_0 = input.LA(1);
          if ((LA1_0 == OR)) {
            alt1 = 1;
          }

          switch (alt1) {
            case 1:
            // ECalc.g:50:26: OR ^ booleanAndExpression
            {
              OR4 = (Token) match(
                  input,
                  OR,
                  FOLLOW_OR_in_logicalExpression83);
              OR4_tree = (CommonTree) adaptor.create(OR4);
              root_0 = (CommonTree) adaptor.becomeRoot(
                  OR4_tree,
                  root_0);

              pushFollow(FOLLOW_booleanAndExpression_in_logicalExpression86);
              booleanAndExpression5 = booleanAndExpression();
              state._fsp--;

              adaptor.addChild(
                  root_0,
                  booleanAndExpression5.getTree());

            }
              break;

            default:
View Full Code Here

    retval.start = input.LT(1);

    CommonTree root_0 = null;

    Token AND7 = null;
    ParserRuleReturnScope equalityExpression6 = null;
    ParserRuleReturnScope equalityExpression8 = null;

    CommonTree AND7_tree = null;

    try {
      // ECalc.g:56:2: ( equalityExpression ( AND ^ equalityExpression )*
      // )
      // ECalc.g:56:4: equalityExpression ( AND ^ equalityExpression )*
      {
        root_0 = (CommonTree) adaptor.nil();

        pushFollow(FOLLOW_equalityExpression_in_booleanAndExpression116);
        equalityExpression6 = equalityExpression();
        state._fsp--;

        adaptor.addChild(
            root_0,
            equalityExpression6.getTree());

        // ECalc.g:56:23: ( AND ^ equalityExpression )*
        loop2: while (true) {
          int alt2 = 2;
          final int LA2_0 = input.LA(1);
          if ((LA2_0 == AND)) {
            alt2 = 1;
          }

          switch (alt2) {
            case 1:
            // ECalc.g:56:24: AND ^ equalityExpression
            {
              AND7 = (Token) match(
                  input,
                  AND,
                  FOLLOW_AND_in_booleanAndExpression119);
              AND7_tree = (CommonTree) adaptor.create(AND7);
              root_0 = (CommonTree) adaptor.becomeRoot(
                  AND7_tree,
                  root_0);

              pushFollow(FOLLOW_equalityExpression_in_booleanAndExpression122);
              equalityExpression8 = equalityExpression();
              state._fsp--;

              adaptor.addChild(
                  root_0,
                  equalityExpression8.getTree());

            }
              break;

            default:
View Full Code Here

TOP

Related Classes of org.antlr.runtime.ParserRuleReturnScope

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.