Exemplo n.º 1
0
        /// <summary>
        /// Creates a balanced group.
        /// </summary>
        /// <param name="current">The name to store the result in.</param>
        /// <param name="previous">The starting group name to replace.</param>
        /// <param name="options">The sub-expressions appearing in the group.</param>
        /// <param name="options">The balance group options to use -or- null, if no options are provided.</param>
        /// <returns>The balance group.</returns>
        public static IBalancedGroup From(string current, string previous, BalanceGroupOptions options, IEnumerable <IExpression> members)
        {
            if (String.IsNullOrWhiteSpace(current))
            {
                current = null;
            }
            ValidateCaptureGroupName(nameof(current), current);
            if (String.IsNullOrWhiteSpace(previous))
            {
                throw new ArgumentException(Resources.PreviousGroupNameBlank, nameof(previous));
            }
            ValidateCaptureGroupName(nameof(previous), previous);
            var group = new BalancedGroup()
            {
                Current   = current,
                Previous  = previous,
                UseQuotes = options?.UseQuotes ?? false
            };

            foreach (var member in members)
            {
                group.Add(member);
            }
            return(group);
        }
Exemplo n.º 2
0
            private IGroup ParseCaptureGroupOrBalanceGroup(string name, bool useQuotes)
            {
                var names = name.Split(new[] { '-' }, 2);

                if (names.Length == 1)
                {
                    return(ParseCaptureGroup(name, useQuotes));
                }
                var(current, previous) = (names[0], names[1]);
                RegisterGroupName(current);
                var options = new BalanceGroupOptions()
                {
                    UseQuotes = useQuotes
                };
                var item = Parse();

                return(BalancedGroup.Of(current, previous, options, item));
            }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a balanced group.
 /// </summary>
 /// <param name="current">The name to store the result in.</param>
 /// <param name="previous">The starting group name to replace.</param>
 /// <param name="members">The sub-expressions appearing in the group.</param>
 /// <param name="options">The balance group options to use -or- null, if no options are provided.</param>
 /// <returns>The balance group.</returns>
 public static IBalancedGroup Of(string current, string previous, BalanceGroupOptions options, params IExpression[] members)
 {
     return(From(current, previous, options, members));
 }