public final HiveParser_SelectClauseParser.window_specification_return window_specification() throws RecognitionException {
		HiveParser_SelectClauseParser.window_specification_return retval = new HiveParser_SelectClauseParser.window_specification_return();
		retval.start = input.LT(1);

		CommonTree root_0 = null;

		Token Identifier95=null;
		Token LPAREN96=null;
		Token Identifier97=null;
		Token RPAREN100=null;
		ParserRuleReturnScope partitioningSpec98 =null;
		ParserRuleReturnScope window_frame99 =null;

		CommonTree Identifier95_tree=null;
		CommonTree LPAREN96_tree=null;
		CommonTree Identifier97_tree=null;
		CommonTree RPAREN100_tree=null;
		RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
		RewriteRuleTokenStream stream_Identifier=new RewriteRuleTokenStream(adaptor,"token Identifier");
		RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
		RewriteRuleSubtreeStream stream_window_frame=new RewriteRuleSubtreeStream(adaptor,"rule window_frame");
		RewriteRuleSubtreeStream stream_partitioningSpec=new RewriteRuleSubtreeStream(adaptor,"rule partitioningSpec");

		 gParent.msgs.push("window_specification"); 
		try {
			// SelectClauseParser.g:257:3: ( ( Identifier | ( LPAREN ( Identifier )? ( partitioningSpec )? ( window_frame )? RPAREN ) ) -> ^( TOK_WINDOWSPEC ( Identifier )? ( partitioningSpec )? ( window_frame )? ) )
			// SelectClauseParser.g:258:3: ( Identifier | ( LPAREN ( Identifier )? ( partitioningSpec )? ( window_frame )? RPAREN ) )
			{
			// SelectClauseParser.g:258:3: ( Identifier | ( LPAREN ( Identifier )? ( partitioningSpec )? ( window_frame )? RPAREN ) )
			int alt36=2;
			int LA36_0 = input.LA(1);
			if ( (LA36_0==Identifier) ) {
				alt36=1;
			}
			else if ( (LA36_0==LPAREN) ) {
				alt36=2;
			}

			else {
				NoViableAltException nvae =
					new NoViableAltException("", 36, 0, input);
				throw nvae;
			}

			switch (alt36) {
				case 1 :
					// SelectClauseParser.g:258:4: Identifier
					{
					Identifier95=(Token)match(input,Identifier,FOLLOW_Identifier_in_window_specification1741);  
					stream_Identifier.add(Identifier95);

					}
					break;
				case 2 :
					// SelectClauseParser.g:258:17: ( LPAREN ( Identifier )? ( partitioningSpec )? ( window_frame )? RPAREN )
					{
					// SelectClauseParser.g:258:17: ( LPAREN ( Identifier )? ( partitioningSpec )? ( window_frame )? RPAREN )
					// SelectClauseParser.g:258:19: LPAREN ( Identifier )? ( partitioningSpec )? ( window_frame )? RPAREN
					{
					LPAREN96=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_window_specification1747);  
					stream_LPAREN.add(LPAREN96);

					// SelectClauseParser.g:258:26: ( Identifier )?
					int alt33=2;
					int LA33_0 = input.LA(1);
					if ( (LA33_0==Identifier) ) {
						alt33=1;
					}
					switch (alt33) {
						case 1 :
							// SelectClauseParser.g:258:26: Identifier
							{
							Identifier97=(Token)match(input,Identifier,FOLLOW_Identifier_in_window_specification1749);  
							stream_Identifier.add(Identifier97);

							}
							break;

					}

					// SelectClauseParser.g:258:38: ( partitioningSpec )?
					int alt34=2;
					int LA34_0 = input.LA(1);
					if ( (LA34_0==KW_CLUSTER||LA34_0==KW_DISTRIBUTE||LA34_0==KW_ORDER||LA34_0==KW_PARTITION||LA34_0==KW_SORT) ) {
						alt34=1;
					}
					switch (alt34) {
						case 1 :
							// SelectClauseParser.g:258:38: partitioningSpec
							{
							pushFollow(FOLLOW_partitioningSpec_in_window_specification1752);
							partitioningSpec98=gHiveParser.partitioningSpec();
							state._fsp--;

							stream_partitioningSpec.add(partitioningSpec98.getTree());
							}
							break;

					}

					// SelectClauseParser.g:258:56: ( window_frame )?
					int alt35=2;
					int LA35_0 = input.LA(1);
					if ( (LA35_0==KW_RANGE||LA35_0==KW_ROWS) ) {
						alt35=1;
					}
					switch (alt35) {
						case 1 :
							// SelectClauseParser.g:258:56: window_frame
							{
							pushFollow(FOLLOW_window_frame_in_window_specification1755);
							window_frame99=window_frame();
							state._fsp--;

							stream_window_frame.add(window_frame99.getTree());
							}
							break;

					}

					RPAREN100=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_window_specification1758);  
					stream_RPAREN.add(RPAREN100);

					}

					}
					break;

			}

			// AST REWRITE
			// elements: window_frame, partitioningSpec, Identifier
			// 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.getTree():null);

			root_0 = (CommonTree)adaptor.nil();
			// 258:79: -> ^( TOK_WINDOWSPEC ( Identifier )? ( partitioningSpec )? ( window_frame )? )
			{
				// SelectClauseParser.g:258:82: ^( TOK_WINDOWSPEC ( Identifier )? ( partitioningSpec )? ( window_frame )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.nil();
				root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(TOK_WINDOWSPEC, "TOK_WINDOWSPEC"), root_1);
				// SelectClauseParser.g:258:99: ( Identifier )?
				if ( stream_Identifier.hasNext() ) {
					adaptor.addChild(root_1, stream_Identifier.nextNode());
				}
				stream_Identifier.reset();

				// SelectClauseParser.g:258:111: ( partitioningSpec )?
				if ( stream_partitioningSpec.hasNext() ) {
					adaptor.addChild(root_1, stream_partitioningSpec.nextTree());
				}
				stream_partitioningSpec.reset();

				// SelectClauseParser.g:258:129: ( window_frame )?
				if ( stream_window_frame.hasNext() ) {
					adaptor.addChild(root_1, stream_window_frame.nextTree());
				}
				stream_window_frame.reset();

				adaptor.addChild(root_0, root_1);
				}

			}


			retval.tree = root_0;

			}

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

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

			 gParent.msgs.pop(); 
		}

		catch (RecognitionException e) {
		  throw e;
		}

		finally {
			// do for sure before leaving
		}
		return retval;
	}