Ejemplo n.º 1
0
        private ITokenV2[] CreateInner(string s)
        {
            var innerRemaining = this.InnerString;
            var innerTokens    = new List <ITokenV2>();

            while (innerRemaining.Length > 0)
            {
                if (!MarkerTokenV2.AtBeginningOf(innerRemaining))
                {
                    var normal = new NormalTokenV2(innerRemaining);
                    innerTokens.Add(normal);

                    innerRemaining = normal.Remaining;
                }
                else
                {
                    var marker = new MarkerTokenV2(innerRemaining);
                    innerTokens.Add(marker);

                    innerRemaining = marker.Remaining;
                }
            }

            return(innerTokens.ToArray());
        }
Ejemplo n.º 2
0
        private ITokenV2 CreateNextToken(string s)
        {
            if (MarkerTokenV2.AtBeginningOf(s))
            {
                return(new MarkerTokenV2(s));
            }

            return(new NormalTokenV2(s));
        }
Ejemplo n.º 3
0
        public MarkerTokenV2(string s)
        {
            if (!MarkerTokenV2.AtBeginningOf(s))
            {
                throw new ArgumentException("Marker must be at the beginning of the string");
            }

            var marker = markerPattern.Match(s);

            var parts = marker.Value.Replace("(", "").Replace(")", "").Split(new string[] { "x" }, StringSplitOptions.RemoveEmptyEntries);

            this.Take   = Int32.Parse(parts[0]);
            this.Repeat = Int32.Parse(parts[1]);

            this.InnerString = s.Substring(marker.Length, this.Take);

            this.Remaining = s.Substring(marker.Index + marker.Length + this.Take,
                                         s.Length - (marker.Index + marker.Length + this.Take));
        }