Adds a postfix unary operator.

@param parser the parser for the operator.
@param precedence the precedence number.
@return this.
555329
public OperatorTable<T> postfix(
      Parser<? extends Function<? super T, ? extends T>> parser, int precedence) {
    ops.add(new Operator(parser, precedence, Associativity.POSTFIX));
    return this;
  }
917252
function addParensIndent(tokens) {
            const parenStack = [];
            const parenPairs = [];

            tokens.forEach(nextToken => {

                // Accumulate a list of parenthesis pairs
                if (astUtils.isOpeningParenToken(nextToken)) {
                    parenStack.push(nextToken);
                } else if (astUtils.isClosingParenToken(nextToken)) {
                    parenPairs.unshift({ left: parenStack.pop(), right: nextToken });
                }
            });

            parenPairs.forEach(pair => {
                const leftParen = pair.left;
                const rightParen = pair.right;

                // We only want to handle parens around expressions, so exclude parentheses that are in function parameters and function call arguments.
                if (!parameterParens.has(leftParen) && !parameterParens.has(rightParen)) {
                    const parenthesizedTokens = new Set(sourceCode.getTokensBetween(leftParen, rightParen));

                    parenthesizedTokens.forEach(token => {
                        if (!parenthesizedTokens.has(offsets.getFirstDependency(token))) {
                            offsets.setDesiredOffset(token, leftParen, 1);
                        }
                    });
                }

                offsets.setDesiredOffset(rightParen, leftParen, 0);
            });
        }
