expression : LNOT expression %prec ULNOT
713
def p_expression_ulnot(self, p):
        ''
        p[0] = Ulnot(p[2], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
495203
public final EObject rulePrefixExpression() throws RecognitionException {
        EObject current = null;

        Token otherlv_1=null;
        EObject lv_expression_2_0 = null;

        EObject this_Atom_3 = null;


         enterRule(); 
            
        try {
            // InternalSimpleExpressions.g:361:28: ( ( ( () otherlv_1= '!' ( (lv_expression_2_0= ruleAtom ) ) ) | this_Atom_3= ruleAtom ) )
            // InternalSimpleExpressions.g:362:1: ( ( () otherlv_1= '!' ( (lv_expression_2_0= ruleAtom ) ) ) | this_Atom_3= ruleAtom )
            {
            // InternalSimpleExpressions.g:362:1: ( ( () otherlv_1= '!' ( (lv_expression_2_0= ruleAtom ) ) ) | this_Atom_3= ruleAtom )
            int alt6=2;
            int LA6_0 = input.LA(1);

            if ( (LA6_0==21) ) {
                alt6=1;
            }
            else if ( ((LA6_0>=RULE_INT && LA6_0<=RULE_ID)||LA6_0==13||(LA6_0>=22 && LA6_0<=23)) ) {
                alt6=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 6, 0, input);

                throw nvae;
            }
            switch (alt6) {
                case 1 :
                    // InternalSimpleExpressions.g:362:2: ( () otherlv_1= '!' ( (lv_expression_2_0= ruleAtom ) ) )
                    {
                    // InternalSimpleExpressions.g:362:2: ( () otherlv_1= '!' ( (lv_expression_2_0= ruleAtom ) ) )
                    // InternalSimpleExpressions.g:362:3: () otherlv_1= '!' ( (lv_expression_2_0= ruleAtom ) )
                    {
                    // InternalSimpleExpressions.g:362:3: ()
                    // InternalSimpleExpressions.g:363:5: 
                    {

                            current = forceCreateModelElement(
                                grammarAccess.getPrefixExpressionAccess().getNotExpressionAction_0_0(),
                                current);
                        

                    }

                    otherlv_1=(Token)match(input,21,FOLLOW_5); 

                        	newLeafNode(otherlv_1, grammarAccess.getPrefixExpressionAccess().getExclamationMarkKeyword_0_1());
                        
                    // InternalSimpleExpressions.g:372:1: ( (lv_expression_2_0= ruleAtom ) )
                    // InternalSimpleExpressions.g:373:1: (lv_expression_2_0= ruleAtom )
                    {
                    // InternalSimpleExpressions.g:373:1: (lv_expression_2_0= ruleAtom )
                    // InternalSimpleExpressions.g:374:3: lv_expression_2_0= ruleAtom
                    {
                     
                    	        newCompositeNode(grammarAccess.getPrefixExpressionAccess().getExpressionAtomParserRuleCall_0_2_0()); 
                    	    
                    pushFollow(FOLLOW_2);
                    lv_expression_2_0=ruleAtom();

                    state._fsp--;


                    	        if (current==null) {
                    	            current = createModelElementForParent(grammarAccess.getPrefixExpressionRule());
                    	        }
                           		set(
                           			current, 
                           			"expression",
                            		lv_expression_2_0, 
                            		"org.eclipse.xtext.xtext.generator.parser.antlr.splitting.SimpleExpressions.Atom");
                    	        afterParserOrEnumRuleCall();
                    	    

                    }


                    }


                    }


                    }
                    break;
                case 2 :
                    // InternalSimpleExpressions.g:392:5: this_Atom_3= ruleAtom
                    {
                     
                            newCompositeNode(grammarAccess.getPrefixExpressionAccess().getAtomParserRuleCall_1()); 
                        
                    pushFollow(FOLLOW_2);
                    this_Atom_3=ruleAtom();

                    state._fsp--;

                     
                            current = this_Atom_3; 
                            afterParserOrEnumRuleCall();
                        

                    }
                    break;

            }


            }

             leaveRule(); 
        }
         
            catch (RecognitionException re) { 
                recover(input,re); 
                appendSkippedTokens();
            } 
        finally {
        }
        return current;
    }
