Parses the expression in <tt>input</tt>

@return the parsed expression
@throws ParseException if the expression contains one or more errors
509522
protected Expression parse() throws ParseException {
        Expression result = expression().simplify();
        if (tokenizer.current().isNotEnd()) {
            Token token = tokenizer.consume();
            errors.add(ParseError.error(token,
                                        String.format("Unexpected token: '%s'. Expected an expression.",
                                                      token.getSource())));
        }
        if (!errors.isEmpty()) {
            throw ParseException.create(errors);
        }
        return result;
    }
332144
private void parseRangeExpr() throws TTXPathException {

        parseAdditiveExpr();
        if (is("to", true)) {

            mPipeBuilder.addExpressionSingle();

            parseAdditiveExpr();
            mPipeBuilder.addRangeExpr(getTransaction());

        }
    }
357597
private function parseExpression (){
		$entities = array();

		do{
			$e = $this->MatchFuncs(array('parseAddition','parseEntity'));
			if( $e ){
				$entities[] = $e;
				// operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here
				if( !$this->PeekReg('/\\G\/[\/*]/') ){
					$delim = $this->MatchChar('/');
					if( $delim ){
						$entities[] = $this->NewObj1('Less_Tree_Anonymous',$delim);
					}
				}
			}
		}while($e);

		if( $entities ){
			return $this->NewObj1('Less_Tree_Expression',$entities);
		}
	}
556592
private ParseTree parseAdditiveExpression() {
    SourcePosition start = getTreeStartLocation();
    ParseTree left = parseMultiplicativeExpression();
    while (peekAdditiveOperator()) {
      Token operator = nextToken();
      ParseTree right = parseMultiplicativeExpression();
      left = new BinaryOperatorTree(getTreeLocation(start), left, operator, right);
    }
    return left;
  }
608026
public final JavaParser.expression_return expression() throws RecognitionException {
		JavaParser.expression_return retval = new JavaParser.expression_return();
		retval.start = input.LT(1);
		int expression_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 108) ) { return retval; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1119:5: ( conditionalExpression ( assignmentOperator expression )? )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1119:7: conditionalExpression ( assignmentOperator expression )?
			{
			pushFollow(FOLLOW_conditionalExpression_in_expression4875);
			conditionalExpression();
			state._fsp--;
			if (state.failed) return retval;
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1119:29: ( assignmentOperator expression )?
			int alt140=2;
			alt140 = dfa140.predict(input);
			switch (alt140) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1119:30: assignmentOperator expression
					{
					pushFollow(FOLLOW_assignmentOperator_in_expression4878);
					assignmentOperator();
					state._fsp--;
					if (state.failed) return retval;
					pushFollow(FOLLOW_expression_in_expression4880);
					expression();
					state._fsp--;
					if (state.failed) return retval;
					}
					break;

			}

			}

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

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 108, expression_StartIndex); }

		}
		return retval;
	}
386617
private Expression parseAtom() {
        // Parse a number
        if (tokenizer.current().isNumber()) {
            return new Number(tokenizer.consume().getContents());
        }
        // Parse a color
        if (tokenizer.current().isSpecialIdentifier("#")) {
            return new Color(tokenizer.consume().getSource());
        }

        // Parse an identifier or function call
        if (tokenizer.current().isIdentifier() || tokenizer.current().isString()) {
            return parseIdentifierOrFunctionCall();
        }

        // Parse as variable reference
        if (tokenizer.current().isSpecialIdentifier("$")) {
            return new VariableReference(tokenizer.consume().getContents());
        }

        // Parse as expression in braces
        if (tokenizer.current().isSymbol("(")) {
            tokenizer.consumeExpectedSymbol("(");
            Expression expression = parseExpression(true);
            tokenizer.consumeExpectedSymbol(")");
            if (expression instanceof Operation) {
                ((Operation) expression).protect();
            }
            return expression;
        }

        // Attribute values can be followed by things like "!import" -> make a value list
        if (tokenizer.current().isSymbol("!") && tokenizer.next().isIdentifier()) {
            tokenizer.consumeExpectedSymbol("!");
            return new Value("!" + tokenizer.consume().getContents());
        }

        // We failed! Report an error and return "" as value (we will fail anyway...)
        tokenizer.addError(tokenizer.current(),
                           "Unexpected token: '" + tokenizer.consume().getSource() + "'. Expected an expression.");
        return new Value("");
    }
230741
public final void constantExpression() throws RecognitionException {
		int constantExpression_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 107) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1115:5: ( expression )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1115:7: expression
			{
			pushFollow(FOLLOW_expression_in_constantExpression4858);
			expression();
			state._fsp--;
			if (state.failed) return;
			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 107, constantExpression_StartIndex); }

		}
	}
1201360
@SuppressWarnings("unchecked")
    public T parse(String input) throws Exception {
        validate(input);
        setContent(input);
        return (T) this;
    }
966536
function parseExpression() {
        var expr = parseAssignmentExpression();

        if (match(',')) {
            expr = {
                type: Syntax.SequenceExpression,
                expressions: [ expr ]
            };

            while (index < length) {
                if (!match(',')) {
                    break;
                }
                lex();
                expr.expressions.push(parseAssignmentExpression());
            }

        }
        return expr;
    }
224145
private void parseExprSingle() throws TTXPathException {

        mPipeBuilder.addExpressionSingle();

        final String tContent = mToken.getContent();
        if ("for".equals(tContent)) {
            parseForExpr();
        } else if ("some".equals(tContent) || "every".equals(tContent)) {
            parseQuantifiedExpr();
        } else if ("if".equals(tContent)) {
            parseIfExpr();
        } else {
            parseOrExpr();
        }
    }
