Returns a clause for a vector of literals.
@param literals the literals
@return the clause
558321
private Formula vec2clause(final LNGVector<Literal> literals) {
    final List<Literal> lits = new ArrayList<>(literals.size());
    for (final Literal l : literals)
      lits.add(l);
    return this.f.clause(lits);
  }
35435
private boolean matchClause(Clause clause, char[] chars, int[] cursor) {
    if (clause.minlen > cursor[1] - cursor[0])
      return false;
    for (int i = 0; i < clause.items.length; i++) {
      Object item = clause.items[i];
      if (item == matchOne)
        cursor[0]++;
      else if (!matchForward(chars, (char[]) item, cursor))
        return false;
      // else this phase succeeded so continue
    }
    return true;
  }
1292601
def build_where_clause(mappings, operator='AND'):
        
        where_clause_mappings = {}
        where_clause_mappings.update(mappings)

        where_clause = 'WHERE ' + ' {} '.format(operator).join(
            '{k} = {v}'.format(k=k, v='"{}"'.format(v) if isinstance(v, basestring) else v)
            for k, v in where_clause_mappings.iteritems()
        )
        return where_clause
1041782
public java.util.Map<String, String> getExprs() {
        if (exprs == null) {
            exprs = new com.amazonaws.internal.SdkInternalMap<String, String>();
        }
        return exprs;
    }
773909
function (clause) {
            var cond = argsToArray(arguments).slice(1), cb;
            if (cond.length && isFunction(cond[cond.length - 1])) {
                cb = cond.pop();
            }
            cond = cond.length === 1 ? cond[0] : cond;
            if ((cond == null || cond === undefined || cond === "") || (Array.isArray(cond) && cond.length === 0 && !cb) || (isObject(cond) && isEmpty(cond) && !cb)) {
                return this.mergeOptions();
            } else {
                cond = this._filterExpr(cond, cb);
                var cl = this.__opts[clause];
                cl && (cond = new BooleanExpression("AND", cl, cond));
                var opts = {};
                opts[clause] = cond;
                return this.mergeOptions(opts);
            }
        }
193178
public MtasSpanQuery getQuery() throws ParseException {
    simplify();
    if (isBasic()) {
      MtasSpanQuery query;
      if (basicSentence == null) {
        throw new ParseException("no condition");
      } else if (basicSentence.isOptional()) {
        List<MtasSpanSequenceItem> clauses = new ArrayList<MtasSpanSequenceItem>();
        clauses.add(new MtasSpanSequenceItem(basicSentence.getQuery(),
            basicSentence.isOptional()));
        query = new MtasSpanSequenceQuery(clauses, ignore, maximumIgnoreLength);
        if (maximumOccurence > 1) {
          query = new MtasSpanRecurrenceQuery(query, minimumOccurence,
              maximumOccurence, ignore, maximumIgnoreLength);
        }
      } else {
        query = basicSentence.getQuery();
        if (maximumOccurence > 1) {
          query = new MtasSpanRecurrenceQuery(query, minimumOccurence,
              maximumOccurence, ignore, maximumIgnoreLength);
        }
      }
      return query;
    } else if (sequenceList.isEmpty()) {
      throw new ParseException("no condition");
    } else if (isSingle()) {
      return createQuery(sequenceList.get(0));
    } else {
      List<MtasSpanQuery> clauses = new ArrayList<MtasSpanQuery>();
      for (List<MtasCQLParserSentenceCondition> sentenceSequence : sequenceList) {
        clauses.add(createQuery(sentenceSequence));
      }
      return new MtasSpanOrQuery(
          clauses.toArray(new MtasSpanQuery[clauses.size()]));
    }
  }
419294
protected AstNode literal() throws ScanException, ParseException {
		AstNode v = null;
		switch (token.getSymbol()) {
			case TRUE:
				v = new AstBoolean(true);
				consumeToken();
				break;
			case FALSE:
				v = new AstBoolean(false);
				consumeToken();
				break;
			case STRING:
				v = new AstString(token.getImage());
				consumeToken();
				break;
			case INTEGER:
				v = new AstNumber(parseInteger(token.getImage()));
				consumeToken();
				break;
			case FLOAT:
				v = new AstNumber(parseFloat(token.getImage()));
				consumeToken();
				break;			
			case NULL:
				v = new AstNull();
				consumeToken();
				break;
			case EXTENSION:
				if (getExtensionHandler(token).getExtensionPoint() == ExtensionPoint.LITERAL) {
					v = getExtensionHandler(consumeToken()).createAstNode();
					break;
				}
		}
		return v;
	}
