atom ::=
             ('(' [yield_expr|testlist_gexp] ')'
                 | '[' [listmaker] ']'
                 | '{' [dictmaker] '}'
                 | '`' testlist1 '`'
                 | NAME | NUMBER | STRING+)
974655
def n_atom(self, node):
        
        length = len(node)
        if length == 1:
            self.preorder(node[0])
        elif length == 3:
            self.preorder(node[0])
            self.preorder(node[1])
            self.preorder(node[2])
        else:
            assert False, "Expecting atom to have length 1 or 3"
        self.prune()
587461
def flat_map(include_self = false, &block)
      result = []

      each_expression(include_self) do |exp, index|
        if block_given?
          result << yield(exp, index)
        else
          result << [exp, index]
        end
      end

      result
    end
1355459
def output(self,delimiter = '\t', addnormalised=False):
        """"""
        for type, count in self:
            if isinstance(type,tuple) or isinstance(type,list):
                if addnormalised:
                    yield " ".join((u(x) for x in type)) + delimiter + str(count) + delimiter + str(count/self.total)
                else:
                    yield " ".join((u(x) for x in type)) + delimiter + str(count)
            elif isstring(type):
                if addnormalised:
                    yield type + delimiter + str(count) + delimiter + str(count/self.total)
                else:
                    yield type + delimiter + str(count)
            else:
                if addnormalised:
                    yield str(type) + delimiter + str(count) + delimiter + str(count/self.total)
                else:
                    yield str(type) + delimiter + str(count)
783707
@SuppressWarnings("unchecked")
    public static <T> Expression<T> list(Class<T> clazz, List<? extends Expression<?>> exprs) {
        Expression<T> rv = (Expression<T>) exprs.get(0);
        if (exprs.size() == 1) {
            rv = operation(clazz, Ops.SINGLETON, rv, exprs.get(0));
        } else {
            for (int i = 1; i < exprs.size(); i++) {
                rv = operation(clazz, Ops.LIST, rv, exprs.get(i));
            }
        }

        return rv;
    }
327068
def _parse_formula(s):
    """"""
    scanner = re.compile(r'''
        (\s+) |         # whitespace
        (\(|\)) |       # group
        ([A-Z][a-z]*) | # element
        (\d+) |         # number
        ([a-z]) |       # variable
        (\Z) |          # end
        (.)             # error
    ''', re.DOTALL | re.VERBOSE)

    def transform_subformula(form):
        """Extract radical if subformula is a singleton with a radical."""
        if isinstance(form, dict) and len(form) == 1:
            # A radical in a singleton subformula is interpreted as a
            # numbered radical.
            element, value = next(iteritems(form))
            if isinstance(element, Radical):
                return Radical('{}{}'.format(element.symbol, value))
        return form

    stack = []
    formula = {}
    expect_count = False

    def close(formula, count=1):
        if len(stack) == 0:
            raise ParseError('Unbalanced parenthesis group in formula')
        subformula = transform_subformula(formula)
        if isinstance(subformula, dict):
            subformula = Formula(subformula)

        formula = stack.pop()
        if subformula not in formula:
            formula[subformula] = 0
        formula[subformula] += count
        return formula

    for match in re.finditer(scanner, s):
        (whitespace, group, element, number, variable, end,
            error) = match.groups()

        if error is not None:
            raise ParseError(
                'Invalid token in formula string: {!r}'.format(match.group(0)),
                span=(match.start(), match.end()))
        elif whitespace is not None:
            continue
        elif group is not None and group == '(':
            if expect_count:
                formula = close(formula)
            stack.append(formula)
            formula = {}
            expect_count = False
        elif group is not None and group == ')':
            if expect_count:
                formula = close(formula)
            expect_count = True
        elif element is not None:
            if expect_count:
                formula = close(formula)
            stack.append(formula)
            if element in 'RX':
                formula = Radical(element)
            else:
                formula = Atom(element)
            expect_count = True
        elif number is not None and expect_count:
            formula = close(formula, int(number))
            expect_count = False
        elif variable is not None and expect_count:
            formula = close(formula, Expression(variable))
            expect_count = False
        elif end is not None:
            if expect_count:
                formula = close(formula)
        else:
            raise ParseError(
                'Invalid token in formula string: {!r}'.format(match.group(0)),
                span=(match.start(), match.end()))

    if len(stack) > 0:
        raise ParseError('Unbalanced parenthesis group in formula')

    return Formula(formula)
