public void define(String name, Combine combine, ParsedPattern pattern, Location loc, Annotations anno) throws BuildException { if(name==START) grammar.start = (DPattern)pattern; else { // TODO: handle combine DDefine d = grammar.getOrAdd(name); d.setPattern( (DPattern) pattern ); if(anno!=null) d.annotation = ((Annotation)anno).getResult(); } }
/** * @param out Output stream. */ public DXMLPrinter(XMLStreamWriter out) { this.out = out; this.visitor = new DXMLPrinterVisitor(); this.ncVisitor = new NameClassXMLPrinterVisitor(); this.domPrinter = new DOMPrinter(out); }
public Void onOptional(DOptionalPattern p) { start("optional"); on(p.getAnnotation()); unwrapGroup(p.getChild()); end(); return null; }
public Void onElement(DElementPattern p) { start("element"); on(p.getName()); on(p.getAnnotation()); unwrapGroup(p.getChild()); end(); return null; }
public Void onZeroOrMore(DZeroOrMorePattern p) { start("zeroOrMore"); on(p.getAnnotation()); unwrapGroup(p.getChild()); end(); return null; } }
public Void onOneOrMore(DOneOrMorePattern p) { start("oneOrMore"); on(p.getAnnotation()); unwrapGroup(p.getChild()); end(); return null; }
public Void onMixed(DMixedPattern p) { start("mixed"); on(p.getAnnotation()); unwrapGroup(p.getChild()); end(); return null; }
public Void onText(DTextPattern p) { start("text"); on(p.getAnnotation()); end(); return null; }
public Void onEmpty(DEmptyPattern p) { start("empty"); on(p.getAnnotation()); end(); return null; }
public Void onGroup(DGroupPattern p) { start("group"); on(p.getAnnotation()); for (DPattern d : p) { on(d); } end(); return null; }
public Void onNotAllowed(DNotAllowedPattern p) { start("notAllowed"); on(p.getAnnotation()); end(); return null; }
public ParsedPattern makeRef(String name, Location loc, Annotations anno) throws BuildException { return DSchemaBuilderImpl.wrap( new DRefPattern(grammar.getOrAdd(name)), (LocatorImpl)loc, (Annotation)anno ); } }
protected Void onContainer(DContainerPattern p) { for( DPattern c=p.firstChild(); c!=null; c=c.next ) c.accept(this); return null; }
public boolean isNullable() { for( DPattern p=firstChild(); p!=null; p=p.next ) if(p.isNullable()) return true; return false; } public <V> V accept( DPatternVisitor<V> visitor ) {
protected void unwrapChoice(DPattern p) { if (p instanceof DChoicePattern && p.getAnnotation() == DAnnotation.EMPTY) { for (DPattern d : (DChoicePattern) p) { on(d); } } else { on(p); } }
public Void onZeroOrMore(DZeroOrMorePattern p) { start("zeroOrMore"); on(p.getAnnotation()); unwrapGroup(p.getChild()); end(); return null; } }
public Void onOneOrMore(DOneOrMorePattern p) { start("oneOrMore"); on(p.getAnnotation()); unwrapGroup(p.getChild()); end(); return null; }
public void define(String name, Combine combine, ParsedPattern pattern, Location loc, Annotations anno) throws BuildException { if(name==START) { grammar.start = (DPattern)pattern; } else { // TODO: handle combine DDefine d = grammar.getOrAdd(name); d.setPattern( (DPattern) pattern ); if (anno!=null) { d.annotation = ((Annotation)anno).getResult(); } } }
/** * @param out Output stream. */ public DXMLPrinter(XMLStreamWriter out) { this.out = out; this.visitor = new DXMLPrinterVisitor(); this.ncVisitor = new NameClassXMLPrinterVisitor(); this.domPrinter = new DOMPrinter(out); }