919528
public static CharPredicate or(final CharPredicate... predicates) {
    if (predicates.length == 0)
      return NEVER;
    else if (predicates.length == 1) return predicates[0];
    return new CharPredicate() {
      @Override public boolean isChar(char c) {
        for(int i = 0;i < predicates.length;i++) {
          if (predicates[i].isChar(c)) return true;
        }
        return false;
      }
      @Override public String toString() {
        return Strings.join(" or ", predicates);
      }
    };
  }
60464
private Predicate toOrcPredicate(Expression pred) {
		if (pred instanceof Or) {
			Predicate c1 = toOrcPredicate(((Or) pred).left());
			Predicate c2 = toOrcPredicate(((Or) pred).right());
			if (c1 == null || c2 == null) {
				return null;
			} else {
				return new OrcRowInputFormat.Or(c1, c2);
			}
		} else if (pred instanceof Not) {
			Predicate c = toOrcPredicate(((Not) pred).child());
			if (c == null) {
				return null;
			} else {
				return new OrcRowInputFormat.Not(c);
			}
		} else if (pred instanceof BinaryComparison) {

			BinaryComparison binComp = (BinaryComparison) pred;

			if (!isValid(binComp)) {
				// not a valid predicate
				LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
				return null;
			}
			PredicateLeaf.Type litType = getLiteralType(binComp);
			if (litType == null) {
				// unsupported literal type
				LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
				return null;
			}

			boolean literalOnRight = literalOnRight(binComp);
			String colName = getColumnName(binComp);

			// fetch literal and ensure it is serializable
			Object literalObj = getLiteral(binComp);
			Serializable literal;
			// validate that literal is serializable
			if (literalObj instanceof Serializable) {
				literal = (Serializable) literalObj;
			} else {
				LOG.warn("Encountered a non-serializable literal of type {}. " +
						"Cannot push predicate [{}] into OrcTableSource. " +
						"This is a bug and should be reported.",
						literalObj.getClass().getCanonicalName(), pred);
				return null;
			}

			if (pred instanceof EqualTo) {
				return new OrcRowInputFormat.Equals(colName, litType, literal);
			} else if (pred instanceof NotEqualTo) {
				return new OrcRowInputFormat.Not(
					new OrcRowInputFormat.Equals(colName, litType, literal));
			} else if (pred instanceof GreaterThan) {
				if (literalOnRight) {
					return new OrcRowInputFormat.Not(
						new OrcRowInputFormat.LessThanEquals(colName, litType, literal));
				} else {
					return new OrcRowInputFormat.LessThan(colName, litType, literal);
				}
			} else if (pred instanceof GreaterThanOrEqual) {
				if (literalOnRight) {
					return new OrcRowInputFormat.Not(
						new OrcRowInputFormat.LessThan(colName, litType, literal));
				} else {
					return new OrcRowInputFormat.LessThanEquals(colName, litType, literal);
				}
			} else if (pred instanceof LessThan) {
				if (literalOnRight) {
					return new OrcRowInputFormat.LessThan(colName, litType, literal);
				} else {
					return new OrcRowInputFormat.Not(
						new OrcRowInputFormat.LessThanEquals(colName, litType, literal));
				}
			} else if (pred instanceof LessThanOrEqual) {
				if (literalOnRight) {
					return new OrcRowInputFormat.LessThanEquals(colName, litType, literal);
				} else {
					return new OrcRowInputFormat.Not(
						new OrcRowInputFormat.LessThan(colName, litType, literal));
				}
			} else {
				// unsupported predicate
				LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
				return null;
			}
		} else if (pred instanceof UnaryExpression) {

			UnaryExpression unary = (UnaryExpression) pred;
			if (!isValid(unary)) {
				// not a valid predicate
				LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
				return null;
			}
			PredicateLeaf.Type colType = toOrcType(((UnaryExpression) pred).child().resultType());
			if (colType == null) {
				// unsupported type
				LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
				return null;
			}

			String colName = getColumnName(unary);

			if (pred instanceof IsNull) {
				return new OrcRowInputFormat.IsNull(colName, colType);
			} else if (pred instanceof IsNotNull) {
				return new OrcRowInputFormat.Not(
					new OrcRowInputFormat.IsNull(colName, colType));
			} else {
				// unsupported predicate
				LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
				return null;
			}
		} else {
			// unsupported predicate
			LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
			return null;
		}
	}
