12.10 The with statement
190846
function parseWithStatement() {
        var object, body;

        if (strict) {
            // TODO(ikarienator): Should we update the test cases instead?
            skipComment();
            throwErrorTolerant({}, Messages.StrictModeWith);
        }

        expectKeyword('with');

        expect('(');

        object = parseExpression();

        expect(')');

        body = parseStatement();

        return delegate.createWithStatement(object, body);
    }
841046
function (statements) {
            for (var i = 0, len = statements.length; i < len; i += 1) {
                var statement = statements[i];
                this.STATEMENTS[statement] = this.ALLSTATEMENTS[statement];
            }
        }
472132
def add_parens(line, maxline, indent, statements=statements, count=count):
    

    if line[0] in statements:
        index = 1
        if not line[0].endswith(' '):
            index = 2
            assert line[1] == ' '
        line.insert(index, '(')
        if line[-1] == ':':
            line.insert(-1, ')')
        else:
            line.append(')')

    # That was the easy stuff.  Now for assignments.
    groups = list(get_assign_groups(line))
    if len(groups) == 1:
        # So sad, too bad
        return line

    counts = list(count(x) for x in groups)
    didwrap = False

    # If the LHS is large, wrap it first
    if sum(counts[:-1]) >= maxline - indent - 4:
        for group in groups[:-1]:
            didwrap = False  # Only want to know about last group
            if len(group) > 1:
                group.insert(0, '(')
                group.insert(-1, ')')
                didwrap = True

    # Might not need to wrap the RHS if wrapped the LHS
    if not didwrap or counts[-1] > maxline - indent - 10:
        groups[-1].insert(0, '(')
        groups[-1].append(')')

    return [item for group in groups for item in group]
259315
function with(array $options, $throwException = false)
    {
        foreach ($options as $key => $val) {
            $key = strtolower($key);
            $this->$key = $val;
        }
    }
631028
func (c *Call) With(opts ...CallOpt) *Call {
	for _, opt := range opts {
		opt(c)
	}
	return c
}
174691
private void XreadWithList(WithList withList) {
        // <with list element> ::= <query name>
        //                         [ <left paren> <with column list> <right paren> ]
        //                         AS <left paren> <query expression> <right paren>
        //                         [ <search or cycle clause> ]
        //
        boolean recursive = withList.isRecursive();
        for (boolean done = false; ! done; done = ! readIfThis(Tokens.COMMA)) {
            HsqlName queryName = readNewSchemaObjectName(SchemaObject.TABLE);
            queryName.setSchemaIfNull(session.getCurrentSchemaHsqlName());
            List<HsqlName> columnNames = parseColumnNames();
            readThis(Tokens.AS);
            readThis(Tokens.OPENBRACKET);
            // Read a query.  If it's recursive it has to be of the form:
            //    Q1 union all Q2.
            // In Q1 we can't use an order by or limit.  It's ok
            // to use group by, aggregates and having, though.  The
            // query name will be visible in Q2 but not in Q1.
            //
            // If this with statement is not recursive then anything goes,
            // but the query name will not be visible in the query.
            QueryExpression baseQueryExpression = null;
            QueryExpression recursionQueryExpression = null;
            // This is not really standard behavior.  This should
            // really be just reading a query expression.  However,
            // This short circuits a great deal of complexity, and
            // will serve for prototype purposes.
            if (recursive) {
                baseQueryExpression = XreadQueryPrimary();
            } else {
                baseQueryExpression = XreadQueryExpressionBodyAndSortAndSlice();
            }
            // We have to resolve this here because we need
            // to fetch the types and perhaps the column aliases.
            // But we can't define the table now, because it is
            // not visible in the base query expression.
            baseQueryExpression.resolve(session);
            //
            // Calculate the schema of the common table.
            //
            HsqlName[] colNames = null;
            if (columnNames != null) {
                colNames = columnNames.toArray(new HsqlName[columnNames.size()]);
            } else {
                String[] queryNames = baseQueryExpression.getColumnNames();
                colNames = new HsqlName[queryNames.length];
                for (int idx = 0; idx < queryNames.length; idx += 1) {
                    String queryColumnName = queryNames[idx];
                    colNames[idx] = database.nameManager.newHsqlName(queryColumnName,
                                                                     false,
                                                                     SchemaObject.COLUMN);
                }
            }
            Type[] colTypes = baseQueryExpression.getColumnTypes();
            String cmp = null;
            if (colNames.length > colTypes.length) {
                cmp = "many";
            }
            else if (colNames.length < colTypes.length) {
                cmp = "few";
            }
            if (cmp != null) {
                throw Error.error("Too " + cmp + " column names in common table expression " + queryName.name);
            }
            // Now, define it.
            Table newTable = session.defineLocalTable(queryName, colNames, colTypes);
            if (recursive) {
                readThis(Tokens.UNION);
                readThis(Tokens.ALL);
                recursionQueryExpression = XreadQueryExpressionBody();
            }
            readThis(Tokens.CLOSEBRACKET);
            WithExpression withExpression = new WithExpression();
            withExpression.setQueryName(queryName);
            withExpression.setBaseQuery(baseQueryExpression);
            withExpression.setRecursiveQuery(recursionQueryExpression);
            withExpression.setTable(newTable);
            withList.add(withExpression);
        }
    }
