Returns an AST where all operations of lower precedence are finalized.
6685
def _start_operation(self, ast, operation, precedence):
        
        if TRACE_PARSE:
            print('   start_operation:', repr(operation), 'AST:', ast)

        op_prec = precedence[operation]
        while True:
            if ast[1] is None:
                # [None, None, x]
                if TRACE_PARSE: print('     start_op: ast[1] is None:', repr(ast))
                ast[1] = operation
                if TRACE_PARSE: print('     --> start_op: ast[1] is None:', repr(ast))
                return ast

            prec = precedence[ast[1]]
            if prec > op_prec:  # op=&, [ast, |, x, y] -> [[ast, |, x], &, y]
                if TRACE_PARSE: print('     start_op: prec > op_prec:', repr(ast))
                ast = [ast, operation, ast.pop(-1)]
                if TRACE_PARSE: print('     --> start_op: prec > op_prec:', repr(ast))
                return ast

            if prec == op_prec:  # op=&, [ast, &, x] -> [ast, &, x]
                if TRACE_PARSE: print('     start_op: prec == op_prec:', repr(ast))
                return ast

            if not (inspect.isclass(ast[1]) and issubclass(ast[1], Function)):
                # the top ast node should be a function subclass at this stage
                raise ParseError(error_code=PARSE_INVALID_NESTING)

            if ast[0] is None:  # op=|, [None, &, x, y] -> [None, |, x&y]
                if TRACE_PARSE: print('     start_op: ast[0] is None:', repr(ast))
                subexp = ast[1](*ast[2:])
                new_ast = [ast[0], operation, subexp]
                if TRACE_PARSE: print('     --> start_op: ast[0] is None:', repr(new_ast))
                return new_ast

            else:  # op=|, [[ast, &, x], ~, y] -> [ast, &, x, ~y]
                if TRACE_PARSE: print('     start_op: else:', repr(ast))
                ast[0].append(ast[1](*ast[2:]))
                ast = ast[0]
                if TRACE_PARSE: print('     --> start_op: else:', repr(ast))
801473
function postprocess(ast, options) {
  visitNode(ast, node => {
    switch (node.type) {
      case "VariableDeclaration": {
        const lastDeclaration = getLast(node.declarations);
        if (lastDeclaration && lastDeclaration.init) {
          overrideLocEnd(node, lastDeclaration);
        }
        break;
      }
    }
  });

  return ast;

  /**
   * - `toOverrideNode` must be the last thing in `toBeOverriddenNode`
   * - do nothing if there's a semicolon on `toOverrideNode.end` (no need to fix)
   */
  function overrideLocEnd(toBeOverriddenNode, toOverrideNode) {
    if (options.originalText[locEnd(toOverrideNode)] === ";") {
      return;
    }
    if (options.parser === "flow") {
      toBeOverriddenNode.range = [
        toBeOverriddenNode.range[0],
        toOverrideNode.range[1]
      ];
    } else {
      toBeOverriddenNode.end = toOverrideNode.end;
    }
    toBeOverriddenNode.loc = Object.assign({}, toBeOverriddenNode.loc, {
      end: toBeOverriddenNode.loc.end
    });
  }

  function locEnd(node) {
    return options.parser === "flow" ? node.range[1] : node.end;
  }
}
69345
private LinkedHashSet<Formula> condenseOperandsAnd(final Collection<? extends Formula> operands) {
    final LinkedHashSet<Formula> ops = new LinkedHashSet<>();
    this.cnfCheck = true;
    for (final Formula form : operands)
      if (form.type() == AND) {
        for (final Formula f : ((NAryOperator) form).operands) {
          this.addFormulaAnd(ops, f);
          if (!this.formulaAdditionResult[0])
            return null;
          if (!this.formulaAdditionResult[1])
            this.cnfCheck = false;
        }
      } else {
        this.addFormulaAnd(ops, form);
        if (!this.formulaAdditionResult[0])
          return null;
        if (!this.formulaAdditionResult[1])
          this.cnfCheck = false;
      }
    return ops;
  }
896134
def ast2expr(ast):
    """"""
    if ast[0] == 'const':
        return _CONSTS[ast[1]]
    elif ast[0] == 'var':
        return exprvar(ast[1], ast[2])
    else:
        xs = [ast2expr(x) for x in ast[1:]]
        return ASTOPS[ast[0]](*xs, simplify=False)
1003784
def _all_equal(iterable):
    """"""
    iterator = iter(iterable)
    first = next(iterator)
    return all(first == rest for rest in iterator)
