public NodeRegex(string re, string description, NodeRegexFlags flags, int?layoutSliceBegin, int?layoutSliceEnd) { if (re == null) { throw new ArgumentNullException("re"); } Regex = re; NodeDescription = description; Flags = flags; LayoutSliceBegin = layoutSliceBegin; LayoutSliceEnd = layoutSliceEnd; WrapperThatMakesRegexNotSpecific = null; WrapperThatMakesRegexConditional = null; DateTimeFormat = null; DateTimeCulture = null; if (Regex == NotSpecificRegexp) { Flags |= NodeRegexFlags.IsNotSpecific; } StringLiteral = null; }
private static NodeRegex GetDateNodeRegex(Syntax.Node dateRenderer, NodeRegexContext ctx) { var format = GetParamValue(dateRenderer, "format").FirstOrDefault(); if (string.IsNullOrEmpty(format)) { format = "G"; } var dateCulture = GetRendererCulture(dateRenderer); var parserFormat = DateTimeFormatParsing.ParseDateTimeFormat(format, dateCulture, new FormatParsing_RegexBuilderHook() { ctx = ctx }); NodeRegexFlags reFlags = NodeRegexFlags.None; var fillDateMask = DateTimeFormatParsing.DateTimeFormatFlag.ContainsYear | DateTimeFormatParsing.DateTimeFormatFlag.ContainsMonth | DateTimeFormatParsing.DateTimeFormatFlag.ContainsDay; if ((parserFormat.Flags & fillDateMask) == fillDateMask) { reFlags |= NodeRegexFlags.RepresentsDate; } var fillTimeMask = DateTimeFormatParsing.DateTimeFormatFlag.ContainsHour; if ((parserFormat.Flags & fillTimeMask) == fillTimeMask) { reFlags |= NodeRegexFlags.RepresentsTime; } if ((reFlags & NodeRegexFlags.RepresentsDateOrTime) == 0) { reFlags |= NodeRegexFlags.IsIgnorable; } return(new NodeRegex(parserFormat.Regex, dateRenderer.Description, reFlags, dateRenderer.NodeStart, dateRenderer.NodeEnd) { DateTimeFormat = format, DateTimeCulture = dateCulture.Name }); }