private final Expression mergeContinuation( Expression exp1, Expression exp2 ) { if(exp1==null && exp2==null) return null; if(exp1==null || exp1==Expression.nullSet) return exp2; if(exp2==null || exp2==Expression.nullSet) return exp1; return docDecl.pool.createChoice(exp1,exp2); }
/** helper function for constructor */ private static Expression createCombined( ExpressionPool pool, DeclImpl[] rules ) { Expression exp = Expression.nullSet; for( int i=0; i<rules.length; i++ ) exp = pool.createChoice( exp, rules[i].exp ); return exp; }
public void addElementRule( ExpressionPool pool, ElementRule newRule ) { newRule.parent = this; if( exp==null ) // the first element exp = newRule; else exp = pool.createChoice(exp,newRule); }
protected Expression castExpression( Expression exp, Expression child ) { // first one. if( exp==null ) return child; else return reader.pool.createChoice(exp,child); } }
private final Expression mergeContinuation( Expression exp1, Expression exp2 ) { if(exp1==null && exp2==null) return null; if(exp1==null || exp1==Expression.nullSet) return exp2; if(exp2==null || exp2==Expression.nullSet) return exp1; return docDecl.pool.createChoice(exp1,exp2); }
protected Expression castExpression( Expression exp, Expression child ) { // first one. if( exp==null ) return child; else return reader.pool.createChoice(exp,child); } }
/** helper function for constructor */ private static Expression createCombined( ExpressionPool pool, DeclImpl[] rules ) { Expression exp = Expression.nullSet; for( int i=0; i<rules.length; i++ ) exp = pool.createChoice( exp, rules[i].exp ); return exp; }
public void mixedElement( String elementName ) { if( contentModel==null ) // assertion failed. contentModel must be prepared by startContentModel method. throw new Error(); contentModel = grammar.pool.createChoice( contentModel, grammar.namedPatterns.getOrCreate(elementName) ); }
public void mixedElement( String elementName ) { if( contentModel==null ) // assertion failed. contentModel must be prepared by startContentModel method. throw new Error(); contentModel = grammar.pool.createChoice( contentModel, grammar.namedPatterns.getOrCreate(elementName) ); }
public void onChoice(ChoiceExp exp) { exp.exp1.visit(this); Expression content1 = content; Expression continuation1 = continuation; exp.exp2.visit(this); content = pool.createChoice(content, content1); continuation = pool.createChoice(continuation, continuation1); } public void onSequence(SequenceExp exp) {
private Expression choiceOfExported( ReferenceContainer con ) { Iterator itr = con.iterator(); Expression r = Expression.nullSet; while( itr.hasNext() ) { Exportable ex= (Exportable)itr.next(); if( ex.isExported() ) r = pool.createChoice(r,(Expression)ex); } return r; }
public Expression onChoice( ChoiceExp exp ) { // if( isAttributeFree(exp) ) return Expression.nullSet; return pool.createChoice( exp.exp1.visit(this), exp.exp2.visit(this) ); } public Expression onElement( ElementExp exp ) {
public Expression onChoice( ChoiceExp exp ) { Expression np1 = exp.exp1.visit(this); Expression np2 = exp.exp2.visit(this); if(exp.exp1==np1 && exp.exp2==np2) return exp; else return pool.createChoice(np1,np2); } public Expression onOneOrMore( OneOrMoreExp exp ) {
/** compute the residual */ public final Expression calcResidual( Expression exp, Token token ) { if( token instanceof ElementToken ) return calcResidual(exp,(ElementToken)token); this.token=token; Expression r = exp.visit(this); // if token is ignorable, make expression as so. if( token.isIgnorable() ) r = pool.createChoice(r,exp); return r; }
public boolean match( AttributeExp exp ) { // Attribute name must meet the constraint of NameClass if(!exp.nameClass.accepts(namespaceURI,localName)) return false; // content model of the attribute must consume the value if(!docDecl.resCalc.calcResidual(exp.exp, value).isEpsilonReducible()) failedExp = docDecl.pool.createChoice( failedExp, exp.exp ); // accept AttributeExp regardless of its content restriction return true; }
public boolean match( AttributeExp exp ) { // Attribute name must meet the constraint of NameClass if(!exp.nameClass.accepts(namespaceURI,localName)) return false; // content model of the attribute must consume the value if(!docDecl.resCalc.calcResidual(exp.exp, value).isEpsilonReducible()) failedExp = docDecl.pool.createChoice( failedExp, exp.exp ); // accept AttributeExp regardless of its content restriction return true; }
public Expression onInterleave( InterleaveExp exp ) { return pool.createChoice( pool.createInterleave( exp.exp1.visit(this), exp.exp2 ), pool.createInterleave( exp.exp1, exp.exp2.visit(this) ) ); }
public Expression onSequence( SequenceExp exp ) { // if( isAttributeFree(exp) ) return Expression.nullSet; // for attributes only, sequence acts as orderless return pool.createChoice( pool.createSequence( exp.exp1.visit(this), exp.exp2 ), pool.createSequence( exp.exp1, exp.exp2.visit(this) ) ); } public Expression onData( DataExp exp ) {
public Expression onInterleave( InterleaveExp exp ) { return pool.createChoice( pool.createInterleave( exp.exp1.visit(this), exp.exp2 ), pool.createInterleave( exp.exp1, exp.exp2.visit(this) ) ); } }
public Expression onSequence( SequenceExp exp ) { // if( isAttributeFree(exp) ) return Expression.nullSet; // for attributes only, sequence acts as orderless return pool.createChoice( pool.createSequence( exp.exp1.visit(this), exp.exp2 ), pool.createSequence( exp.exp1, exp.exp2.visit(this) ) ); } public Expression onData( DataExp exp ) {