本文整理汇总了Java中com.github.ruediste.lambdaPegParser.ParserFactory类的典型用法代码示例。如果您正苦于以下问题:Java ParserFactory类的具体用法?Java ParserFactory怎么用?Java ParserFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParserFactory类属于com.github.ruediste.lambdaPegParser包,在下文中一共展示了ParserFactory类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addition
import com.github.ruediste.lambdaPegParser.ParserFactory; //导入依赖的package包/类
@Test
public void addition() {
DefaultParsingContext ctx = new DefaultParsingContext("1+2");
PlusMinusParser parser = ParserFactory.create(PlusMinusParser.class, ctx);
int result = parser.input();
assertEquals(3, result);
}
示例2: format
import com.github.ruediste.lambdaPegParser.ParserFactory; //导入依赖的package包/类
public String format(String pattern, Map<String, Object> arguments,
Locale locale) {
DefaultParsingContext ctx = new DefaultParsingContext(pattern);
if (trace) {
new Tracer(ctx, System.out);
}
PatternParser parser = ParserFactory.create(PatternParser.class, ctx);
formatTypeParsers
.entrySet()
.stream()
.forEach(
e -> {
FormatTypeParser tmp = ParserFactory.create(
e.getValue(), FormatTypeParser.class, ctx);
tmp.setPatternParser(parser);
parser.getFormatParsers().put(e.getKey(), tmp);
});
PatternNode node = parser.fullPattern();
FormattingContext fCtx = new FormattingContext(locale, arguments
.entrySet()
.stream()
.collect(
toMap(e -> e.getKey(),
e -> argumentPreparationFunction.apply(
e.getValue(), locale))));
return node.format(fCtx);
}
示例3: setup
import com.github.ruediste.lambdaPegParser.ParserFactory; //导入依赖的package包/类
@Before
public void setup() {
ctx = new DefaultParsingContext("");
parser = ParserFactory.create(ParsingFailureParser.class, ctx);
}
示例4: singleNumber
import com.github.ruediste.lambdaPegParser.ParserFactory; //导入依赖的package包/类
@Test
public void singleNumber() {
assertEquals(123, ParserFactory.create(PlusMinusParser.class, "123").input());
}
示例5: subtraction
import com.github.ruediste.lambdaPegParser.ParserFactory; //导入依赖的package包/类
@Test
public void subtraction() {
assertEquals(7, ParserFactory.create(PlusMinusParser.class, "12-5").input());
}
示例6: complex
import com.github.ruediste.lambdaPegParser.ParserFactory; //导入依赖的package包/类
@Test
public void complex() {
assertEquals(9, ParserFactory.create(PlusMinusParser.class, "12-5+2").input());
}
示例7: toPrefixAndRegex
import com.github.ruediste.lambdaPegParser.ParserFactory; //导入依赖的package包/类
/**
* Turn a glob into a regex
*/
public static Pair<String, String> toPrefixAndRegex(String glob) {
return ParserFactory.create(GlobParser.class, glob).glob();
}