1020537
def p_call_expr_nobf(self, p):
        
        if len(p) == 3:
            p[0] = ast.FunctionCall(p[1], p[2])
        elif len(p) == 4:
            p[0] = ast.DotAccessor(p[1], p[3])
        else:
            p[0] = ast.BracketAccessor(p[1], p[3])
1209624
def _parseExpressionTerm(self, src):
        
        ctxsrc = src

        result, src = self._getMatchResult(self.re_num, src)
        if result is not None:
            units, src = self._getMatchResult(self.re_unit, src)
            term = self.cssBuilder.termNumber(result, units)
            return src.lstrip(), term

        result, src = self._getString(src, self.re_uri)
        if result is not None:
            # XXX URL!!!!
            term = self.cssBuilder.termURI(result)
            return src.lstrip(), term

        result, src = self._getString(src)
        if result is not None:
            term = self.cssBuilder.termString(result)
            return src.lstrip(), term

        result, src = self._getMatchResult(self.re_functionterm, src)
        if result is not None:
            src, params = self._parseExpression(src, True)
            if src[0] != ')':
                raise self.ParseError('Terminal function expression expected closing \')\'', src, ctxsrc)
            src = src[1:].lstrip()
            term = self.cssBuilder.termFunction(result, params)
            return src, term

        result, src = self._getMatchResult(self.re_rgbcolor, src)
        if result is not None:
            term = self.cssBuilder.termRGB(result)
            return src.lstrip(), term

        result, src = self._getMatchResult(self.re_unicoderange, src)
        if result is not None:
            term = self.cssBuilder.termUnicodeRange(result)
            return src.lstrip(), term

        nsPrefix, src = self._getMatchResult(self.re_namespace_selector, src)
        result, src = self._getIdent(src)
        if result is not None:
            if nsPrefix is not None:
                result = self.cssBuilder.resolveNamespacePrefix(nsPrefix, result)
            term = self.cssBuilder.termIdent(result)
            return src.lstrip(), term

        result, src = self._getMatchResult(self.re_unicodeid, src)
        if result is not None:
            term = self.cssBuilder.termIdent(result)
            return src.lstrip(), term

        result, src = self._getMatchResult(self.re_unicodestr, src)
        if result is not None:
            term = self.cssBuilder.termString(result)
            return src.lstrip(), term

        return self.cssBuilder.termUnknown(src)
467920
def p_expr_nobf(self, p):
        
        if len(p) == 2:
            p[0] = p[1]
        else:
            p[0] = ast.Comma(left=p[1], right=p[3])
105586
static int prec(TokenKind token) {
        JCTree.Tag oc = optag(token);
        return (oc != NO_TAG) ? TreeInfo.opPrec(oc) : -1;
    }
1211132
function expression(rbp) {
			var fnLeft;

			oToken = advance();
			if (!oToken) {
				error("Expected expression but instead saw end of input", sInput);
			}
			fnLeft = mSymbols[oToken.id].nud(oToken, oParser);

			while (iNextToken < aTokens.length) {
				oToken = current();
				if (rbp >= (mSymbols[oToken.id].lbp || 0)) {
					break;
				}
				advance();
				fnLeft = mSymbols[oToken.id].led(oToken, oParser, fnLeft);
			}

			return fnLeft;
		}
999751
def in_global_expression(self):
        """"""
        return (self.parenthesis_count == 0 and self.curly_bracket_count == 0
                and self.square_bracket_count == 0
                and not self.in_single_quote and not self.in_double_quote)
