当前位置: 首页>>代码示例>>Java>>正文


Java Rule类代码示例

本文整理汇总了Java中org.parboiled.Rule的典型用法代码示例。如果您正苦于以下问题:Java Rule类的具体用法?Java Rule怎么用?Java Rule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Rule类属于org.parboiled包,在下文中一共展示了Rule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: operatorSymbolRule

import org.parboiled.Rule; //导入依赖的package包/类
Rule operatorSymbolRule(String operatorSymbol) {
    if (!operatorSymbol.contains(" ")) {
        return operatorSymbol.length() == 1 ?
                Ch(operatorSymbol.charAt(0)) :
                String(operatorSymbol);
    }

    LinkedList<Rule> symbolParts = new LinkedList<>();
    String[] parts = operatorSymbol.split(" ");
    for (int i = 0; i < parts.length; i++) {
        Rule operatorValue = parts[i].length() == 1 ?
                Ch(parts[i].charAt(0)) :
                String(parts[i]);

        symbolParts.add(operatorValue);

        if ((i + 1) < parts.length) {
            symbolParts.add(Ch(' '));
        }
    }

    return Sequence(symbolParts.toArray(new Object[0]));
}
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:24,代码来源:QueryParser.java

示例2: operatorParts

import org.parboiled.Rule; //导入依赖的package包/类
Object[] operatorParts(Operator operatorType, Object... moreRules) {

        Set<String> symbols = operatorType.getOperatorSymbols(config.getGrammar());

        LinkedList<Rule> symbolsRule = new LinkedList<>();
        for (String symbol : symbols) {
            symbolsRule.add(operatorSymbolRule(symbol));
        }

        Rule rule = FirstOf(symbolsRule.toArray(new Object[0]));

        LinkedList<Object> allRules = new LinkedList<>();
        allRules.add(rule);
        allRules.addAll(Arrays.asList(moreRules));

        return allRules.toArray(new Object[0]);
    }
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:18,代码来源:QueryParser.java

示例3: Order

import org.parboiled.Rule; //导入依赖的package包/类
Rule Order() {
    ListVar<OrderNode.OrderSpecifier> list = new ListVar<>();
    OrderVar orderVar = new OrderVar();

    return Sequence(
            toOperator(QueryOperatorType.ORDER),
            WS(),
            OrderSpecifier(orderVar),
            list.add(orderVar.get()),
            orderVar.clear(),
            ZeroOrMore(Sequence(OptionalWS(),
                    String(config.getGrammar().getArgsSeparator()),
                    OptionalWS(),
                    OrderSpecifier(orderVar),
                    list.add(orderVar.get()),
                    orderVar.clear()
            )), pushOrderByOperation(list.get()));
}
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:19,代码来源:QueryParser.java

示例4: TextBlock

import org.parboiled.Rule; //导入依赖的package包/类
Rule TextBlock() {
  return Sequence(TextBlock.builder(),
      TextFragment(), TextBlock.addParts(TextFragment.of()),
      ZeroOrMore(Sequence(
          Newline(), TextBlock.addParts(Newline.of()),
          TextFragment(), TextBlock.addParts(TextFragment.of()))),
      TextBlock.build());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:Parser.java

示例5: TemplateBody

import org.parboiled.Rule; //导入依赖的package包/类
Rule TemplateBody() {
  return Sequence(
      TextBlock(), Template.addParts(),
      ZeroOrMore(
      Sequence(
          Directive(), Template.addParts(),
          TextBlock(), Template.addParts())));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:Parser.java

示例6: DirectiveEnd

import org.parboiled.Rule; //导入依赖的package包/类
Rule DirectiveEnd() {
  return ClosingDirective(FirstOf(
      IfEnd(),
      LetEnd(),
      ForEnd(),
      InvokeEnd()));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Parser.java

示例7: AccessExpression

import org.parboiled.Rule; //导入依赖的package包/类
Rule AccessExpression() {
  return Sequence(SimpleAccessExpression.builder(),
      Identifier(), SimpleAccessExpression.addPath(),
      ZeroOrMore(Sequence(DOT,
          Identifier(), SimpleAccessExpression.addPath())),
      SimpleAccessExpression.build());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Parser.java

示例8: IterationGenerator

import org.parboiled.Rule; //导入依赖的package包/类
Rule IterationGenerator() {
  return Sequence(IterationGenerator.builder(),
      ValueDeclaration(), IterationGenerator.declaration(),
      IN,
      Expression(), IterationGenerator.from(),
      Optional(IF, Expression(), IterationGenerator.condition()),
      IterationGenerator.build());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:Parser.java

示例9: AssignGenerator

import org.parboiled.Rule; //导入依赖的package包/类
Rule AssignGenerator() {
  return Sequence(AssignGenerator.builder(),
      ValueDeclaration(), AssignGenerator.declaration(),
      ASSIGN,
      Expression(), AssignGenerator.from(),
      AssignGenerator.build());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Parser.java

示例10: TransformGenerator

import org.parboiled.Rule; //导入依赖的package包/类
Rule TransformGenerator() {
  return Sequence(TransformGenerator.builder(),
      ValueDeclaration(), TransformGenerator.declaration(),
      ASSIGN,
      Expression(), TransformGenerator.transform(),
      FOR,
      ValueDeclaration(), TransformGenerator.varDeclaration(),
      IN,
      Expression(), TransformGenerator.from(),
      Optional(IF, Expression(), TransformGenerator.condition()),
      TransformGenerator.build());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:Parser.java

示例11: DisambiguatedExpression

import org.parboiled.Rule; //导入依赖的package包/类
@DontLabel
Rule DisambiguatedExpression() {
  return FirstOf(
      Parens(ApplyExpression()),
      ForIterationAccessExpression(),
      AccessExpression(),
      StringLiteral());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:Parser.java

示例12: ParameterDeclaration

import org.parboiled.Rule; //导入依赖的package包/类
Rule ParameterDeclaration() {
  return Sequence(Parameter.builder(),
      Type(), Parameter.type(),
      Name(), Parameter.name(),
      Parameter.build(),
      InvokableDeclaration.addParameters());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Parser.java

示例13: InOperation

import org.parboiled.Rule; //导入依赖的package包/类
Rule InOperation() {
    ListVar<Object> list = new ListVar<>();
    return Sequence(Selector(), WS(), FirstOf(NotInOperator(), InOperator()),
            OptionalWS(),
            Ch('('),
            OptionalWS(), Arguments(list), OptionalWS(),
            Ch(')'), pushListOperation(list.get()));
}
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:9,代码来源:QueryParser.java

示例14: Literal

import org.parboiled.Rule; //导入依赖的package包/类
@DontLabel
@SuppressSubnodes
Rule Literal(String string) {
  return Sequence(
      String(string),
      Spacing());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Parser.java

示例15: Identifier

import org.parboiled.Rule; //导入依赖的package包/类
@SuppressSubnodes
@MemoMismatches
Rule Identifier() {
  return Sequence(
      TestNot(Keyword()),
      Sequence(Sequence(IdentifierStartLetter(), ZeroOrMore(LetterOrDigit())), Identifier.of()),
      Spacing());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:Parser.java


注:本文中的org.parboiled.Rule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。