Example #1
0
        public override Verb CreateVerb(string[] tokens)
        {
            Color(position, tokens[1].Length, Whitespaces);
            var fromSource = tokens[2];

            Color(fromSource.Length, Numbers);
            Color(1, Structures);
            var toSource = tokens[3];

            Color(toSource.Length, Numbers);

            var from = fromSource.ToInt();
            var to   = toSource.ToInt();

            var parser = new PatternParser
            {
                IgnoreReplacement = true
            };

            if (parser.Scan(source, position + length - 1))
            {
                var newPattern = (Pattern)parser.Result.Value;
                Element          = new RangeElement(from, to, newPattern);
                overridePosition = parser.Result.Position;
                return(new NullOp());
            }
            return(null);
        }
Example #2
0
        public override Verb CreateVerb(string[] tokens)
        {
            var tokens0Length = tokens[0].Length;
            var index         = position + tokens0Length;
            var parser        = new PatternParser();

            if (parser.Scan(source, index))
            {
                var delimiterPattern = (Pattern)parser.Result.Value;
                index = parser.Result.Position;
                if (parser.Scan(source, index))
                {
                    var mainPattern = (Pattern)parser.Result.Value;
                    overridePosition = parser.Result.Position;
                    Element          = new ListElement(delimiterPattern, mainPattern);
                    Color(position, tokens0Length, Operators);
                    return(new NullOp());
                }
            }
            return(null);
        }
Example #3
0
        public override Verb CreateVerb(string[] tokens)
        {
            Color(position, length, Operators);
            var parser = new PatternParser
            {
                IgnoreReplacement = true
            };

            if (parser.Scan(source, position + length))
            {
                var subPattern = (Pattern)parser.Result.Value;
                Element          = new ArbNoElement(subPattern);
                overridePosition = parser.Result.Position;
                return(new NullOp());
            }
            return(null);
        }
Example #4
0
        public override Verb CreateVerb(string[] tokens)
        {
            Color(position, tokens[1].Length, Whitespaces);
            var countSource = tokens[2];

            Color(countSource.Length, Numbers);

            var count = countSource.ToInt();

            var parser = new PatternParser
            {
                IgnoreReplacement = true
            };

            if (parser.Scan(source, NextPosition - 1))
            {
                var newPattern = (Pattern)parser.Result.Value;
                Element          = new CountElement(count, newPattern);
                overridePosition = parser.Result.Position;
                return(new NullOp());
            }
            return(null);
        }