510253
def p_expression_uand(self, p):
        ''
        p[0] = Uand(p[2], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
691166
def p_primary_expr_no_brace_1(self, p):
        """"""
        p[1]._mangle_candidate = True
        p[1]._in_expression = True
        p[0] = p[1]
308837
def p_and_expression(tok):
        """"""
        if len(tok) == 4:
            tok[0] = LogicalBinOpRule(tok[2], tok[1], tok[3])
        else:
            tok[0] = tok[1]
1262830
def p_expression_uxnor(self, p):
        ''
        p[0] = Uxnor(p[2], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
30610
def p_expression_b_op(p):
    ''''''
    if p[2] == 'AND':
        p[0] = p[1] & p[3]
    elif p[2] == 'OR':
        p[0] = p[1] | p[3]
287776
def p_expression_sll(self, p):
        ''
        p[0] = Sll(p[1], p[3], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
10293
def p_expr_post_incdec(p):
    ''''''
    p[0] = ast.PostIncDecOp(p[2], p[1], lineno=p.lineno(2))
1133734
function nfx($expr) {

                        $index = 0;
                        $stack = new EvalMathStack;
                        $output = array(); // postfix form of expression, to be passed to pfx()
                        $expr = trim(strtolower($expr));

                        $ops   = array('+', '-', '*', '/', '^', '_');
                        $ops_r = array('+'=>0,'-'=>0,'*'=>0,'/'=>0,'^'=>1); // right-associative operator?  
                        $ops_p = array('+'=>0,'-'=>0,'*'=>1,'/'=>1,'_'=>1,'^'=>2); // operator precedence

                        $expecting_op = false; // we use this in syntax-checking the expression
                                                                   // and determining when a - is a negation

                        if (preg_match("/[^\w\s+*^\/()\.,-]/", $expr, $matches)) { // make sure the characters are all good
                                return $this->trigger("illegal character '{$matches[0]}'");
                        }

                        while(1) { // 1 Infinite Loop ;)
                                $op = substr($expr, $index, 1); // get the first character at the current index
                                // find out if we're currently at the beginning of a number/variable/function/parenthesis/operand
                                $ex = preg_match('/^([a-z]\w*\(?|\d+(?:\.\d*)?|\.\d+|\()/', substr($expr, $index), $match);
                                //===============
                                if ($op == '-' and !$expecting_op) { // is it a negation instead of a minus?
                                        $stack->push('_'); // put a negation on the stack
                                        $index++;
                                } elseif ($op == '_') { // we have to explicitly deny this, because it's legal on the stack 
                                        return $this->trigger("illegal character '_'"); // but not in the input expression
                                //===============
                                } elseif ((in_array($op, $ops) or $ex) and $expecting_op) { // are we putting an operator on the stack?
                                        if ($ex) { // are we expecting an operator but have a number/variable/function/opening parethesis?
                                                $op = '*'; $index--; // it's an implicit multiplication
                                        }
                                        // heart of the algorithm:
                                        while($stack->count > 0 and ($o2 = $stack->last()) and in_array($o2, $ops) and ($ops_r[$op] ? $ops_p[$op] < $ops_p[$o2] : $ops_p[$op] <= $ops_p[$o2])) {
                                                $output[] = $stack->pop(); // pop stuff off the stack into the output
                                        }
                                        // many thanks: http://en.wikipedia.org/wiki/Reverse_Polish_notation#The_algorithm_in_detail
                                        $stack->push($op); // finally put OUR operator onto the stack
                                        $index++;
                                        $expecting_op = false;
                                //===============
                                } elseif ($op == ')' and $expecting_op) { // ready to close a parenthesis?
                                        $expectingOperand = false; 
                                        while (($o2 = $stack->pop()) != '(') { // pop off the stack back to the last (
                                                if (is_null($o2)) return $this->trigger("unexpected ')'");
                                                else $output[] = $o2;
                                        }
                                        if (preg_match("/^([a-z]\w*)\($/", $stack->last(2), $matches)) { // did we just close a function?
                                                $fnn = $matches[1]; // get the function name
                                                $arg_count = $stack->pop(); // see how many arguments there were (cleverly stored on the stack, thank you)
                                                $output[] = $stack->pop(); // pop the function and push onto the output
                                                if (in_array($fnn, $this->fb)) { // check the argument count
                                                        if($arg_count > 1)
                                                                return $this->trigger("too many arguments ($arg_count given, 1 expected)");
                                                } elseif (array_key_exists($fnn, $this->f)) {
                                                        if ($arg_count != count($this->f[$fnn]['args']))
                                                                return $this->trigger("wrong number of arguments ($arg_count given, " . count($this->f[$fnn]['args']) . " expected)");
                                                } else { // did we somehow push a non-function on the stack? this should never happen
                                                        return $this->trigger("internal error");
                                                }
                                        }
                                        $index++;
                                //===============
                                } elseif ($op == ',' and $expecting_op) { // did we just finish a function argument?
                                        while (($o2 = $stack->pop()) != '(') { 
                                                if (is_null($o2)) return $this->trigger("unexpected ','"); // oops, never had a (
                                                else $output[] = $o2; // pop the argument expression stuff and push onto the output
                                        }
                                        // make sure there was a function
                                        if (!preg_match("/^([a-z]\w*)\($/", $stack->last(2), $matches))
                                                return $this->trigger("unexpected ','");
                                        $stack->push($stack->pop()+1); // increment the argument count
                                        $stack->push('('); // put the ( back on, we'll need to pop back to it again
                                        $index++;
                                        $expecting_op = false;
                                //===============
                                } elseif ($op == '(' and !$expecting_op) {
                                        $stack->push('('); // that was easy
                                        $index++;
                                        $allow_neg = true;
                                //===============
                                } elseif ($ex and !$expecting_op) { // do we now have a function/variable/number?
                                        $expecting_op = true;
                                        $val = $match[1];
                                        if (preg_match("/^([a-z]\w*)\($/", $val, $matches)) { // may be func, or variable w/ implicit multiplication against parentheses...
                                                if (in_array($matches[1], $this->fb) or array_key_exists($matches[1], $this->f)) { // it's a func
                                                        $stack->push($val);
                                                        $stack->push(1);
                                                        $stack->push('(');
                                                        $expecting_op = false;
                                                } else { // it's a var w/ implicit multiplication
                                                        $val = $matches[1];
                                                        $output[] = $val;
                                                }
                                        } else { // it's a plain old var or num
                                                $output[] = $val;
                                        }
                                        $index += strlen($val);
                                //===============
                                } elseif ($op == ')') { // miscellaneous error checking
                                        return $this->trigger("unexpected ')'");
                                } elseif (in_array($op, $ops) and !$expecting_op) {
                                        return $this->trigger("unexpected operator '$op'");
                                } else { // I don't even want to know what you did to get here
                                        return $this->trigger("an unexpected error occured");
                                }
                                if ($index == strlen($expr)) {
                                        if (in_array($op, $ops)) { // did we end with an operator? bad.
                                                return $this->trigger("operator '$op' lacks operand");
                                        } else {
                                                break;
                                        }
                                }
                                while (substr($expr, $index, 1) == ' ') { // step the index past whitespace (pretty much turns whitespace 
                                        $index++;                             // into implicit multiplication if no operator is there)
                                }

                        } 
                        while (!is_null($op = $stack->pop())) { // pop everything off the stack and push onto output
                                if ($op == '(') return $this->trigger("expecting ')'"); // if there are (s on the stack, ()s were unbalanced
                                $output[] = $op;
                        }
                        return $output;
                }
1050434
@Override
  public void exitNotExpression(GDLParser.NotExpressionContext ctx) {
    if (!ctx.NOT().isEmpty()) {
      Predicate not = new Not(currentPredicates.pop());
      currentPredicates.add(not);
    }
  }