File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\bnf\RuleRepeat.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.bnf;
8
9 import java.util.HashMap;
10
11 /**
12 * Represents a loop in a BNF object.
13 */
14 class RuleRepeat implements Rule {
15
16 private final Rule rule;
17 private final boolean comma;
18
19 RuleRepeat(Rule rule, boolean comma) {
20 this.rule = rule;
21 this.comma = comma;
22 }
23
24 public void accept(BnfVisitor visitor) {
25 visitor.visitRuleRepeat(comma, rule);
26 }
27
28 public void setLinks(HashMap<String, RuleHead> ruleMap) {
29 // not required, because it's already linked
30 }
31
32 public boolean autoComplete(Sentence sentence) {
33 sentence.stopIfRequired();
34 while (rule.autoComplete(sentence)) {
35 // nothing to do
36 }
37 return true;
38 }
39
40 }
41