1216379
def p_exprs(p):
    
    if len(p) == 2:
        p[0] = node.expr_list([p[1]])
    elif len(p) == 4:
        p[0] = p[1]
        p[0].append(p[3])
    else:
        assert (0)
    assert isinstance(p[0], node.expr_list)
1271985
def parse_seq(tokens, options):
    """"""
    result = []
    while tokens.current() not in [None, ']', ')', '|']:
        atom = parse_atom(tokens, options)
        if tokens.current() == '...':
            atom = [OneOrMore(*atom)]
            tokens.move()
        result += atom
    return result
1351235
function evalExpr(expr, data, owner) {
    if (expr.value != null) {
        return expr.value;
    }

    var value;

    switch (expr.type) {
        case ExprType.UNARY:
            value = evalExpr(expr.expr, data, owner);
            switch (expr.operator) {
                case 33:
                    value = !value;
                    break;

                case 45:
                    value = 0 - value;
                    break;
            }
            return value;

        case ExprType.BINARY:
            value = evalExpr(expr.segs[0], data, owner);
            var rightValue = evalExpr(expr.segs[1], data, owner);

            /* eslint-disable eqeqeq */
            switch (expr.operator) {
                case 37:
                    value = value % rightValue;
                    break;

                case 43:
                    value = value + rightValue;
                    break;

                case 45:
                    value = value - rightValue;
                    break;

                case 42:
                    value = value * rightValue;
                    break;

                case 47:
                    value = value / rightValue;
                    break;

                case 60:
                    value = value < rightValue;
                    break;

                case 62:
                    value = value > rightValue;
                    break;

                case 76:
                    value = value && rightValue;
                    break;

                case 94:
                    value = value != rightValue;
                    break;

                case 121:
                    value = value <= rightValue;
                    break;

                case 122:
                    value = value == rightValue;
                    break;

                case 123:
                    value = value >= rightValue;
                    break;

                case 155:
                    value = value !== rightValue;
                    break;

                case 183:
                    value = value === rightValue;
                    break;

                case 248:
                    value = value || rightValue;
                    break;

            }
            /* eslint-enable eqeqeq */
            return value;

        case ExprType.TERTIARY:
            return evalExpr(
                expr.segs[evalExpr(expr.segs[0], data, owner) ? 1 : 2],
                data,
                owner
            );


        case ExprType.ARRAY:
            value = [];
            for (var i = 0, l = expr.items.length; i < l; i++) {
                var item = expr.items[i];
                var itemValue = evalExpr(item.expr, data, owner);

                if (item.spread) {
                    itemValue && (value = value.concat(itemValue));
                }
                else {
                    value.push(itemValue);
                }
            }
            return value;

        case ExprType.OBJECT:
            value = {};
            for (var i = 0, l = expr.items.length; i < l; i++) {
                var item = expr.items[i];
                var itemValue = evalExpr(item.expr, data, owner);

                if (item.spread) {
                    itemValue && extend(value, itemValue);
                }
                else {
                    value[evalExpr(item.name, data, owner)] = itemValue;
                }
            }
            return value;

        case ExprType.ACCESSOR:
            return data.get(expr);


        case ExprType.INTERP:
            value = evalExpr(expr.expr, data, owner);

            if (owner) {
                for (var i = 0, l = expr.filters.length; i < l; i++) {
                    var filter = expr.filters[i];
                    var filterName = filter.name.paths[0].value;

                    if (owner.filters[filterName]) {
                        value = owner.filters[filterName].apply(
                            owner,
                            [value].concat(evalArgs(filter.args, data, owner))
                        );
                    }
                    else if (DEFAULT_FILTERS[filterName]) {
                        value = DEFAULT_FILTERS[filterName](value);
                    }
                }
            }

            if (value == null) {
                value = '';
            }

            return value;

        case ExprType.CALL:
            if (owner && expr.name.type === ExprType.ACCESSOR) {
                var method = owner;
                var pathsLen = expr.name.paths.length;

                for (var i = 0; method && i < pathsLen; i++) {
                    method = method[evalExpr(expr.name.paths[i], data, owner)];
                }

                if (method) {
                    value = method.apply(owner, evalArgs(expr.args, data, owner));
                }
            }

            break;

        /* eslint-disable no-redeclare */
        case ExprType.TEXT:
            var buf = '';
            for (var i = 0, l = expr.segs.length; i < l; i++) {
                var seg = expr.segs[i];
                buf += seg.value || evalExpr(seg, data, owner);
            }
            return buf;
    }

    return value;
}
130214
def names(expr: AST) -> Set[str]:
    """"""
    nodes = [node for node in ast.walk(expr) if isinstance(node, ast.Name)]
    loaded = {node.id for node in nodes if isinstance(node.ctx, ast.Load)}
    stored = {node.id for node in nodes if isinstance(node.ctx, ast.Store)}
    return loaded - stored
