org.exist.xquery.parser.XQueryAST tmp96_AST = null; tmp96_AST = (org.exist.xquery.parser.XQueryAST)astFactory.create(LT(1)); astFactory.addASTChild(currentAST, tmp96_AST);
org.exist.xquery.parser.XQueryAST tmp97_AST = null; tmp97_AST = (org.exist.xquery.parser.XQueryAST)astFactory.create(LT(1)); astFactory.addASTChild(currentAST, tmp97_AST);
	public final void functionDecl() throws RecognitionException, TokenStreamException, XPathException {				returnAST = null;		ASTPair currentAST = new ASTPair();		org.exist.xquery.parser.XQueryAST functionDecl_AST = null;		Token  lp = null;		org.exist.xquery.parser.XQueryAST lp_AST = null;		String name= null;				try {      // for error handling			match(LITERAL_declare);			match(LITERAL_function);			name=qName();			lp = LT(1);			lp_AST = (org.exist.xquery.parser.XQueryAST)astFactory.create(lp);			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:			case LITERAL_external:			{				break;			}			default:			{				throw new NoViableAltException(LT(1), getFilename());			}			}			}			{			switch ( LA(1)) {			case LCURLY:			{				functionBody();				astFactory.addASTChild(currentAST, returnAST);				break;			}			case LITERAL_external:			{				org.exist.xquery.parser.XQueryAST tmp96_AST = null;				tmp96_AST = (org.exist.xquery.parser.XQueryAST)astFactory.create(LT(1));				astFactory.addASTChild(currentAST, tmp96_AST);				match(LITERAL_external);				break;			}			default:			{				throw new NoViableAltException(LT(1), getFilename());			}			}			}			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)); 						functionDecl_AST.copyLexInfo(lp_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;		}		catch (RecognitionException e) {			if (inputState.guessing==0) {										lp_AST.setLine(e.getLine());						lp_AST.setColumn(e.getColumn());						throw new XPathException(lp_AST, "Syntax error within user defined function " + 							name + ": " + e.getMessage());								} else {				throw e;			}		}		returnAST = functionDecl_AST;	}