File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\bnf\RuleOptional.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 an optional BNF rule.
13 */
14 class RuleOptional implements Rule {
15 private final Rule rule;
16 private boolean mapSet;
17
18 RuleOptional(Rule rule) {
19 this.rule = rule;
20 }
21
22 public void accept(BnfVisitor visitor) {
23 visitor.visitRuleOptional(rule);
24 }
25
26 public void setLinks(HashMap<String, RuleHead> ruleMap) {
27 if (!mapSet) {
28 rule.setLinks(ruleMap);
29 mapSet = true;
30 }
31 }
32 public boolean autoComplete(Sentence sentence) {
33 sentence.stopIfRequired();
34 rule.autoComplete(sentence);
35 return true;
36 }
37
38 }
39