protected void onElementFound( ElementExp elem ) { // root element if( namespaces.includes(elem.getNameClass()) ) { // add this element this.exp = pool.createChoice( this.exp, elem ); } }
public Expression onAttribute(AttributeExp exp) { Expression content = exp.exp.visit(this); if (content == Expression.nullSet) { return Expression.nullSet; // this attribute is not allowed } return pool.createAttribute(exp.nameClass, content, exp.getDefaultValue()); } public Expression onRef(ReferenceExp exp) {
public void onOneOrMore(OneOrMoreExp exp) { exp.exp.visit(this); continuation = pool.createSequence(continuation, pool.createZeroOrMore(exp.exp)); } public void onMixed(MixedExp 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 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) {
public Expression onAttribute(AttributeExp exp) { Expression content = exp.exp.visit(this); if (content == Expression.nullSet) return Expression.nullSet; // this attribute is not allowed else return pool.createAttribute(exp.nameClass, content); }
public final Expression createInterleave( Expression left, Expression right ) { if( left == Expression.epsilon ) return right; if( right== Expression.epsilon ) return left; if( left == Expression.nullSet || right== Expression.nullSet ) return Expression.nullSet; // associative operators are grouped to the left if( right instanceof InterleaveExp ) { final InterleaveExp i = (InterleaveExp)right; return createInterleave( createInterleave(left, i.exp1), i.exp2 ); } return unify(new InterleaveExp(left,right)); }
public Expression onConcur( ConcurExp exp ) { return pool.createConcur( exp.exp1.visit(this), exp.exp2.visit(this)); } public Expression onInterleave( InterleaveExp exp ) {
public Expression onList( ListExp exp ) { Expression body = exp.exp.visit(this); if(exp.exp==body) return exp; else return pool.createList( body ); } public Expression onSequence( SequenceExp exp ) {
public Expression onMixed( MixedExp exp ) { Expression body = exp.exp.visit(this); if(exp.exp==body) return exp; else return pool.createMixed( body ); } public Expression onList( ListExp exp ) {
public final Expression createOneOrMore( Expression child ) { if( child == Expression.epsilon || child == Expression.anyString || child == Expression.nullSet || child instanceof OneOrMoreExp ) return child; return unify(new OneOrMoreExp(child)); }
public Expression onOneOrMore( OneOrMoreExp exp ) { // if( isAttributeFree(exp) ) return Expression.nullSet; return pool.createSequence( exp.exp.visit(this), pool.createZeroOrMore(exp.exp) ); } public Expression onMixed( MixedExp 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 ) {
public void onConcur(ConcurExp exp) { foundConcur = true; exp.exp1.visit(this); Expression content1 = content; Expression continuation1 = continuation; exp.exp2.visit(this); content = pool.createConcur(content, content1); continuation = pool.createConcur(continuation, continuation1); }
public final Expression createOneOrMore( Expression child ) { if( child == Expression.epsilon || child == Expression.anyString || child == Expression.nullSet || child instanceof OneOrMoreExp ) return child; return unify(new OneOrMoreExp(child)); }
public Expression onOneOrMore( OneOrMoreExp exp ) { // if( isAttributeFree(exp) ) return Expression.nullSet; return pool.createSequence( exp.exp.visit(this), pool.createZeroOrMore(exp.exp) ); } public Expression onMixed( MixedExp exp ) {
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 onOneOrMore( OneOrMoreExp exp ) { return pool.createSequence( exp.exp.visit(this), pool.createZeroOrMore(exp.exp) ); } public Expression onMixed( MixedExp exp ) {