Exemplo n.º 1
0
  // $ANTLR start "line"
  // /home/jon/flume/src/antlr/FlumeShell.g:88:1: line : command EOF -> command ;
  public final FlumeShellParser.line_return line() throws RecognitionException {
    FlumeShellParser.line_return retval = new FlumeShellParser.line_return();
    retval.start = input.LT(1);

    Object root_0 = null;

    Token EOF6 = null;
    FlumeShellParser.command_return command5 = null;

    Object EOF6_tree = null;
    RewriteRuleTokenStream stream_EOF = new RewriteRuleTokenStream(adaptor, "token EOF");
    RewriteRuleSubtreeStream stream_command = new RewriteRuleSubtreeStream(adaptor, "rule command");
    try {
      // /home/jon/flume/src/antlr/FlumeShell.g:88:6: ( command EOF -> command )
      // /home/jon/flume/src/antlr/FlumeShell.g:88:8: command EOF
      {
        pushFollow(FOLLOW_command_in_line107);
        command5 = command();

        state._fsp--;

        stream_command.add(command5.getTree());
        EOF6 = (Token) match(input, EOF, FOLLOW_EOF_in_line109);
        stream_EOF.add(EOF6);

        // AST REWRITE
        // elements: command
        // token labels:
        // rule labels: retval
        // token list labels:
        // rule list labels:
        // wildcard labels:
        retval.tree = root_0;
        RewriteRuleSubtreeStream stream_retval =
            new RewriteRuleSubtreeStream(
                adaptor, "rule retval", retval != null ? retval.tree : null);

        root_0 = (Object) adaptor.nil();
        // 88:20: -> command
        {
          adaptor.addChild(root_0, stream_command.nextTree());
        }

        retval.tree = root_0;
      }

      retval.stop = input.LT(-1);

      retval.tree = (Object) adaptor.rulePostProcessing(root_0);
      adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
      retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);

    } finally {
    }
    return retval;
  }
Exemplo n.º 2
0
  // $ANTLR start "command"
  // /home/jon/flume/src/antlr/FlumeShell.g:90:1: command : ( literal )+ -> ^( CMD ( literal )+ ) ;
  public final FlumeShellParser.command_return command() throws RecognitionException {
    FlumeShellParser.command_return retval = new FlumeShellParser.command_return();
    retval.start = input.LT(1);

    Object root_0 = null;

    FlumeShellParser.literal_return literal7 = null;

    RewriteRuleSubtreeStream stream_literal = new RewriteRuleSubtreeStream(adaptor, "rule literal");
    try {
      // /home/jon/flume/src/antlr/FlumeShell.g:90:9: ( ( literal )+ -> ^( CMD ( literal )+ ) )
      // /home/jon/flume/src/antlr/FlumeShell.g:90:11: ( literal )+
      {
        // /home/jon/flume/src/antlr/FlumeShell.g:90:11: ( literal )+
        int cnt2 = 0;
        loop2:
        do {
          int alt2 = 2;
          int LA2_0 = input.LA(1);

          if (((LA2_0 >= DQuoteLiteral && LA2_0 <= Argument))) {
            alt2 = 1;
          }

          switch (alt2) {
            case 1:
              // /home/jon/flume/src/antlr/FlumeShell.g:90:11: literal
              {
                pushFollow(FOLLOW_literal_in_command122);
                literal7 = literal();

                state._fsp--;

                stream_literal.add(literal7.getTree());
              }
              break;

            default:
              if (cnt2 >= 1) break loop2;
              EarlyExitException eee = new EarlyExitException(2, input);
              throw eee;
          }
          cnt2++;
        } while (true);

        // AST REWRITE
        // elements: literal
        // token labels:
        // rule labels: retval
        // token list labels:
        // rule list labels:
        // wildcard labels:
        retval.tree = root_0;
        RewriteRuleSubtreeStream stream_retval =
            new RewriteRuleSubtreeStream(
                adaptor, "rule retval", retval != null ? retval.tree : null);

        root_0 = (Object) adaptor.nil();
        // 90:20: -> ^( CMD ( literal )+ )
        {
          // /home/jon/flume/src/antlr/FlumeShell.g:90:23: ^( CMD ( literal )+ )
          {
            Object root_1 = (Object) adaptor.nil();
            root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(CMD, "CMD"), root_1);

            if (!(stream_literal.hasNext())) {
              throw new RewriteEarlyExitException();
            }
            while (stream_literal.hasNext()) {
              adaptor.addChild(root_1, stream_literal.nextTree());
            }
            stream_literal.reset();

            adaptor.addChild(root_0, root_1);
          }
        }

        retval.tree = root_0;
      }

      retval.stop = input.LT(-1);

      retval.tree = (Object) adaptor.rulePostProcessing(root_0);
      adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
      retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);

    } finally {
    }
    return retval;
  }