153574
final public ExpressionToken MapKey() throws ParseException {
        Token t = null;
        ExpressionToken eTok = null;
        jj_consume_token(LBRACKET);
        t = jj_consume_token(STRING_LITERAL);
        jj_consume_token(RBRACKET);
        eTok = new MapKeyToken(t.image);
        {
            if(true) return eTok;
        }
        throw new Error("Missing return statement in function");
    }
1164802
private void parseForExpr() throws TTXPathException {

        // get number of all for conditions
        final int rangeVarNo = parseSimpleForClause();
        consume("return", true);

        // parse return clause
        parseExprSingle();

        mPipeBuilder.addForExpression(rangeVarNo);

    }
406768
@Override
	public ImmutableList<TargetAtom> parse(String input) throws TargetQueryParserException {
		StringBuffer bf = new StringBuffer(input.trim());
		if (!bf.substring(bf.length() - 2, bf.length()).equals(" .")) {
			bf.insert(bf.length() - 1, ' ');
		}
		if (!prefixes.isEmpty()) {
			// Update the input by appending the directives
			appendDirectives(bf);
		}		
		try {
			CharStream inputStream = CharStreams.fromString(bf.toString());
			TurtleOBDALexer lexer = new TurtleOBDALexer(inputStream);

			//substitute the standard ConsoleErrorListener (simply print out the error) with ThrowingErrorListener
            lexer.removeErrorListeners();
			lexer.addErrorListener(ThrowingErrorListener.INSTANCE);

			CommonTokenStream tokenStream = new CommonTokenStream(lexer);
			TurtleOBDAParser parser = new TurtleOBDAParser(tokenStream);
            //substitute the standard ConsoleErrorListener (simply print out the error) with ThrowingErrorListener
			parser.removeErrorListeners();
			parser.addErrorListener(ThrowingErrorListener.INSTANCE);

			return (ImmutableList<TargetAtom>)visitor.visitParse(parser.parse());
		} catch (RuntimeException e) {
			throw new TargetQueryParserException(e.getMessage(), e);
		}
	}
540164
public Number parse(String text) throws ParseException {
        ParsePosition parsePosition = new ParsePosition(0);
        Number result = parse(text, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new ParseException("Unparseable number: \"" + text + '"',
                                     parsePosition.getErrorIndex());
        }
        return result;
    }
878777
final public Selector QueryExpr() throws ParseException {
                         Selector ans;
    ans = BooleanExpr();
    jj_consume_token(0);
                              {if (true) return ans;}
    throw new Error("Missing return statement in function");
  }
701722
public final void unaryExpression() throws RecognitionException {
		int unaryExpression_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 124) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1196:5: ( '+' unaryExpression | '-' unaryExpression | '++' primary | '--' primary | unaryExpressionNotPlusMinus )
			int alt156=5;
			switch ( input.LA(1) ) {
			case 40:
				{
				alt156=1;
				}
				break;
			case 44:
				{
				alt156=2;
				}
				break;
			case 41:
				{
				alt156=3;
				}
				break;
			case 45:
				{
				alt156=4;
				}
				break;
			case CharacterLiteral:
			case DecimalLiteral:
			case FloatingPointLiteral:
			case HexLiteral:
			case Identifier:
			case OctalLiteral:
			case StringLiteral:
			case 29:
			case 36:
			case 53:
			case 65:
			case 67:
			case 70:
			case 71:
			case 77:
			case 79:
			case 80:
			case 82:
			case 85:
			case 92:
			case 94:
			case 97:
			case 98:
			case 105:
			case 108:
			case 111:
			case 115:
			case 118:
			case 126:
				{
				alt156=5;
				}
				break;
			default:
				if (state.backtracking>0) {state.failed=true; return;}
				NoViableAltException nvae =
					new NoViableAltException("", 156, 0, input);
				throw nvae;
			}
			switch (alt156) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1196:9: '+' unaryExpression
					{
					match(input,40,FOLLOW_40_in_unaryExpression5484); if (state.failed) return;
					pushFollow(FOLLOW_unaryExpression_in_unaryExpression5486);
					unaryExpression();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1197:7: '-' unaryExpression
					{
					match(input,44,FOLLOW_44_in_unaryExpression5494); if (state.failed) return;
					pushFollow(FOLLOW_unaryExpression_in_unaryExpression5496);
					unaryExpression();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 3 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1198:9: '++' primary
					{
					match(input,41,FOLLOW_41_in_unaryExpression5506); if (state.failed) return;
					pushFollow(FOLLOW_primary_in_unaryExpression5508);
					primary();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 4 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1199:9: '--' primary
					{
					match(input,45,FOLLOW_45_in_unaryExpression5518); if (state.failed) return;
					pushFollow(FOLLOW_primary_in_unaryExpression5520);
					primary();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 5 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1200:9: unaryExpressionNotPlusMinus
					{
					pushFollow(FOLLOW_unaryExpressionNotPlusMinus_in_unaryExpression5530);
					unaryExpressionNotPlusMinus();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}
		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 124, unaryExpression_StartIndex); }

		}
	}
593160
public void validate() throws Exception {
        boolean validated = true;
        for (ValueExpression expression : this.getApplicableExpressions()) {
            try {
                expression.validate();
                validated = true;
            } catch (Throwable e) {
                validated = false;
            }
            if (validated) {
                break;
            }
        }
        Assert.assertTrue("At least one expression type should match the input", validated);
    }