Пример #1
0
        public override RevRegExData VisitRangeStartEnd(RevRegExParser.RangeStartEndContext context)
        {
            var start = (Visit(context.startchar) as RevRegExDataChar).Value;
            var end   = (Visit(context.endchar) as RevRegExDataChar).Value;

            if (start > end)
            {
                var tmp = start;
                start = end;
                end   = tmp;
            }
            var chars = new List <RevRegExDataChar>();

            for (var ch = start; ch <= end; ++ch)
            {
                chars.Add(new RevRegExDataChar(ch));
            }
            return(RevRegExDataJoin.Create(chars));
        }
Пример #2
0
        public override RevRegExData VisitRange(RevRegExParser.RangeContext context)
        {
            var list = new List <RevRegExDataChar>();

            if (context.HYPHEN() != null)
            {
                list.Add(new RevRegExDataChar('-'));
            }
            foreach (var item in context.rangeItem().Select(item => Visit(item)))
            {
                if (item is RevRegExDataChar)
                {
                    list.Add(item as RevRegExDataChar);
                }
                if (item is RevRegExDataJoin)
                {
                    list.AddRange((item as RevRegExDataJoin).List.Cast <RevRegExDataChar>());
                }
            }
            return(RevRegExDataJoin.Create(list));
        }
Пример #3
0
 public override RevRegExData VisitItems(RevRegExParser.ItemsContext context) => RevRegExDataJoin.Create(context.itemsList().Select(item => Visit(item)).ToList());