Beispiel #1
0
 public XmlTokenStateTransition(ITokenState from,
                                ITokenState to,
                                ITokenPatternMatch match)
     :
     base(from, to, match)
 {
 }
 protected TokenStateTransition(ITokenState from,
                                ITokenState to,
                                ITokenPatternMatch match)
 {
     this.From  = from;
     this.To    = to;
     this.Match = match;
 }
Beispiel #3
0
        protected ITokenStateTransition?GetNextTransition(ITokenStateTransition?previousTransition,
                                                          ITokenPatternMatch nextTransitionMatch,
                                                          ref long position)
        {
            ITokenStateTransition?result = null;

            position = nextTransitionMatch.EndIndex;

            ITokenPattern pattern = nextTransitionMatch.Pattern;

            if (XmlTokenPatterns.BeginOfMessage.Equals(pattern) == true)
            {
                result = new XmlTokenStateTransition(this,
                                                     XmlTokenStates.WithinMessage,
                                                     nextTransitionMatch);
            }
            else if (XmlTokenPatterns.EndOfMessage.Equals(pattern) == true)
            {
                if (previousTransition is not null)
                {
                    result = new XmlTokenStateTransition(this,
                                                         previousTransition.From,
                                                         nextTransitionMatch);
                }
            }
            else if (XmlTokenPatterns.BeginOfData.Equals(pattern) == true)
            {
                result = new XmlTokenStateTransition(this,
                                                     XmlTokenStates.WithinData,
                                                     nextTransitionMatch);
            }
            else if (XmlTokenPatterns.EndOfData.Equals(pattern) == true)
            {
                if (previousTransition is not null)
                {
                    result = new XmlTokenStateTransition(this,
                                                         previousTransition.From,
                                                         nextTransitionMatch);
                }
            }
            else
            {
                throw Assert.Exception(new ArgumentException($"Unknown token pattern in match '{ nextTransitionMatch.Pattern }'.", nameof(nextTransitionMatch)));
            }

            return(result);
        }
Beispiel #4
0
        protected ITokenStateTransition? GetNextTransition( ITokenStateTransition? previousTransition,
                                                            ITokenPatternMatch nextTransitionMatch,
                                                            ref long position   )
        {
            ITokenStateTransition? result = null;

            position = nextTransitionMatch.EndIndex;

            ITokenPattern pattern = nextTransitionMatch.Pattern;

            if( JsonTokenPatterns.BeginOfObject.Equals( pattern ) == true )
            {
                result = new JsonTokenStateTransition(  this,
                                                        JsonTokenStates.WithinObject,
                                                        nextTransitionMatch   );
            }else if( JsonTokenPatterns.EndOfObject.Equals( pattern ) == true )
            {
                if( previousTransition is not null )
                {
                    result = new JsonTokenStateTransition(  this,
                                                            previousTransition.From,
                                                            nextTransitionMatch   );
                }
            }else if( JsonTokenPatterns.BeginOfString.Equals( pattern ) == true )
            {
                result = new JsonTokenStateTransition(  this,
                                                        JsonTokenStates.WithinString,
                                                        nextTransitionMatch   );
            }else if( JsonTokenPatterns.EndOfString.Equals( pattern ) == true )
            {
                if( previousTransition is not null )
                {
                    result = new JsonTokenStateTransition(  this,
                                                            previousTransition.From,
                                                            nextTransitionMatch   );
                }
            }else
            {
                throw Assert.Exception( new ArgumentException( $"Unknown token pattern in match '{ nextTransitionMatch.Pattern }'.", nameof( nextTransitionMatch ) ) );
            }

            return result;
        }