本文整理汇总了Java中org.codehaus.jparsec.Parsers.or方法的典型用法代码示例。如果您正苦于以下问题:Java Parsers.or方法的具体用法?Java Parsers.or怎么用?Java Parsers.or使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.jparsec.Parsers
的用法示例。
在下文中一共展示了Parsers.or方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: arithmetic
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
static Parser<Expression> arithmetic(Parser<Expression> atom) {
Reference<Expression> reference = Parser.newReference();
Parser<Expression> operand =
Parsers.or(paren(reference.lazy()), functionCall(reference.lazy()), atom);
Parser<Expression> parser = new OperatorTable<Expression>()
.infixl(binary("/", Op.AGG_DIV), 5)
.infixl(binary("<", Op.LESS), 7)
.infixl(binary("<=", Op.LESS_EQ), 7)
.infixl(binary("=", Op.EQ), 7)
.infixl(binary("!=", Op.NOT_EQ), 7)
.infixl(binary(">", Op.GREATER), 7)
.infixl(binary(">=", Op.GREATER_EQ), 7)
.infixl(binary("+", Op.PLUS), 10)
.infixl(binary("-", Op.MINUS), 10)
.infixl(binary("*", Op.MUL), 20)
.infixl(binary("\\", Op.DIV), 20)
.infixl(binary("%", Op.MOD), 20)
.prefix(unary("-", Op.NEG), 30)
.build(operand);
reference.set(parser);
return parser;
}
示例2: allStatements
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
public static Parser<Exp> allStatements() {
return Parsers.or(PackageParser.packageDecl(), PackageParser.importDecl(),
VarParser.assignment00(), TypeParser.typestruct01(),
TypeParser.typeenum01(), TypeParser.type01(), TypeParser.typelist01(),
RuleDeclParser.customRuleDecl(), ViewParser.view03());
// followedBy(TerminalParser.token(";").optional());
}
示例3: valueassigninstruct
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
public static Parser<Exp> valueassigninstruct() {
return Parsers.or(
struct_someNumberValueAssign(),
struct_stringvalueassign(),
struct_booleanvalueassign(),
struct_varname(),
struct_null(),
struct_listvalueassign(),
struct_structvalueassign());
}
示例4: zvalueassign
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
private static Parser<Exp> zvalueassign() {
return Parsers.or(
VarParser.someNumberValueassign(),
VarParser.stringvalueassign(),
VarParser.booleanvalueassign(),
ident(),
VarParser.listvalueassign(),
VarParser.structvalueassign());
}
示例5: statement
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
private Parser<Statement> statement()
{
return Parsers.or(
selectStatement(),
findStatement()
);
}
示例6: filter
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
static Parser<Expression> filter() {
// each filter is one of: 1) simple field equality 2) metric inequality/comparison 3) IN operation 4) function call with any expressions as params
// TODO: should be able to do a metric comparison involving functions e.g. floatscale(yearlysalary,1,0) != 0
return Parsers.or(
comparison(NAME, atomWhere()),
inCondition(),
functionCall(arithmetic(atom())), // function parameters are away from top level so we use non-where version of atom
arithmetic(atomWhere()) // TODO: fix: using this instead of the line below lets through some input that will fail in IQLTranslator
// metricComparison(arithmetic(atomWhere()), SIGNED_NUMBER)
);
}
示例7: parse
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
/** Parses {@code string} to a {@link TypeToken}. */
public TypeToken<?> parse(String string) throws ParserException {
Parser.Reference<Type> ref = Parser.newReference();
Parser<Type> type = Parsers.or(
wildcardType(ref.lazy()), parameterizedType(ref.lazy()), arrayClass(), rawType());
ref.set(type.postfix(TERMS.phrase("[", "]").retn(Types::newArrayType)));
return TypeToken.of(
ref.get().from(TERMS.tokenizer(), Scanners.WHITESPACES.optional()).parse(string));
}
示例8: shapeParser
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
private Parser<MatrixShape> shapeParser() {
Parser.Reference<MatrixShape> reference = Parser.newReference();
Parser<MatrixShape> lazyExpr = reference.lazy();
Parser<MatrixShape> parser = Parsers.or(shapeBinOpParser(lazyExpr),
powerShapeParser(lazyExpr),
shapeUnOpParser(lazyExpr), bangShapeParser(),
scalarShapeParser());
reference.set(parser);
return parser;
}
示例9: expressionParser
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
private Parser<Expression> expressionParser() {
Parser.Reference<Expression> reference = Parser.newReference();
Parser<Expression> lazyExpr = reference.lazy();
Parser<Expression> parser = Parsers.or(applicationParser(lazyExpr),
applicationDebugParser(lazyExpr), ifParser(lazyExpr),
lambdaParser(lazyExpr), constParser(), stringParser(), literalMatrix(),
matrixConstructorParser(), keyParser(), VARIABLE);
reference.set(parser);
return parser;
}
示例10: unitParser
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
private Parser<Unit> unitParser() {
Parser.Reference<Unit> reference = Parser.newReference();
Parser<Unit> lazyExpr = reference.lazy();
Parser<Unit> parser = Parsers.or(unitPower(lazyExpr),
unitMult(lazyExpr), unitDiv(lazyExpr), unitScaled(),
unitNamed());
reference.set(parser);
return parser;
}
示例11: typeParserRec
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
private static Parser<TypeNode> typeParserRec() {
Parser.Reference<TypeNode> reference = Parser.newReference();
Parser<TypeNode> termParser = termParser();
Parser<TypeNode> lazyExpr = reference.lazy();
Parser<TypeNode> parser = Parsers.or(typeSchemeParser(lazyExpr),
functionTypeParser(lazyExpr),
simpleFunctionTypeParser(lazyExpr),
parametricTypeParser(lazyExpr), matrixTypeParser(Parsers.or(
parametricTypeParser(lazyExpr), termParser)),
matrixTermIdentifier());
reference.set(parser);
return parser;
}
示例12: matrixExprTypeParser
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
private static Parser<TypeNode> matrixExprTypeParser(
Parser<TypeNode> typeParser) {
Parser<TypeNode> termParser = typeParser;
return Parsers.or(Parsers.sequence(matrixDimensionParser(termParser),
token("per").next(matrixDimensionParser(termParser)),
new Map2<TypeNode, TypeNode, TypeNode>() {
public TypeNode map(final TypeNode row,
final TypeNode column) {
Location location = row.getLocation().join(
column.getLocation());
return new TypeOperationNode(location, "per", row,
column);
}
}), matrixDimensionParser(termParser));
}
示例13: elseRestParser
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
private static Parser<List<Pair<ExpressionNode, ExpressionNode>>> elseRestParser(
Parser<ExpressionNode> statementParser,
Parser<ExpressionNode> expParser,
Parser<List<Pair<ExpressionNode, ExpressionNode>>> restParser) {
return Parsers.or(
elseRestIfParser(statementParser, expParser, restParser),
elseRestIflessParser(statementParser, expParser, restParser));
}
示例14: expressionParser
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
private static Parser<ExpressionNode> expressionParser() {
Parser.Reference<ExpressionNode> reference = Parser.newReference();
Parser<ExpressionNode> lazyExpr = reference.lazy();
Parser<ExpressionNode> parser = Parsers.or(
arithmeticParser(nonArithmeticParser(lazyExpr)),
nonArithmeticParser(lazyExpr));
reference.set(parser);
return parser;
}
示例15: nonArithmeticParser
import org.codehaus.jparsec.Parsers; //导入方法依赖的package包/类
private static Parser<ExpressionNode> nonArithmeticParser(
Parser<ExpressionNode> expParser) {
Parser<ExpressionNode> parser = Parsers.or(BOOLEAN,
STRINGLIT,
applicationParser(expParser), listParser(expParser),
statementParser(expParser), letParser(expParser),
ifParser(expParser), lambdaParser(expParser), projectionParser(expParser), BANG, KEY,
parenthesisParser(expParser), comprehensionParser(expParser),
foldComprehensionParser(expParser), NUMBER, EXPIDENTIFIER);
return parser;
}