int _m385 = mark(); synPredMatched385 = true;
int _m44 = mark(); synPredMatched44 = true;
	public final Expression  function_call(		PathExpr expr	) throws RecognitionException, TokenStreamException, PermissionDeniedException,EXistException {		Expression step;				Token  l = null;		Token  l2 = null;		Token  arg = null;		Token  l3 = null;		Token  l4 = null;		Token  i = null;		Token  f1 = null;		Token  f2 = null;					step = null;			PathExpr path = new PathExpr(pool);			PathExpr arg1 = new PathExpr(pool);			PathExpr arg2 = null;			Function fun = null;		int distance = 1;						switch ( LA(1)) {		case 33:		{			match(33);			match(LPAREN);			or_expr(path);			match(COMMA);			l = LT(1);			match(CONST);			match(RPAREN);			if ( inputState.guessing==0 ) {										if(path.returnsType() == Constants.TYPE_NODELIST) {				String val = l.getText() + "%";						   step = new OpEquals(pool, path, new Literal(val), Constants.EQ);				expr.add(step);						} else {						   step = new FunStartsWith(pool, path, new Literal(l.getText()));						   expr.add(step);					    }							}			break;		}		case 34:		{			match(34);			match(LPAREN);			or_expr(path);			match(COMMA);			l2 = LT(1);			match(CONST);			match(RPAREN);			if ( inputState.guessing==0 ) {										if(path.returnsType() == Constants.TYPE_NODELIST) {				String val = l2.getText();						   step = new OpEquals(pool, path, new Literal(l2.getText()), 				Constants.EQ);				expr.add(step);						} else {						   step = new FunEndsWith(pool, path, new Literal(l2.getText()));						   expr.add(step);					    }								}			break;		}		case LITERAL_contains:		{			match(LITERAL_contains);			match(LPAREN);			or_expr(path);			match(COMMA);			arg = LT(1);			match(CONST);			match(RPAREN);			if ( inputState.guessing==0 ) {								String term = "%" + arg.getText() + "%";							step =							  new OpEquals(pool, path, new Literal(term), Constants.EQ);				System.out.println(step.pprint());							expr.add(step);								}			break;		}		default:			if ((LA(1)==LITERAL_text) && (LA(2)==LPAREN)) {				match(LITERAL_text);				match(LPAREN);				match(RPAREN);				if ( inputState.guessing==0 ) {													step = new LocationStep(pool, -1, new TypeTest(Constants.TEXT_NODE));								expr.add(step);										}			}			else if ((LA(1)==LITERAL_text) && (_tokenSet_3.member(LA(2)))) {				match(LITERAL_text);				{				switch ( LA(1)) {				case SLASH:				{					match(SLASH);					break;				}				case DSLASH:				{					match(DSLASH);					break;				}				case EOF:				{					match(Token.EOF_TYPE);					break;				}				case LPPAREN:				{					match(LPPAREN);					break;				}				default:				{					throw new NoViableAltException(LT(1), getFilename());				}				}				}				if ( inputState.guessing==0 ) {												step = new LocationStep( pool, -1,								new NameTest("text"));							expr.add(step);										}			}			else if ((LA(1)==LITERAL_match) && (LA(2)==LPAREN)) {				match(LITERAL_match);				match(LPAREN);				or_expr(path);				match(COMMA);				l3 = LT(1);				match(CONST);				match(RPAREN);				if ( inputState.guessing==0 ) {										if(path.returnsType() == Constants.TYPE_NODELIST) {							step = new OpEquals(pool, path, new Literal(l3.getText()), 					Constants.REGEXP);					expr.add(step);						     }										}			}			else if ((LA(1)==LITERAL_match) && (_tokenSet_3.member(LA(2)))) {				match(LITERAL_match);				{				switch ( LA(1)) {				case SLASH:				{					match(SLASH);					break;				}				case DSLASH:				{					match(DSLASH);					break;				}				case EOF:				{					match(Token.EOF_TYPE);					break;				}				case LPPAREN:				{					match(LPPAREN);					break;				}				default:				{					throw new NoViableAltException(LT(1), getFilename());				}				}				}				if ( inputState.guessing==0 ) {												step = new LocationStep( pool, -1,								new NameTest("match"));							expr.add(step);										}			}			else if ((LA(1)==LITERAL_near) && (LA(2)==LPAREN)) {				match(LITERAL_near);				match(LPAREN);				or_expr(path);				match(COMMA);				l4 = LT(1);				match(CONST);				{				switch ( LA(1)) {				case COMMA:				{					match(COMMA);					i = LT(1);					match(INT);					if ( inputState.guessing==0 ) {						distance = Integer.parseInt(i.getText());					}					break;				}				case RPAREN:				{					break;				}				default:				{					throw new NoViableAltException(LT(1), getFilename());				}				}				}				match(RPAREN);				if ( inputState.guessing==0 ) {										FunNear near = new FunNear(pool);					near.setDistance(distance);					near.setPath(path);						    DBBroker broker = null;						    try {						      broker = pool.get();					Tokenizer tok = broker.getTextEngine().getTokenizer();					tok.setText(l4.getText());					org.exist.storage.analysis.TextToken token;					String next;					while((token = tok.nextToken(true)) != null) {					next = token.getText();					near.addTerm(next);					}						     } finally {						       pool.release(broker);						     }					expr.addPath(near);										}			}			else if ((LA(1)==LITERAL_near) && (_tokenSet_3.member(LA(2)))) {				match(LITERAL_near);				{				switch ( LA(1)) {				case SLASH:				{					match(SLASH);					break;				}				case DSLASH:				{					match(DSLASH);					break;				}				case EOF:				{					match(Token.EOF_TYPE);					break;				}				case LPPAREN:				{					match(LPPAREN);					break;				}				default:				{					throw new NoViableAltException(LT(1), getFilename());				}				}				}				if ( inputState.guessing==0 ) {												step = new LocationStep( pool, -1,								new NameTest("text"));							expr.add(step);										}			}			else {				boolean synPredMatched385 = false;				if (((LA(1)==FUNC) && (LA(2)==LPAREN))) {					int _m385 = mark();					synPredMatched385 = true;					inputState.guessing++;					try {						{						match(FUNC);						match(LPAREN);						match(RPAREN);						}					}					catch (RecognitionException pe) {						synPredMatched385 = false;					}					rewind(_m385);					inputState.guessing--;				}				if ( synPredMatched385 ) {					f1 = LT(1);					match(FUNC);					if (!( env.hasFunction(f1.getText()) ))					  throw new SemanticException(" env.hasFunction(f1.getText()) ");					match(LPAREN);					match(RPAREN);					if ( inputState.guessing==0 ) {														fun = Function.createFunction(pool, env.getFunction(f1.getText()));								expr.addPath(fun);												}				}				else if ((LA(1)==FUNC) && (LA(2)==LPAREN)) {					f2 = LT(1);					match(FUNC);					if (!( env.hasFunction(f2.getText()) ))					  throw new SemanticException(" env.hasFunction(f2.getText()) ");					if ( inputState.guessing==0 ) {														fun = Function.createFunction(pool, env.getFunction(f2.getText()));								expr.addPath(fun);												}					match(LPAREN);					or_expr(arg1);					if ( inputState.guessing==0 ) {						fun.addArgument(arg1);					}					{					_loop387:					do {						if ((LA(1)==COMMA)) {							match(COMMA);							if ( inputState.guessing==0 ) {								arg2 = new PathExpr(pool);							}							or_expr(arg2);							if ( inputState.guessing==0 ) {								fun.addArgument(arg2);							}						}						else {							break _loop387;						}											} while (true);					}					match(RPAREN);				}			else {				throw new NoViableAltException(LT(1), getFilename());			}			}}			return step;		}