26978
public static BooleanExpression allOf(BooleanExpression... exprs) {
        BooleanExpression rv = null;
        for (BooleanExpression b : exprs) {
            rv = rv == null ? b : rv.and(b);
        }
        return rv;
    }
447634
public List<Statement> sourceElements() {
        List<Statement> statements = new ArrayList<>();
        while (la() != EOF && la() != RIGHT_BRACE) {
            Statement element = sourceElement();
            if (currentContext().isInProlog()) {
                if (element instanceof ExpressionStatement) {
                    Expression expr = ((ExpressionStatement) element).getExpr();
                    if (expr instanceof StringLiteralExpression) {
                        if (((StringLiteralExpression) expr).getLiteral().equals("use strict")) {
                            if (!((StringLiteralExpression) expr).isContinuedLine() && !((StringLiteralExpression) expr).isEscaped()) {
                                currentContext().setStrict(true);
                            }
                        }
                    } else {
                        currentContext().setInProlog(false);
                    }
                } else {
                    currentContext().setInProlog(false);
                }
            }
            statements.add(element);
        }
        return statements;
    }
336100
public void addClause(final Literal... literals) {
    if (this.miniSat == null && this.cleaneLing == null)
      this.result.add(this.f.clause(literals));
    else if (this.miniSat != null) {
      final LNGIntVector clauseVec = new LNGIntVector(literals.length);
      for (final Literal lit : literals) {
        int index = this.miniSat.underlyingSolver().idxForName(lit.name());
        if (index == -1) {
          index = this.miniSat.underlyingSolver().newVar(!this.miniSat.initialPhase(), true);
          this.miniSat.underlyingSolver().addName(lit.name(), index);
        }
        final int litNum;
        if (lit instanceof EncodingAuxiliaryVariable)
          litNum = !((EncodingAuxiliaryVariable) lit).negated ? index * 2 : (index * 2) ^ 1;
        else
          litNum = lit.phase() ? index * 2 : (index * 2) ^ 1;
        clauseVec.push(litNum);
      }
      this.miniSat.underlyingSolver().addClause(clauseVec, null);
      this.miniSat.setSolverToUndef();
    } else {
      for (final Literal lit : literals) {
        final int index = this.cleaneLing.getOrCreateVarIndex(lit.variable());
        if (lit instanceof EncodingAuxiliaryVariable)
          this.cleaneLing.underlyingSolver().addlit(!((EncodingAuxiliaryVariable) lit).negated ? index : -index);
        else
          this.cleaneLing.underlyingSolver().addlit(lit.phase() ? index : -index);
      }
      this.cleaneLing.underlyingSolver().addlit(CleaneLing.CLAUSE_TERMINATOR);
      this.cleaneLing.setSolverToUndef();
    }
  }
712513
function literalFromParts(parts) {
  let s = '';
  for (let i=0; i<parts.length; i++) {
    let literal = parts[i].literal;
    s += literal || '';
  }
  return s;
}
1134921
public static ExprDouble toExprDouble(Expression expr) {
	if (expr instanceof ExprDouble) return (ExprDouble) expr;
	if (expr instanceof Literal) {
	    Double dbl = ((Literal) expr).getDouble(null);
	    if (dbl != null) return expr.getFactory().createLitDouble(dbl.doubleValue(), expr.getStart(), expr.getEnd());
	}
	return new CastDouble(expr);
    }
467587
@NonNull
  public static <T> Literal literal(@Nullable T value, @Nullable TypeCodec<T> codec) {
    return new DefaultLiteral<>(value, codec);
  }
199229
public static CharPredicate and(final CharPredicate... predicates) {
    if (predicates.length == 0)
      return ALWAYS;
    else if (predicates.length == 1) return predicates[0];
    return new CharPredicate() {
      @Override public boolean isChar(char c) {
        for(int i = 0;i < predicates.length;i++) {
          if (!predicates[i].isChar(c)) return false;
        }
        return true;
      }
      @Override public String toString() {
        return Strings.join(" and ", predicates);
      }
    };
  }
1110711
private List<VarDef> getVarsRemaining( List<VarDef> vars, TestCaseDef testCase)
    {
    return getVarsRemaining( vars.iterator(), testCase);
    }