Exemplo n.º 3
0
  // $ANTLR start "lines"
  // /home/jon/flume/src/antlr/FlumeShell.g:86:1: lines : command ( ';' command )* EOF -> ( command
  // )+ ;
  public final FlumeShellParser.lines_return lines() throws RecognitionException {
    FlumeShellParser.lines_return retval = new FlumeShellParser.lines_return();
    retval.start = input.LT(1);

    Object root_0 = null;

    Token char_literal2 = null;
    Token EOF4 = null;
    FlumeShellParser.command_return command1 = null;

    FlumeShellParser.command_return command3 = null;

    Object char_literal2_tree = null;
    Object EOF4_tree = null;
    RewriteRuleTokenStream stream_19 = new RewriteRuleTokenStream(adaptor, "token 19");
    RewriteRuleTokenStream stream_EOF = new RewriteRuleTokenStream(adaptor, "token EOF");
    RewriteRuleSubtreeStream stream_command = new RewriteRuleSubtreeStream(adaptor, "rule command");
    try {
      // /home/jon/flume/src/antlr/FlumeShell.g:86:7: ( command ( ';' command )* EOF -> ( command )+
      // )
      // /home/jon/flume/src/antlr/FlumeShell.g:86:9: command ( ';' command )* EOF
      {
        pushFollow(FOLLOW_command_in_lines85);
        command1 = command();

        state._fsp--;

        stream_command.add(command1.getTree());
        // /home/jon/flume/src/antlr/FlumeShell.g:86:17: ( ';' command )*
        loop1:
        do {
          int alt1 = 2;
          int LA1_0 = input.LA(1);

          if ((LA1_0 == 19)) {
            alt1 = 1;
          }

          switch (alt1) {
            case 1:
              // /home/jon/flume/src/antlr/FlumeShell.g:86:18: ';' command
              {
                char_literal2 = (Token) match(input, 19, FOLLOW_19_in_lines88);
                stream_19.add(char_literal2);

                pushFollow(FOLLOW_command_in_lines90);
                command3 = command();

                state._fsp--;

                stream_command.add(command3.getTree());
              }
              break;

            default:
              break loop1;
          }
        } while (true);

        EOF4 = (Token) match(input, EOF, FOLLOW_EOF_in_lines94);
        stream_EOF.add(EOF4);

        // AST REWRITE
        // elements: command
        // token labels:
        // rule labels: retval
        // token list labels:
        // rule list labels:
        // wildcard labels:
        retval.tree = root_0;
        RewriteRuleSubtreeStream stream_retval =
            new RewriteRuleSubtreeStream(
                adaptor, "rule retval", retval != null ? retval.tree : null);

        root_0 = (Object) adaptor.nil();
        // 86:36: -> ( command )+
        {
          if (!(stream_command.hasNext())) {
            throw new RewriteEarlyExitException();
          }
          while (stream_command.hasNext()) {
            adaptor.addChild(root_0, stream_command.nextTree());
          }
          stream_command.reset();
        }

        retval.tree = root_0;
      }

      retval.stop = input.LT(-1);

      retval.tree = (Object) adaptor.rulePostProcessing(root_0);
      adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
      retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);

    } finally {
    }
    return retval;
  }