本文整理汇总了Java中org.parboiled.MatcherContext类的典型用法代码示例。如果您正苦于以下问题:Java MatcherContext类的具体用法?Java MatcherContext怎么用?Java MatcherContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MatcherContext类属于org.parboiled包,在下文中一共展示了MatcherContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
@Override
public <V> boolean match(MatcherContext<V> context) {
int cur = context.getCurrentIndex();
if(cur == 0) {
context.createNode();
return true;
}
InputBuffer buffer = context.getInputBuffer();
if(buffer.charAt(cur-1)=='\n') {
context.createNode();
return true;
}
return false;
}
开发者ID:simonwibberley,项目名称:GramExp,代码行数:17,代码来源:StartOfLineMatcher.java
示例2: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
public boolean match(MatcherContext<V> context) {
String path = stack.isEmpty() ? "" : stack.get(stack.size() - 1).getPath();
path += String.format("/%s[%d]", context.getMatcher().getLabel(), context.getCurrentIndex());
ReportEntry<V> report = new ReportEntry<V>(path);
stack.add(report);
boolean result = context.getMatcher().match(context);
report.setSucceeded(result);
stack.remove(stack.size() -1);
if (stack.isEmpty()) rootReport = report;
else {
ReportEntry<V> parent = stack.get(stack.size() - 1);
parent.getChildren().add(report);
parent.setSubSteps(parent.getSubSteps() + 1 + report.getSubSteps());
}
return result;
}
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:17,代码来源:ProfilerParseRunner.java
示例3: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
public boolean match(MatcherContext context) {
Object valueStackSnapshot = context.getValueStack().takeSnapshot();
List<Matcher> children = getChildren();
int size = children.size();
for (int i = 0; i < size; i++) {
Matcher matcher = children.get(i);
// remember the current index in the context, so we can access it for building the current follower set
context.setIntTag(i);
if (!matcher.getSubContext(context).runMatcher()) {
// rule failed, so invalidate all stack actions the rule might have done
context.getValueStack().restoreSnapshot(valueStackSnapshot);
return false;
}
}
context.createNode();
return true;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:21,代码来源:SequenceMatcher.java
示例4: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
public boolean match(MatcherContext context) {
boolean matched = subMatcher.getSubContext(context).runMatcher();
if (!matched) return false;
// collect all further matches as well
int lastIndex = context.getCurrentIndex();
while (subMatcher.getSubContext(context).runMatcher()) {
int currentIndex = context.getCurrentIndex();
if (currentIndex == lastIndex) {
throw new GrammarException("The inner rule of OneOrMore rule '%s' must not allow empty matches",
context.getPath());
}
lastIndex = currentIndex;
}
context.createNode();
return true;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:19,代码来源:OneOrMoreMatcher.java
示例5: run
import org.parboiled.MatcherContext; //导入依赖的package包/类
public ParsingResult<V> run(InputBuffer inputBuffer) {
checkArgNotNull(inputBuffer, "inputBuffer");
resetValueStack();
totalRuns++;
MatcherContext<V> rootContext = createRootContext(inputBuffer, this, true);
rootContext.getMatcher().accept(new DoWithMatcherVisitor(new DoWithMatcherVisitor.Action() {
public void process(Matcher matcher) {
RuleStats ruleStats = (RuleStats) matcher.getTag();
if (ruleStats == null) {
ruleStats = new RuleStats();
matcher.setTag(ruleStats);
} else {
ruleStats.clear();
}
}
}));
runMatches = 0;
long timeStamp = System.nanoTime() - timeCorrection;
boolean matched = rootContext.runMatcher();
totalNanoTime += System.nanoTime() - timeCorrection - timeStamp;
getRootMatcher().accept(new DoWithMatcherVisitor(updateStatsAction));
return createParsingResult(matched, rootContext);
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:27,代码来源:ProfilingParseRunner.java
示例6: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
@Override
public final <V> boolean match(final MatcherContext<V> context) {
if (!isAllowedChar(context.getCurrentChar())) {
return false;
}
context.advanceIndex(1);
context.createNode();
return true;
}
开发者ID:edmocosta,项目名称:queryfy,代码行数:10,代码来源:SelectorMatcher.java
示例7: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
@Override
public final <V> boolean match(MatcherContext<V> context) {
if (!acceptChar(context.getCurrentChar())) {
return false;
}
context.advanceIndex(1);
context.createNode();
return true;
}
开发者ID:AlexFalappa,项目名称:nb-springboot,代码行数:10,代码来源:JavaIdPartMatcher.java
示例8: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
@Override
public <V> boolean match(MatcherContext<V> context) {
int cur = context.getCurrentIndex();
InputBuffer buffer = context.getInputBuffer();
String content = InputBufferUtils.collectContent(buffer);
content = content.substring(cur);
Matcher m = pattern.matcher(content);
if(m.find()) {
int start = m.start();
if(start == 0) {
int end = m.end();
int delta = end - start;
context.advanceIndex(delta);
context.createNode();
return true;
} else {
return false;
}
} else {
return false;
}
}
开发者ID:simonwibberley,项目名称:GramExp,代码行数:33,代码来源:RegularExpressionMatcher.java
示例9: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
@Override public boolean match(MatcherContext<Node> context) {
char current = context.getCurrentChar();
if (Character.isJavaIdentifierPart(current)) {
context.advanceIndex();
context.createNode();
return true;
}
return false;
}
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:10,代码来源:BasicsParser.java
示例10: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
@Override
public boolean match(MatcherContext context) {
if (!context.fastStringMatching()) {
return super.match(context);
}
Record rec = root;
int ix = context.getCurrentIndex();
InputBuffer buffer = context.getInputBuffer();
char c = context.getCurrentChar();
int endIx = -1;
loop:
while (true) {
char[] chars = rec.chars;
for (int i = 0; i < chars.length; i++) {
if (c == chars[i]) {
ix++;
rec = rec.subs[i];
if (rec == null) { // success, we complected a tree path to a leave
endIx = ix;
break loop;
}
if (rec.complete) { // we completed a valid match path, but continue looking for a longer match
endIx = ix;
}
c = buffer.charAt(ix);
continue loop;
}
}
// we checked all sub branches of the current node, none matched, so we are done
break;
}
if (endIx == -1) return false; // we matched no complete path, so fail
context.advanceIndex(endIx - context.getCurrentIndex());
context.createNode();
return true;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:41,代码来源:FirstOfStringsMatcher.java
示例11: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
public boolean match(MatcherContext context) {
switch (context.getCurrentChar()) {
case Chars.DEL_ERROR:
case Chars.INS_ERROR:
case Chars.RESYNC:
case Chars.RESYNC_START:
case Chars.RESYNC_END:
case Chars.RESYNC_EOI:
case Chars.EOI:
return false;
}
context.advanceIndex(1);
context.createNode();
return true;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:16,代码来源:AnyMatcher.java
示例12: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
public boolean match(MatcherContext context) {
int lastIndex = context.getCurrentIndex();
Object valueStackSnapshot = context.getValueStack().takeSnapshot();
if (!subMatcher.getSubContext(context).runMatcher()) return false;
// reset location, Test matchers never advance
context.setCurrentIndex(lastIndex);
// erase all value stack changes the the submatcher could have made
context.getValueStack().restoreSnapshot(valueStackSnapshot);
return true;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:14,代码来源:TestMatcher.java
示例13: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
@Override
public boolean match(MatcherContext context) {
if (!context.fastStringMatching()) {
return super.match(context);
}
if (!context.getInputBuffer().test(context.getCurrentIndex(), characters)) return false;
context.advanceIndex(characters.length);
context.createNode();
return true;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:12,代码来源:StringMatcher.java
示例14: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
public boolean match(MatcherContext context) {
int lastIndex = context.getCurrentIndex();
Object valueStackSnapshot = context.getValueStack().takeSnapshot();
if (subMatcher.getSubContext(context).runMatcher()) return false;
// reset location, Test matchers never advance
context.setCurrentIndex(lastIndex);
// erase all value stack changes the the submatcher could have made
context.getValueStack().restoreSnapshot(valueStackSnapshot);
return true;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:14,代码来源:TestNotMatcher.java
示例15: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
public boolean match(MatcherContext context) {
char c = context.getCurrentChar();
if (c != charLow && c != charUp) return false;
context.advanceIndex(1);
context.createNode();
return true;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:8,代码来源:CharIgnoreCaseMatcher.java
示例16: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
public boolean match(MatcherContext context) {
checkArgNotNull(context, "context");
int lastIndex = context.getCurrentIndex();
while (subMatcher.getSubContext(context).runMatcher()) {
int currentLocation = context.getCurrentIndex();
if (currentLocation == lastIndex) {
throw new GrammarException("The inner rule of ZeroOrMore rule '%s' must not allow empty matches",
context.getPath());
}
lastIndex = currentLocation;
}
context.createNode();
return true;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:16,代码来源:ZeroOrMoreMatcher.java
示例17: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
public <V> boolean match(MatcherContext<V> context) {
if (context.hasMismatched()) {
return false;
}
if (inner.match(context)) {
return true;
}
context.memoizeMismatch();
return false;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:12,代码来源:MemoMismatchesMatcher.java
示例18: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
@SuppressWarnings( {"ForLoopReplaceableByForEach"})
public boolean match(MatcherContext context) {
List<Matcher> children = getChildren();
int size = children.size();
for (int i = 0; i < size; i++) {
Matcher matcher = children.get(i);
if (matcher.getSubContext(context).runMatcher()) {
context.createNode();
return true;
}
}
return false;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:14,代码来源:FirstOfMatcher.java
示例19: match
import org.parboiled.MatcherContext; //导入依赖的package包/类
public boolean match(MatcherContext context) {
char c = context.getCurrentChar();
if (c < cLow || c > cHigh) return false;
context.advanceIndex(1);
context.createNode();
return true;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:9,代码来源:CharRangeMatcher.java
示例20: getFollowMatchers
import org.parboiled.MatcherContext; //导入依赖的package包/类
public List<Matcher> getFollowMatchers(MatcherContext currentContext) {
followMatchers.clear();
context = currentContext.getParent();
while (context != null) {
boolean complete = context.getMatcher().accept(this);
if (complete) return followMatchers;
context = context.getParent();
}
return followMatchers;
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:11,代码来源:FollowMatchersVisitor.java
注:本文中的org.parboiled.MatcherContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论