1166060
public final void unaryExpressionNotPlusMinus() throws RecognitionException {
		int unaryExpressionNotPlusMinus_StartIndex = input.index();

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

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1204:5: ( '~' unaryExpression | '!' unaryExpression | castExpression | primary ( selector )* ( '++' | '--' )? )
			int alt159=4;
			switch ( input.LA(1) ) {
			case 126:
				{
				alt159=1;
				}
				break;
			case 29:
				{
				alt159=2;
				}
				break;
			case 36:
				{
				switch ( input.LA(2) ) {
				case 65:
				case 67:
				case 71:
				case 77:
				case 85:
				case 92:
				case 94:
				case 105:
					{
					int LA159_20 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case Identifier:
					{
					int LA159_21 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 40:
					{
					int LA159_22 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 44:
					{
					int LA159_23 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 41:
					{
					int LA159_24 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 45:
					{
					int LA159_25 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 126:
					{
					int LA159_26 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 29:
					{
					int LA159_27 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 36:
					{
					int LA159_28 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 53:
					{
					int LA159_29 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 111:
					{
					int LA159_30 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 108:
					{
					int LA159_31 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 80:
					{
					int LA159_32 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 79:
					{
					int LA159_33 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 70:
					{
					int LA159_34 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case DecimalLiteral:
				case HexLiteral:
				case OctalLiteral:
					{
					int LA159_35 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case FloatingPointLiteral:
					{
					int LA159_36 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case CharacterLiteral:
					{
					int LA159_37 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case StringLiteral:
					{
					int LA159_38 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 82:
				case 115:
					{
					int LA159_39 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 98:
					{
					int LA159_40 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 97:
					{
					int LA159_41 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				case 118:
					{
					int LA159_42 = input.LA(3);
					if ( (synpred240_Java()) ) {
						alt159=3;
					}
					else if ( (true) ) {
						alt159=4;
					}

					}
					break;
				default:
					if (state.backtracking>0) {state.failed=true; return;}
					int nvaeMark = input.mark();
					try {
						input.consume();
						NoViableAltException nvae =
							new NoViableAltException("", 159, 3, input);
						throw nvae;
					} finally {
						input.rewind(nvaeMark);
					}
				}
				}
				break;
			case CharacterLiteral:
			case DecimalLiteral:
			case FloatingPointLiteral:
			case HexLiteral:
			case Identifier:
			case OctalLiteral:
			case StringLiteral:
			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:
				{
				alt159=4;
				}
				break;
			default:
				if (state.backtracking>0) {state.failed=true; return;}
				NoViableAltException nvae =
					new NoViableAltException("", 159, 0, input);
				throw nvae;
			}
			switch (alt159) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1204:9: '~' unaryExpression
					{
					match(input,126,FOLLOW_126_in_unaryExpressionNotPlusMinus5549); if (state.failed) return;
					pushFollow(FOLLOW_unaryExpression_in_unaryExpressionNotPlusMinus5551);
					unaryExpression();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1205:8: '!' unaryExpression
					{
					match(input,29,FOLLOW_29_in_unaryExpressionNotPlusMinus5560); if (state.failed) return;
					pushFollow(FOLLOW_unaryExpression_in_unaryExpressionNotPlusMinus5562);
					unaryExpression();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 3 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1206:9: castExpression
					{
					pushFollow(FOLLOW_castExpression_in_unaryExpressionNotPlusMinus5572);
					castExpression();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 4 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1207:9: primary ( selector )* ( '++' | '--' )?
					{
					pushFollow(FOLLOW_primary_in_unaryExpressionNotPlusMinus5582);
					primary();
					state._fsp--;
					if (state.failed) return;
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1207:17: ( selector )*
					loop157:
					while (true) {
						int alt157=2;
						int LA157_0 = input.LA(1);
						if ( (LA157_0==47||LA157_0==59) ) {
							alt157=1;
						}

						switch (alt157) {
						case 1 :
							// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1207:17: selector
							{
							pushFollow(FOLLOW_selector_in_unaryExpressionNotPlusMinus5584);
							selector();
							state._fsp--;
							if (state.failed) return;
							}
							break;

						default :
							break loop157;
						}
					}

					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1207:27: ( '++' | '--' )?
					int alt158=2;
					int LA158_0 = input.LA(1);
					if ( (LA158_0==41||LA158_0==45) ) {
						alt158=1;
					}
					switch (alt158) {
						case 1 :
							// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:
							{
							if ( input.LA(1)==41||input.LA(1)==45 ) {
								input.consume();
								state.errorRecovery=false;
								state.failed=false;
							}
							else {
								if (state.backtracking>0) {state.failed=true; return;}
								MismatchedSetException mse = new MismatchedSetException(null,input);
								throw mse;
							}
							}
							break;

					}

					}
					break;

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

		}
	}
585025
function parsePostfixExpression() {
        var expr, token, startToken = lookahead;

        expr = inheritCoverGrammar(parseLeftHandSideExpressionAllowCall);

        if (!hasLineTerminator && lookahead.type === Token.Punctuator) {
            if (match('++') || match('--')) {
                // ECMA-262 11.3.1, 11.3.2
                if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
                    tolerateError(Messages.StrictLHSPostfix);
                }

                if (!isAssignmentTarget) {
                    tolerateError(Messages.InvalidLHSInAssignment);
                }

                isAssignmentTarget = isBindingElement = false;

                token = lex();
                expr = new WrappingNode(startToken).finishPostfixExpression(token.value, expr);
            }
        }

        return expr;
    }
1243638
public Grammar register(@NonNull ParserTokenType type, @NonNull InfixHandler handler) {
      infixHandlers.put(type, handler);
      return this;
   }
1036197
public static Integer parserInteger(JsonPullParser parser) throws IOException,
			JsonFormatException {

		State eventType = parser.getEventType();
		if (eventType == State.VALUE_NULL) {
			return null;
		} else if (eventType == State.VALUE_LONG) {
			return (int) parser.getValueLong();
		} else {
			throw new IllegalStateException("unexpected state. expected=VALUE_LONG, but get="
					+ eventType.toString());
		}
	}
1127863
static BaseTypeSignature parse(final Parser parser) {
        switch (parser.peek()) {
        case 'B':
            parser.next();
            return new BaseTypeSignature("byte");
        case 'C':
            parser.next();
            return new BaseTypeSignature("char");
        case 'D':
            parser.next();
            return new BaseTypeSignature("double");
        case 'F':
            parser.next();
            return new BaseTypeSignature("float");
        case 'I':
            parser.next();
            return new BaseTypeSignature("int");
        case 'J':
            parser.next();
            return new BaseTypeSignature("long");
        case 'S':
            parser.next();
            return new BaseTypeSignature("short");
        case 'Z':
            parser.next();
            return new BaseTypeSignature("boolean");
        case 'V':
            parser.next();
            return new BaseTypeSignature("void");
        default:
            return null;
        }
    }
1095169
static String paren(LabelOperatorPrecedence op, Label l) {
        if (op.compareTo(l.precedence())<0)
            return '('+l.getExpression()+')';
        return l.getExpression();
    }
947848
private ParseTree parseUnaryExpression() {
    SourcePosition start = getTreeStartLocation();
    if (peekUnaryOperator()) {
      Token operator = nextToken();
      ParseTree operand = parseUnaryExpression();
      return new UnaryExpressionTree(getTreeLocation(start), operator, operand);
    } else if (peekAwaitExpression()) {
      return parseAwaitExpression();
    } else {
      return parseUpdateExpression();
    }
  }
785900
public void addRuleParserBefore(IRuleParser parser, Class<? extends IRuleParser> beforeParser) {
        int index = getIndexOfClass(ruleParsers, beforeParser);
        if (index == -1) {
            throw new ParserAddException("parser " + beforeParser.getSimpleName() + " has not been added");
        }
        ruleParsers.add(index, parser);
    }
532599
public final void addParser(@NotNull final ParserConfig parser) {
        Contract.requireArgNotNull("parser", parser);
        if (list == null) {
            list = new ArrayList<>();
        }
        list.add(parser);
    }
627122
public final void castExpression() throws RecognitionException {
		int castExpression_StartIndex = input.index();

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

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1211:5: ( '(' primitiveType ')' unaryExpression | '(' ( type | expression ) ')' unaryExpressionNotPlusMinus )
			int alt161=2;
			int LA161_0 = input.LA(1);
			if ( (LA161_0==36) ) {
				int LA161_1 = input.LA(2);
				if ( (LA161_1==65||LA161_1==67||LA161_1==71||LA161_1==77||LA161_1==85||LA161_1==92||LA161_1==94||LA161_1==105) ) {
					int LA161_2 = input.LA(3);
					if ( (synpred244_Java()) ) {
						alt161=1;
					}
					else if ( (true) ) {
						alt161=2;
					}

				}
				else if ( ((LA161_1 >= CharacterLiteral && LA161_1 <= DecimalLiteral)||LA161_1==FloatingPointLiteral||(LA161_1 >= HexLiteral && LA161_1 <= Identifier)||(LA161_1 >= OctalLiteral && LA161_1 <= StringLiteral)||LA161_1==29||LA161_1==36||(LA161_1 >= 40 && LA161_1 <= 41)||(LA161_1 >= 44 && LA161_1 <= 45)||LA161_1==53||LA161_1==70||(LA161_1 >= 79 && LA161_1 <= 80)||LA161_1==82||(LA161_1 >= 97 && LA161_1 <= 98)||LA161_1==108||LA161_1==111||LA161_1==115||LA161_1==118||LA161_1==126) ) {
					alt161=2;
				}

				else {
					if (state.backtracking>0) {state.failed=true; return;}
					int nvaeMark = input.mark();
					try {
						input.consume();
						NoViableAltException nvae =
							new NoViableAltException("", 161, 1, input);
						throw nvae;
					} finally {
						input.rewind(nvaeMark);
					}
				}

			}

			else {
				if (state.backtracking>0) {state.failed=true; return;}
				NoViableAltException nvae =
					new NoViableAltException("", 161, 0, input);
				throw nvae;
			}

			switch (alt161) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1211:8: '(' primitiveType ')' unaryExpression
					{
					match(input,36,FOLLOW_36_in_castExpression5610); if (state.failed) return;
					pushFollow(FOLLOW_primitiveType_in_castExpression5612);
					primitiveType();
					state._fsp--;
					if (state.failed) return;
					match(input,37,FOLLOW_37_in_castExpression5614); if (state.failed) return;
					pushFollow(FOLLOW_unaryExpression_in_castExpression5616);
					unaryExpression();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1212:8: '(' ( type | expression ) ')' unaryExpressionNotPlusMinus
					{
					match(input,36,FOLLOW_36_in_castExpression5625); if (state.failed) return;
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1212:12: ( type | expression )
					int alt160=2;
					switch ( input.LA(1) ) {
					case Identifier:
						{
						int LA160_1 = input.LA(2);
						if ( (synpred245_Java()) ) {
							alt160=1;
						}
						else if ( (true) ) {
							alt160=2;
						}

						}
						break;
					case 65:
					case 67:
					case 71:
					case 77:
					case 85:
					case 92:
					case 94:
					case 105:
						{
						switch ( input.LA(2) ) {
						case 59:
							{
							int LA160_51 = input.LA(3);
							if ( (synpred245_Java()) ) {
								alt160=1;
							}
							else if ( (true) ) {
								alt160=2;
							}

							}
							break;
						case 37:
							{
							alt160=1;
							}
							break;
						case 47:
							{
							alt160=2;
							}
							break;
						default:
							if (state.backtracking>0) {state.failed=true; return;}
							int nvaeMark = input.mark();
							try {
								input.consume();
								NoViableAltException nvae =
									new NoViableAltException("", 160, 2, input);
								throw nvae;
							} finally {
								input.rewind(nvaeMark);
							}
						}
						}
						break;
					case CharacterLiteral:
					case DecimalLiteral:
					case FloatingPointLiteral:
					case HexLiteral:
					case OctalLiteral:
					case StringLiteral:
					case 29:
					case 36:
					case 40:
					case 41:
					case 44:
					case 45:
					case 53:
					case 70:
					case 79:
					case 80:
					case 82:
					case 97:
					case 98:
					case 108:
					case 111:
					case 115:
					case 118:
					case 126:
						{
						alt160=2;
						}
						break;
					default:
						if (state.backtracking>0) {state.failed=true; return;}
						NoViableAltException nvae =
							new NoViableAltException("", 160, 0, input);
						throw nvae;
					}
					switch (alt160) {
						case 1 :
							// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1212:13: type
							{
							pushFollow(FOLLOW_type_in_castExpression5628);
							type();
							state._fsp--;
							if (state.failed) return;
							}
							break;
						case 2 :
							// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1212:20: expression
							{
							pushFollow(FOLLOW_expression_in_castExpression5632);
							expression();
							state._fsp--;
							if (state.failed) return;
							}
							break;

					}

					match(input,37,FOLLOW_37_in_castExpression5635); if (state.failed) return;
					pushFollow(FOLLOW_unaryExpressionNotPlusMinus_in_castExpression5637);
					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, 126, castExpression_StartIndex); }

		}
	}
1047819
def accept_operator(self, precedence):
        """"""
        match = grammar.infix(self.tokens)
        if not match:
            return

        if match.operator.precedence < precedence:
            return

        # The next thing is an operator that we want. Now match it for real.
        return self.tokens.accept(grammar.infix)
1151794
public final <R> Parser<R> next(Parser<R> parser) {
    return Parsers.sequence(this, parser);
  }
432565
public <O extends BaseOption> ArgumentParser add(O option) {
        if (option.getName() != null) {
            if (longNameOptions.containsKey(option.getName())) {
                throw new IllegalArgumentException("Option " + option.getName() + " already exists");
            }
            if (parent != null && parent.longNameOptions.containsKey(option.getName())) {
                throw new IllegalArgumentException("Option " + option.getName() + " already exists in parent");
            }

            longNameOptions.put(option.getName(), option);
        }

        if (option instanceof Flag) {
            String negate = ((Flag) option).getNegateName();
            if (negate != null) {
                if (longNameOptions.containsKey(negate)) {
                    throw new IllegalArgumentException("Flag " + negate + " already exists");
                }
                if (parent != null && parent.longNameOptions.containsKey(negate)) {
                    throw new IllegalArgumentException("Flag " + negate + " already exists in parent");
                }

                longNameOptions.put(negate, option);
            }
        }

        if (option.getShortNames()
                  .length() > 0) {
            for (char s : option.getShortNames()
                                .toCharArray()) {
                if (shortOptions.containsKey(s)) {
                    throw new IllegalArgumentException("Short option -" + s + " already exists");
                }
                if (parent != null && parent.shortOptions.containsKey(s)) {
                    throw new IllegalArgumentException("Short option -" + s + " already exists in parent");
                }

                shortOptions.put(s, option);
            }
        }

        this.options.add(option);
        return this;
    }
413193
public static <A, B, T> Parser<T> sequence(
      final Parser<A> p1, final Parser<B> p2, final BiFunction<? super A, ? super B, ? extends T> map) {
    return new Parser<T>() {
      @Override boolean apply(ParseContext ctxt) {
        boolean r1 = p1.apply(ctxt);
        if (!r1) return false;
        A o1 = p1.getReturn(ctxt);
        boolean r2 = p2.apply(ctxt);
        if (!r2) return false;
        B o2 = p2.getReturn(ctxt);
        ctxt.result = map.apply(o1, o2);
        return true;
      }
      @Override public String toString() {
        return map.toString();
      }
    };
  }
502207
def _precedence_parens(self, node, child, is_left=True):
        """"""
        if self._should_wrap(node, child, is_left):
            return "(%s)" % child.accept(self)

        return child.accept(self)