Beispiel #1
0
        private ClassExpression Class(INode node)
        {
            Debug.Assert(node.Name == "class" && node.Count == 2);

            var invert = node[0].Count == 1;
            var ranges = node[1].Children.Select(SingleOrRange).ToArray();

            return(ClassExpression.From(node, invert, ranges));
        }
Beispiel #2
0
            private static ClassExpression Class(INode node)
            {
                var parts = new List <ClassPartExpression>();

                foreach (var part in node.Children.Skip(1))
                {
                    switch (part.Name)
                    {
                    case "range":
                        parts.Add(ClassRangeExpression.From(part,
                                                            Char.ConvertToUtf32(DecodeChar(part[0]), 0),
                                                            Char.ConvertToUtf32(DecodeChar(part[1]), 0)));
                        break;

                    default:
                        parts.Add(ClassCharExpression.From(part, Char.ConvertToUtf32(DecodeChar(part), 0)));
                        break;
                    }
                }

                return(ClassExpression.From(node, node[0].Count != 0, parts));
            }