01: package org.kohsuke.rngom.parse.host;
02:
03: import org.kohsuke.rngom.ast.builder.Annotations;
04: import org.kohsuke.rngom.ast.builder.BuildException;
05: import org.kohsuke.rngom.ast.builder.Grammar;
06: import org.kohsuke.rngom.ast.om.Location;
07: import org.kohsuke.rngom.ast.om.ParsedPattern;
08:
09: /**
10: * Wraps {@link Grammar} and provides error checking.
11: *
12: * <p>
13: * The following errors are checked by this host:
14: *
15: * <ol>
16: * <li>referenced to undefined patterns.
17: * </ol>
18: *
19: * @author
20: * Kohsuke Kawaguchi (kk@kohsuke.org)
21: */
22: public class GrammarHost extends ScopeHost implements Grammar {
23: final Grammar lhs;
24: final Grammar rhs;
25:
26: public GrammarHost(Grammar lhs, Grammar rhs) {
27: super (lhs, rhs);
28: this .lhs = lhs;
29: this .rhs = rhs;
30: }
31:
32: public ParsedPattern endGrammar(Location _loc, Annotations _anno)
33: throws BuildException {
34: LocationHost loc = cast(_loc);
35: AnnotationsHost anno = cast(_anno);
36:
37: return new ParsedPatternHost(lhs.endGrammar(loc.lhs, anno.lhs),
38: rhs.endGrammar(loc.rhs, anno.rhs));
39: }
40: }
|