Esempio n. 1
0
            public override State Expand( AttributesSet attributes, State result )
            {
                if( result.Contains(this) )   return result;  // no need to expand more

                if( IsPersistent )
                    result = MakeChoice( result, this );

                for( Transition.Att aa = aTr; aa!=null; aa=aa.Next ) {
                    int matchCount=0,failCount=0;

                    for( int j=attributes.Count-1; j>=0; j-- ) {

                        int nameCode = attributes.GetName(j);

                        if( aa.Accepts(nameCode) ) {
                            string value = attributes.GetValue(j);

                            State s = aa.Left;
                            s = s.Text( value, attributes.Context, AttributesSet.empty, emptySet );

                            if( s.IsFinal )		matchCount++;
                            else				failCount++;
                        }
                    }

                    if( (matchCount==1 && failCount==0 && !aa.Repeated)
                    ||  (matchCount!=0 && failCount==0 && aa.Repeated) )
                        result = aa.Right.Expand( attributes, result );
                }

                for( Transition.NoAtt nea = nTr; nea!=null; nea=nea.Next ) {

                    int j;
                    for( j=attributes.Count-1; j>=0; j-- ) {
                        int nc = attributes.GetName(j);
                        if( nea.Accepts(nc) )
                            // this attribute is prohibited.
                            break;
                    }
                    if(j==-1)
                        result = nea.Right.Expand( attributes, result );
                }

                for( Transition.Interleave ia = iTr; ia!=null; ia=ia.Next ) {
                    result = MakeChoice( result, MakeInterleave(
                        ia.Left. Expand( attributes, emptySet ),
                        ia.Right.Expand( attributes, emptySet ),
                        ia ));
                }

                return result;
            }