952286
def visit_Expr(self, node: ast.Expr) -> Any:
        """"""
        result = self.visit(node=node.value)

        self.recomputed_values[node] = result
        return result
799148
def p_expr_stmt(p):
    
    assert isinstance(p[1], node.expr_list)
    p[0] = node.expr_stmt(expr=p[1])
795148
def re_parser(self, scode, *args):
        

        def gen_match(matches, num):
            for match in matches:
                yield match.group(num)

        scode = self.ensure_str(scode)
        assert self._re.match(
            '^@|^\$\d+', args[1]), ValueError('args1 should match ^@|^\$\d+')
        arg1, arg2 = args[1][0], args[1][1:]
        com = self._re.compile(args[0])
        if arg1 == '@':
            result = com.sub(arg2, scode)
            return self.ensure_list(result)
        else:
            result = com.finditer(scode)
            return gen_match(result, int(arg2))
327865
def define(cls, expr):
        

        try:
            lang = cls.lang
            items = items_(expr)
            for item in items:
                op, term = item
                full_op = operators.get(op)
                if full_op:
                    class_ = lang.ops[full_op.id]
                    clauses = {k: jx_expression(v) for k, v in expr.items() if k != op}
                    break
            else:
                if not items:
                    return NULL
                raise Log.error("{{operator|quote}} is not a known operator", operator=expr)

            if term == None:
                return class_([], **clauses)
            elif is_list(term):
                terms = [jx_expression(t) for t in term]
                return class_(terms, **clauses)
            elif is_data(term):
                items = items_(term)
                if class_.has_simple_form:
                    if len(items) == 1:
                        k, v = items[0]
                        return class_([Variable(k), Literal(v)], **clauses)
                    else:
                        return class_({k:  Literal(v) for k, v in items}, **clauses)
                else:
                    return class_(_jx_expression(term, lang), **clauses)
            else:
                if op in ["literal", "date", "offset"]:
                    return class_(term, **clauses)
                else:
                    return class_(_jx_expression(term, lang), **clauses)
        except Exception as e:
            Log.error("programmer error expr = {{value|quote}}", value=expr, cause=e)
238313
def t_ATOM(self, t):
        '
        t.type = PLLexer.reserved.get(t.value, 'ATOM')  # Check for reserved words
        return t
1255982
def _handle_expr_list(self, node, scope, ctxt, stream):
        
        self._dlog("handling expression list")
        exprs = [
            self._handle_node(expr, scope, ctxt, stream) for expr in node.exprs
        ]
        return exprs
1147029
def each_with_something( test, max=0, name=nil )
      num = 0
      child=nil
      @elements.each( name ){ |child|
        yield child if test.call(child) and num += 1
        return if max>0 and num == max
      }
    end
1314001
def __expr_str(cls, expr, level):
        ''''''
        ident = ' ' * level * 4

        if isinstance(expr, tuple):
            return '{}{}'.format(ident, str(expr))

        if expr.etype[0] in ['pvar', 'constant']:
            return '{}Expression(etype={}, args={})'.format(ident, expr.etype, expr.args)

        if not isinstance(expr, Expression):
            return '{}{}'.format(ident, str(expr))

        args = list(cls.__expr_str(arg, level + 1) for arg in expr.args)
        args = '\n'.join(args)
        return '{}Expression(etype={}, args=\n{})'.format(ident, expr.etype, args)