本文整理汇总了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]));
}
示例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]);
}
示例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()));
}
示例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());
}
示例5: TemplateBody
import org.parboiled.Rule; //导入依赖的package包/类
Rule TemplateBody() {
return Sequence(
TextBlock(), Template.addParts(),
ZeroOrMore(
Sequence(
Directive(), Template.addParts(),
TextBlock(), Template.addParts())));
}
示例6: DirectiveEnd
import org.parboiled.Rule; //导入依赖的package包/类
Rule DirectiveEnd() {
return ClosingDirective(FirstOf(
IfEnd(),
LetEnd(),
ForEnd(),
InvokeEnd()));
}
示例7: AccessExpression
import org.parboiled.Rule; //导入依赖的package包/类
Rule AccessExpression() {
return Sequence(SimpleAccessExpression.builder(),
Identifier(), SimpleAccessExpression.addPath(),
ZeroOrMore(Sequence(DOT,
Identifier(), SimpleAccessExpression.addPath())),
SimpleAccessExpression.build());
}
示例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());
}
示例9: AssignGenerator
import org.parboiled.Rule; //导入依赖的package包/类
Rule AssignGenerator() {
return Sequence(AssignGenerator.builder(),
ValueDeclaration(), AssignGenerator.declaration(),
ASSIGN,
Expression(), AssignGenerator.from(),
AssignGenerator.build());
}
示例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());
}
示例11: DisambiguatedExpression
import org.parboiled.Rule; //导入依赖的package包/类
@DontLabel
Rule DisambiguatedExpression() {
return FirstOf(
Parens(ApplyExpression()),
ForIterationAccessExpression(),
AccessExpression(),
StringLiteral());
}
示例12: ParameterDeclaration
import org.parboiled.Rule; //导入依赖的package包/类
Rule ParameterDeclaration() {
return Sequence(Parameter.builder(),
Type(), Parameter.type(),
Name(), Parameter.name(),
Parameter.build(),
InvokableDeclaration.addParameters());
}
示例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()));
}
示例14: Literal
import org.parboiled.Rule; //导入依赖的package包/类
@DontLabel
@SuppressSubnodes
Rule Literal(String string) {
return Sequence(
String(string),
Spacing());
}
示例15: Identifier
import org.parboiled.Rule; //导入依赖的package包/类
@SuppressSubnodes
@MemoMismatches
Rule Identifier() {
return Sequence(
TestNot(Keyword()),
Sequence(Sequence(IdentifierStartLetter(), ZeroOrMore(LetterOrDigit())), Identifier.of()),
Spacing());
}