本文整理汇总了Java中org.codehaus.jparsec.Parsers类的典型用法代码示例。如果您正苦于以下问题:Java Parsers类的具体用法?Java Parsers怎么用?Java Parsers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Parsers类属于org.codehaus.jparsec包,在下文中一共展示了Parsers类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: packageDecl
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
public static Parser<PackageExp> packageDecl() {
return Parsers.sequence(term("package"), VarParser.ident().many().sepBy(term(".")).
map(new org.codehaus.jparsec.functors.Map<List<List<IdentExp>>, PackageExp>() {
@Override
public PackageExp map(List<List<IdentExp>> arg0) {
StringBuilder sb = new StringBuilder();
boolean flag = false;
if (! arg0.isEmpty()) {
for(List<IdentExp> sublist : arg0) {
if (! sublist.isEmpty()) {
if (flag) {
sb.append('.');
}
sb.append(sublist.get(0).val);
flag = true;
}
}
}
return new PackageExp(sb.toString());
}
}));
}
开发者ID:ianrae,项目名称:dnal-lang,代码行数:23,代码来源:PackageParser.java
示例2: importDecl
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
public static Parser<ImportExp> importDecl() {
return Parsers.sequence(term("import"), VarParser.ident().many().sepBy(term(".")).
map(new org.codehaus.jparsec.functors.Map<List<List<IdentExp>>, ImportExp>() {
@Override
public ImportExp map(List<List<IdentExp>> arg0) {
StringBuilder sb = new StringBuilder();
boolean flag = false;
if (! arg0.isEmpty()) {
for(List<IdentExp> sublist : arg0) {
if (! sublist.isEmpty()) {
if (flag) {
sb.append('.');
}
sb.append(sublist.get(0).val);
flag = true;
}
}
}
return new ImportExp(sb.toString());
}
}));
}
开发者ID:ianrae,项目名称:dnal-lang,代码行数:23,代码来源:PackageParser.java
示例3: listvalueassign
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
public static Parser<ListAssignExp> listvalueassign() {
return Parsers.between(term("["), listmemberRef.lazy().many().sepBy(term(",")), term("]")).
map(new org.codehaus.jparsec.functors.Map<List<List<Exp>>, ListAssignExp>() {
@Override
public ListAssignExp map(List<List<Exp>> arg0) {
List<Exp> list = new ArrayList<>();
if (! arg0.isEmpty()) {
for(List<Exp> sublist : arg0) {
if (! sublist.isEmpty()) {
list.add(sublist.get(0));
}
}
}
return new ListAssignExp(list);
}
});
}
开发者ID:ianrae,项目名称:dnal-lang,代码行数:18,代码来源:VarParser.java
示例4: structvalueassign
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
public static Parser<StructAssignExp> structvalueassign() {
return Parsers.between(term("{"),
structmemberRef.lazy().many().sepBy(term(",")), term("}")).
map(new org.codehaus.jparsec.functors.Map<List<List<Exp>>, StructAssignExp>() {
@Override
public StructAssignExp map(List<List<Exp>> arg0) {
List<Exp> list = new ArrayList<>();
for(List<Exp> sublist : arg0) {
if (! sublist.isEmpty()) {
list.add(sublist.get(0));
}
}
return new StructAssignExp(list);
}
});
}
开发者ID:ianrae,项目名称:dnal-lang,代码行数:17,代码来源:VarParser.java
示例5: 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;
}
开发者ID:indeedeng,项目名称:iql,代码行数:23,代码来源:ExpressionParser.java
示例6: arrayClass
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
/**
* Parser for internal array class names such as {@code [Z}, {@code [[[Ljava.lang.String;} etc.
*
* <p>.java files can only use {@code int[]} format, not the internal format. But we have to
* be able to parse from internal format because {@link Type#toString} can produce it.
*/
private Parser<Class<?>> arrayClass() {
Parser<Class<?>> arrayType = FQN.next(name -> {
// Only invoked when we already see a "[" at the beginning.
Class<?> primitiveArray = PRIMITIVE_ARRAY_TYPES.get("[" + name);
if (primitiveArray != null) return Parsers.constant(primitiveArray);
if (name.startsWith("L") && name.endsWith(";")) {
String className = name.substring(1, name.length() - 1);
return Parsers.constant(Types.newArrayType(loadClass(className)));
} else {
return Parsers.expect("array class internal name");
}
});
return TERMS.token("[") // must be an array internal format from this point on.
.next(arrayType.prefix(TERMS.token("[").retn(Types::newArrayType)));
}
开发者ID:jparsec,项目名称:jparsec-g,代码行数:22,代码来源:TypeParser.java
示例7: argumentList
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
static <T extends ExprNode> Parser<InvArgListNode> argumentList (Parser<T> e)
{
Parser<InvArgNode> namedArg = Mapper.<InvArgNode>curry(InvArgNode.Named.class).sequence(NAME_PARSER, term("="), e);
Parser<InvArgNode> arg = namedArg.or(Mapper.curry(InvArgNode.Positional.class).sequence(e));
Parser<InvArgNode> manyArgs = Mapper.<InvArgNode>curry(InvArgNode.ManyArgs.class).sequence(term("*"), e);
Parser<InvArgNode> keywordArgs = Mapper.<InvArgNode>curry(InvArgNode.KeywordArgs.class).sequence(term("**"), e);
/* Gleefully stolen from the Python grammar file. */
Parser<List<InvArgNode>> parser;
parser = Parsers2.collect(
arg.sepEndBy(term(",")),
Parsers.or(
Parsers2.collectN1(manyArgs, term(",").next(namedArg.sepBy1(term(","))).atomic().optional(), term(",").next(keywordArgs).optional()),
Parsers2.list(keywordArgs),
Parsers2.list(arg.followedBy(term(",")).optional())));
parser = Parsers2.filter(parser, Predicates.<InvArgNode>notNull());
return Mapper.curry(InvArgListNode.class).sequence(parser);
}
开发者ID:impl,项目名称:yashiro,代码行数:21,代码来源:ExpressionParser.java
示例8: data
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
Parser<DataNode> data ()
{
return Marker.mark(Mapper.curry(DataNode.class).sequence(
new Mapper<String>()
{
public String map(Stripping stripLeading, List<String> bodies, Stripping stripTrailing)
{
String body = Joiner.on("").join(bodies);
if (stripLeading == Stripping.ALL)
body = CharMatcher.WHITESPACE.trimLeadingFrom(body);
if (stripTrailing == Stripping.ALL)
body = CharMatcher.WHITESPACE.trimTrailingFrom(body);
else if (stripTrailing == Stripping.LINE)
body = LINE_STRIP_PATTERN.matcher(body).replaceFirst("");
return body;
}
}.sequence(strip().optional(Stripping.NONE), Parsers.or(TagParsers.data(), Parsers.EOF.retn("")).many1(), strip().optional(Stripping.NONE))));
}
开发者ID:impl,项目名称:yashiro,代码行数:22,代码来源:BodyParser.java
示例9: parserOf
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
@SafeVarargs
public final <U extends T> Parser<?> parserOf (final U... expected)
{
if (expected.length == 0) {
return Parsers.never();
} else if (expected.length == 1) {
return parserOf(expected[0]);
}
Parser<?>[] parsers = new Parser<?>[expected.length];
for (int i = 0; i < expected.length; i++)
{
parsers[i] = parserOf(expected[i]);
}
return Parsers.sequence(parsers);
}
开发者ID:impl,项目名称:yashiro,代码行数:17,代码来源:Tag.java
示例10: indexsetCommand
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
private Parser<Void> indexsetCommand() {
return Parsers.sequence(token("indexset"), STRING, STRING,
token("list").next(token("(")).next(STRING.sepBy(token(",")))
.followedBy(token(")")),
new Map4<Token, String, String, List<String>, Void>() {
public Void map(Token id, String full, String name,
List<String> set) {
if (indexSets.containsKey(full)) {
throw createException("Redefining index set '%s'",
name);
}
indexSets.put(full, new IndexSet(name, set));
return null;
}
});
}
开发者ID:pgriffel,项目名称:pacioli,代码行数:17,代码来源:Machine.java
示例11: applicationDebugParser
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
private static Parser<Expression> applicationDebugParser(
Parser<Expression> expParser) {
return Parsers
.sequence(
token("application_debug").next(token("("))
.next(STRING),
token(",").next(STRING),
token(",").next(STRING),
token(",").next(expParser),
token(",").next(expParser).many()
.followedBy(token(")")),
new Map5<String, String, String, Expression, List<Expression>, Expression>() {
public Expression map(String text, String fullText,
String trace, Expression fun,
List<Expression> args) {
return new ApplicationDebug(text, fullText,
trace.equals("true"), fun, args);
}
});
}
开发者ID:pgriffel,项目名称:pacioli,代码行数:21,代码来源:Machine.java
示例12: defIndexParser
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
private static Parser<Definition> defIndexParser() {
return Parsers.sequence(
token("defindex"),
token("public").optional(),
EXPIDENTIFIER,
token("=").next(
Parsers.between(token("{"), NAME.sepBy(token(",")),
token("}"))).optional().followedBy(token(";")),
new Map4<Token, Token, IdentifierNode, List<IdentifierNode>, Definition>() {
public Definition map(Token key, Token pub, final IdentifierNode id,
final List<IdentifierNode> items) {
List<String> names = new ArrayList<String>();
if (items != null) {
for (IdentifierNode item : items) {
names.add(item.getName());
}
} else {
//throw createException(id.getLocation(), "todo: empty defindex");
}
return new IndexSetDefinition(id.getLocation(), id,
names);
}
});
}
开发者ID:pgriffel,项目名称:pacioli,代码行数:25,代码来源:Reader.java
示例13: collectionValueParser
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
/**
* A collection is a constraint value consisting of a pair of parentheses around a comma-separated
* list of constraint values, as defined above excluding collections, so it is not recursive.
*
* @return ConstraintValueCollection containing ConstraintValues *MAY BE OF DIFFERENT TYPES*
*/
protected Parser<QlConstraintValueCollection<? extends QlConstraintValue>> collectionValueParser() {
return padWithWhitespace(
Parsers.or(executableValueParser(), stringValueParser(),
numericalValueParser(), booleanValueParser()), false)
.sepBy(padWithWhitespace(regex(",", true), false))
.between(padWithWhitespace(regex("\\(", true), false),
padWithWhitespace(regex("\\)", true), false))
.map(new Map<List<QlConstraintValue>, QlConstraintValueCollection<? extends QlConstraintValue>>() {
@Override
public QlConstraintValueCollection<? extends QlConstraintValue> map(
List<QlConstraintValue> arg0) {
return new QlConstraintValueCollection<QlConstraintValue>(
arg0);
}
});
}
开发者ID:lithiumtech,项目名称:starql,代码行数:24,代码来源:JparsecQueryMarkupManager.java
示例14: forUnitParser
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
private static Parser<TypeContext> forUnitParser() {
return token("for_unit").next(Parsers.or(matrixTermBang(), TYPEIDENTIFIER).sepBy(token(","))).map(
new Map<List<TypeNode>, TypeContext>() {
public TypeContext map(List<TypeNode> nodes) {
TypeContext context = new TypeContext();
for (TypeNode node : nodes) {
if (node instanceof TypeIdentifierNode) {
context.addUnitVar(((TypeIdentifierNode) node).getName());
} else {
context.addUnitVar(((BangTypeNode) node).toText());
}
}
return context;
}
});
}
开发者ID:pgriffel,项目名称:pacioli,代码行数:17,代码来源:Reader.java
示例15: parametricTypeParser
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
private static Parser<TypeNode> parametricTypeParser(
Parser<TypeNode> typeParser) {
return Parsers
.sequence(
TYPEIDENTIFIER,
token("(").next(typeParser.sepBy(token(","))),
token(")"),
new Map3<TypeIdentifierNode, List<TypeNode>, Token, TypeNode>() {
public TypeNode map(final TypeIdentifierNode id,
final List<TypeNode> args, Token paren) {
Location loc = id.getLocation().join(
tokenLocation(paren));
return new TypeApplicationNode(loc, id, args);
}
});
}
开发者ID:pgriffel,项目名称:pacioli,代码行数:17,代码来源:Reader.java
示例16: statementParser
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
private static Parser<ExpressionNode> statementParser(
Parser<ExpressionNode> expParser) {
Parser.Reference<ExpressionNode> reference = Parser.newReference();
Parser<ExpressionNode> lazyExpr = reference.lazy();
Parser<ExpressionNode> nestedParser = statementSequenceParser(lazyExpr,
expParser);
Parser<ExpressionNode> parser = Parsers.sequence(token("begin"),
statementSequenceParser(lazyExpr, expParser), token("end"),
new Map3<Token, ExpressionNode, Token, ExpressionNode>() {
public ExpressionNode map(Token begin, ExpressionNode body,
Token end) {
return new StatementNode(tokenLocation(begin).join(
tokenLocation(end)), (SequenceNode) body);
}
});
reference.set(nestedParser);
return parser;
}
开发者ID:pgriffel,项目名称:pacioli,代码行数:19,代码来源:Reader.java
示例17: statementSequenceParser
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
private static Parser<ExpressionNode> statementSequenceParser(
Parser<ExpressionNode> statementParser,
Parser<ExpressionNode> expParser) {
return Parsers
.or(assignmentStatementParser(expParser),
tupleAssignmentParser(expParser),
ifStatementParser(statementParser, expParser),
whileStatementParser(statementParser, expParser),
returnStatementParser(expParser),
applicationParser(expParser).followedBy(token(";"))).many1()
.map(new Map<List<ExpressionNode>, ExpressionNode>() {
public ExpressionNode map(List<ExpressionNode> body) {
assert (0 < body.size());
Location loc = body.get(0).getLocation()
.join(body.get(body.size() - 1).getLocation());
return new SequenceNode(loc, body);
}
});
}
开发者ID:pgriffel,项目名称:pacioli,代码行数:20,代码来源:Reader.java
示例18: tupleAssignmentParser
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
private static Parser<ExpressionNode> tupleAssignmentParser(
Parser<ExpressionNode> expParser) {
return Parsers
.sequence(
token("("),
EXPIDENTIFIER.sepBy(token(",")).followedBy(token(")"))
.followedBy(token(":=")),
expParser.followedBy(token(";")),
new Map3<Token, List<IdentifierNode>, ExpressionNode, ExpressionNode>() {
public ExpressionNode map(final Token paren,
List<IdentifierNode> vars,
final ExpressionNode value) {
Location loc = tokenLocation(paren).join(
value.getLocation());
return new TupleAssignmentNode(loc, vars, value);
}
});
}
开发者ID:pgriffel,项目名称:pacioli,代码行数:19,代码来源:Reader.java
示例19: elseRestIfParser
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
private static Parser<List<Pair<ExpressionNode, ExpressionNode>>> elseRestIfParser(
Parser<ExpressionNode> statementParser,
Parser<ExpressionNode> expParser,
Parser<List<Pair<ExpressionNode, ExpressionNode>>> restParser) {
return Parsers
.sequence(
token("if").next(expParser),
token("then").next(statementParser),
restParser,
new Map3<ExpressionNode, ExpressionNode, List<Pair<ExpressionNode, ExpressionNode>>, List<Pair<ExpressionNode, ExpressionNode>>>() {
public List<Pair<ExpressionNode, ExpressionNode>> map(
ExpressionNode test,
ExpressionNode body,
List<Pair<ExpressionNode, ExpressionNode>> rest) {
List<Pair<ExpressionNode, ExpressionNode>> list = new ArrayList<Pair<ExpressionNode, ExpressionNode>>(
rest);
list.add(new Pair<ExpressionNode, ExpressionNode>(
test, body));
return list;
}
});
}
开发者ID:pgriffel,项目名称:pacioli,代码行数:23,代码来源:Reader.java
示例20: applicationParser
import org.codehaus.jparsec.Parsers; //导入依赖的package包/类
private static Parser<ExpressionNode> applicationParser(
Parser<ExpressionNode> expParser) {
return Parsers
.sequence(
EXPIDENTIFIER,
token("("),
expParser.sepBy(token(",")),
token(")"),
new Map4<ExpressionNode, Token, List<ExpressionNode>, Token, ExpressionNode>() {
public ExpressionNode map(ExpressionNode fun,
Token left, List<ExpressionNode> args,
Token right) {
return new ApplicationNode(fun, args, fun
.getLocation().join(
tokenLocation(right)));
}
});
}
开发者ID:pgriffel,项目名称:pacioli,代码行数:19,代码来源:Reader.java
注:本文中的org.codehaus.jparsec.Parsers类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论