1285647
def p_iteration_statement_2(self, p):
        """"""
        p[0] = self.asttypes.While(predicate=p[3], statement=p[5])
        p[0].setpos(p)
936565
def parse_with(self, node):
        

        if 'instance' in node.lattrib:
            instance = node.lattrib['instance']
            list = None
            index = None
        elif 'list' in node.lattrib and 'index' in node.lattrib:
            instance = None
            list = node.lattrib['list']
            index = node.lattrib['index']
        else:
            self.raise_error('<With> must specify EITHER instance OR list & index')

        if 'as' in node.lattrib:
            as_ = node.lattrib['as']
        else:
            self.raise_error('<With> must specify a name for the '
                             'target instance')

        self.current_structure.add_with(With(instance, as_, list, index))
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
247736
public With andWith(final String alias, final Expression expression) {
        this.clauses.add(new ImmutablePair<>(new Name(alias), expression));
        return this;
    }
1067262
function checkIfWithElse(node) {
            const parent = node.parent;


            /*
             * Fixing this would require splitting one statement into two, so no error should
             * be reported if this node is in a position where only one statement is allowed.
             */
            if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) {
                return;
            }

            const alternate = node.alternate;

            if (alternate && alwaysReturns(node.consequent)) {
                displayReport(alternate);
            }
        }
837016
public TerminalResult STARTS_WITH(String string) {
		getPredicateExpression().setOperator(Operator.STARTS_WITH);
		getPredicateExpression().setValue_2(string);
		TerminalResult ret = APIAccess.createTerminalResult(this.getPredicateExpression());
		QueryRecorder.recordInvocation(this, "STARTS_WITH", ret, QueryRecorder.literal(string));
		return ret;
	}
1357998
def p_statement_for(p):
    ''
    p[0] = ast.For(p[3], p[5], p[7], p[9], lineno=p.lineno(1))
825170
function isInsideWithStatementBody(node) {
            if (node) {
                while (node.parent) {
                    if (node.parent.kind === 212 /* WithStatement */ && node.parent.statement === node) {
                        return true;
                    }
                    node = node.parent;
                }
            }
            return false;
        }
1253443
private function arrayFilter($value, $field, array $where, array $with)
    {
        if ($field == 'is_hidden' && $with['hidden'] === false && $value == 1) {
            return false;
        }
    
        foreach ($where as $expression) {
            if ($expression['field'] == $field) {
                switch ($expression['op']) {
                    case '==':
                        return ($value === $expression['value']);
                    case '>':
                        return ($value > $expression['value']);
                    case '>=':
                        return ($value >= $expression['value']);
                    case '<':
                        return ($value < $expression['value']);
                    case '<=':
                        return ($value <= $expression['value']);
                    case 'in':
                        return in_array($value, $expression['value']);
                    case '!=':
                        return ($value != $expression['value']);
                    default:
                        return ($value == $expression['value']);
                }
            }
        }
    
        return true;
    }
738161
public function with($with)
    {
        if (! is_array($with)) {
            $with = func_get_args();
        }

        $this->with = $with;

        return $this;
    }
59797
protected function andWith(array $with, $mode)
    {
        return (
            implode(
                $mode === self::MODE_OR ? '|' : ',',
                array_map([$this, 'normalize'], $with)
            )
        );
    }