org.glowroot.shaded.h2.bnf.RuleRepeat Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.glowroot.shaded.h2.bnf;
import java.util.HashMap;
/**
* Represents a loop in a BNF object.
*/
public class RuleRepeat implements Rule {
private final Rule rule;
private final boolean comma;
public RuleRepeat(Rule rule, boolean comma) {
this.rule = rule;
this.comma = comma;
}
@Override
public void accept(BnfVisitor visitor) {
visitor.visitRuleRepeat(comma, rule);
}
@Override
public void setLinks(HashMap ruleMap) {
// not required, because it's already linked
}
@Override
public boolean autoComplete(Sentence sentence) {
sentence.stopIfRequired();
while (rule.autoComplete(sentence)) {
// nothing to do
}
return true;
}
}