920155
def complete(self, e): # (TAB)
        """
        completions = self._get_completions()
        if completions:
            cprefix = commonprefix(completions)
            if len(cprefix) > 0:
                rep = [ c for c in cprefix ]
                point=self.l_buffer.point
                self.l_buffer[self.begidx:self.endidx] = rep
                self.l_buffer.point = point + len(rep) - (self.endidx - self.begidx)
            if len(completions) > 1:
                if self.show_all_if_ambiguous == u'on':
                    self._display_completions(completions)
                else:
                    self._bell()
        else:
            self._bell()
        self.finalize()
769944
def complete_dos(self):
        
        final_struct = self.final_structure
        pdoss = {final_struct[i]: pdos for i, pdos in enumerate(self.pdos)}
        return CompleteDos(self.final_structure, self.tdos, pdoss)
1229543
public List<IRStatus<PIR>> finalIrEvent(List<IRStatus<PIR>> ast)
	{
		if (irObserver != null)
		{
			return irObserver.finalIRConstructed(ast, getInfo());
		}

		return ast;
	}
192153
def _construct_result(left, result, index, name, dtype=None):
    
    out = left._constructor(result, index=index, dtype=dtype)
    out = out.__finalize__(left)
    out.name = name
    return out
1115866
function hasPrecedence(op1, op2) {
    (0, _invariant2['default'])(PRECEDENCE[op1] && PRECEDENCE[op2], 'Missing precedence number for\n            ' + 
    JSON.stringify(op1) + ' or ' + JSON.stringify(op2) + '.\n            See ' + 
    JSON.stringify(PRECEDENCE));

    return PRECEDENCE[op1] < PRECEDENCE[op2];}
233161
def completions(self):
        
        debug.speed('completions start')
        comps = self._evaluator.complete()
        debug.speed('completions end')

        return sorted(comps, key=lambda x: (x.name.lower()))
883297
def __end_of_list(self, ast_token):
        """"""
        self.list_level -= 1
        if self.list_level == 0:
            if self.list_entry is not None:
                self.final_ast_tokens.append(self.list_entry)
                self.list_entry = None
            self.final_ast_tokens.append(ast_token)
86932
def completion_logic(input, options = {})
      o = {}
      options = options.dup

      o[k = :enabled_as] = options.delete(k)

      raise ArgumentError, "Unknown option(s): #{options.inspect}" if not options.empty?
      raise ArgumentError, "options[:enabled_as] must be given" if not o[:enabled_as]

      # Check if this input is related to us.
      if not mat = input.match(/\A#{o[:enabled_as]}\.((?:[^.].*)|)\z/)
        return nil
      end

      lookup = mat[1]

      # Parse lookup string into node name and prefix.
      global_name, prefix = if mat = lookup.match(/\A(?:([^.]*)|(.+)\.(.*?))\z/)
        if mat[1]
          # "something".
          ["", mat[1]]
        else
          # "something.other", "something.other.other.".
          [mat[2], mat[3]]
        end
      else
        # Handle no match just in case.
        ["", ""]
      end

      base = if global_name == ""
        # Base is root.
        nil
      else
        # Find a named base node. If not found, return no candidates right away.
        find_node(global_name) or return []
      end
      
      # Select sub-nodes.
      candidates = children_of(base).select do |node|
        # Select those matching `prefix`.
        node.name.to_s.index(prefix) == 0
      end.map do |node|
        # Provide 1+ candidates per item.
        case node
        when Node::Group
          # A neat trick to prevent IRB from appending a " " after group name.
          [node.name, "#{node.name}."]
        else
          [node.name]
        end.map(&:to_s)
      end.flatten(1).map do |s|
        # Convert to final names.
        [
          "#{o[:enabled_as]}.",
          ("#{global_name}." if global_name != ""),
          s,
        ].compact.join
      end

      candidates
    end
716037
public static int precedenceOf(Object o) {
        if (o instanceof PrecedencedSelfDescribing) {
            return ((PrecedencedSelfDescribing) o).getDescriptionPrecedence();
        } else {
            return PrecedencedSelfDescribing.P_ATOMIC;
        }
    }
744857
def total_ordering(cls):  # pragma: no cover
    """"""
    convert = {
        '__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
                   ('__le__', lambda self, other: self < other or self == other),
                   ('__ge__', lambda self, other: not self < other)],
        '__le__': [('__ge__', lambda self, other: not self <= other or self == other),
                   ('__lt__', lambda self, other: self <= other and not self == other),
                   ('__gt__', lambda self, other: not self <= other)],
        '__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),
                   ('__ge__', lambda self, other: self > other or self == other),
                   ('__le__', lambda self, other: not self > other)],
        '__ge__': [('__le__', lambda self, other: (not self >= other) or self == other),
                   ('__gt__', lambda self, other: self >= other and not self == other),
                   ('__lt__', lambda self, other: not self >= other)]
    }
    roots = set(dir(cls)) & set(convert)
    if not roots:
        raise ValueError('must define at least one ordering operation: < > <= >=')
    root = max(roots)       # prefer __lt__ to __le__ to __gt__ to __ge__
    for opname, opfunc in convert[root]:
        if opname not in roots:
            opfunc.__name__ = opname
            opfunc.__doc__ = getattr(int, opname).__doc__
            setattr(cls, opname, opfunc)
    return cls
898745
def un_priority(op,val):
  ""
  if isinstance(val,BinX) and val.op < op: return bin_priority(val.op,UnX(op,val.left),val.right)
  else: return UnX(op,val)
420983
def complete_options(node)

      return [:keyword] + [:prefix_op] if tokens.empty?

      #prefix operator
      return [:keyword] if last_token_is(PREFIX_OPERATORS)

      # left hand
      if is_left_hand(node)
        if (tokens.size == 1 || last_token_is(PREFIX_OPERATORS + LOGICAL_INFIX_OPERATORS) ||
            last_token_is(PREFIX_OPERATORS + LOGICAL_INFIX_OPERATORS, 2))
          options = [:keyword]
          options += [:prefix_op]  unless last_token_is(PREFIX_OPERATORS)
        else
          options = [:logical_op]
        end
        return options
      end

      if is_right_hand
        # right hand
        return [:value]
      else
        # comparison operator completer
        return [:infix_op]
      end
    end