functionDecl_AST = (org.exist.xquery.parser.XQueryAST)currentAST.root; returnAST = functionDecl_AST;
	public final void functionDecl() throws RecognitionException, TokenStreamException {				traceIn("functionDecl");		try { // debugging			returnAST = null;			ASTPair currentAST = new ASTPair();			org.exist.xquery.parser.XQueryAST functionDecl_AST = null;			String name= null;						match(LITERAL_declare);			match(LITERAL_function);			name=qName();			match(LPAREN);			{			switch ( LA(1)) {			case DOLLAR:			{				paramList();				astFactory.addASTChild(currentAST, returnAST);				break;			}			case RPAREN:			{				break;			}			default:			{				throw new NoViableAltException(LT(1), getFilename());			}			}			}			match(RPAREN);			{			switch ( LA(1)) {			case LITERAL_as:			{				returnType();				astFactory.addASTChild(currentAST, returnAST);				break;			}			case LCURLY:			{				break;			}			default:			{				throw new NoViableAltException(LT(1), getFilename());			}			}			}			functionBody();			astFactory.addASTChild(currentAST, returnAST);			if ( inputState.guessing==0 ) {				functionDecl_AST = (org.exist.xquery.parser.XQueryAST)currentAST.root;				functionDecl_AST= (org.exist.xquery.parser.XQueryAST)astFactory.make( (new ASTArray(2)).add((org.exist.xquery.parser.XQueryAST)astFactory.create(FUNCTION_DECL,name)).add(functionDecl_AST));				currentAST.root = functionDecl_AST;				currentAST.child = functionDecl_AST!=null &&functionDecl_AST.getFirstChild()!=null ?					functionDecl_AST.getFirstChild() : functionDecl_AST;				currentAST.advanceChildToEnd();			}			functionDecl_AST = (org.exist.xquery.parser.XQueryAST)currentAST.root;			returnAST = functionDecl_AST;		} finally { // debugging			traceOut("functionDecl");		}	}