public RegexNodeAlternation(RegexNode expression1, RegexNode expression2)
 {
     if (expression1 == null || expression2 == null)
     {
         throw new ArgumentNullException(string.Empty, "Expressions cannot be null");
     }
     expressions = new[] { expression1, expression2 };
 }
Ejemplo n.º 2
0
        public static RegexNode Add(RegexNode node1, RegexNode node2)
        {
            if (node1 == null || node2 == null)
            {
                throw new ArgumentException("Both nodes must be not null.");
            }

            RegexNodeConcatenation node1AsConcatenation = node1 as RegexNodeConcatenation;
            RegexNodeConcatenation node2AsConcatenation = node2 as RegexNodeConcatenation;

            if (node1AsConcatenation != null && node2AsConcatenation != null)
            {
                List <RegexNode> newChildNodes = new List <RegexNode>();
                newChildNodes.AddRange(node1AsConcatenation.ChildNodes);
                newChildNodes.AddRange(node2AsConcatenation.ChildNodes);

                RegexNodeConcatenation result = new RegexNodeConcatenation(newChildNodes);
                return(result);
            }

            if (node1AsConcatenation != null)
            {
                List <RegexNode> newChildNodes = new List <RegexNode>(node1AsConcatenation.ChildNodes);
                newChildNodes.Add(node2);

                RegexNodeConcatenation result = new RegexNodeConcatenation(newChildNodes);
                return(result);
            }

            if (node2AsConcatenation != null)
            {
                List <RegexNode> newChildNodes = new List <RegexNode>();
                newChildNodes.Add(node1);
                newChildNodes.AddRange(node2AsConcatenation.ChildNodes);

                RegexNodeConcatenation result = new RegexNodeConcatenation(newChildNodes);
                return(result);
            }

            return(new RegexNodeConcatenation(node1, node2));
        }
Ejemplo n.º 3
0
        public static RegexNode Add(RegexNode node1, RegexNode node2)
        {
            if (node1 == null || node2 == null)
            {
                throw new ArgumentException("Both nodes must be not null.");
            }

            RegexNodeConcatenation node1AsConcatenation = node1 as RegexNodeConcatenation;
            RegexNodeConcatenation node2AsConcatenation = node2 as RegexNodeConcatenation;

            if (node1AsConcatenation != null && node2AsConcatenation != null)
            {
                List<RegexNode> newChildNodes = new List<RegexNode>();
                newChildNodes.AddRange(node1AsConcatenation.ChildNodes);
                newChildNodes.AddRange(node2AsConcatenation.ChildNodes);

                RegexNodeConcatenation result = new RegexNodeConcatenation(newChildNodes);
                return result;
            }

            if (node1AsConcatenation != null)
            {
                List<RegexNode> newChildNodes = new List<RegexNode>(node1AsConcatenation.ChildNodes);
                newChildNodes.Add(node2);

                RegexNodeConcatenation result = new RegexNodeConcatenation(newChildNodes);
                return result;
            }

            if (node2AsConcatenation != null)
            {
                List<RegexNode> newChildNodes = new List<RegexNode>();
                newChildNodes.Add(node1);
                newChildNodes.AddRange(node2AsConcatenation.ChildNodes);

                RegexNodeConcatenation result = new RegexNodeConcatenation(newChildNodes);
                return result;
            }

            return new RegexNodeConcatenation(node1, node2);
        }
 public RegexNodeConditionalMatch(string conditionGroupName, RegexNode trueMatchExpression, RegexNode falseMatchExpression)
 {
     ConditionGroupName = conditionGroupName;
     TrueMatchExpression = trueMatchExpression;
     FalseMatchExpression = falseMatchExpression;
 }
Ejemplo n.º 5
0
 public RegexNodeBacktrackingSuppression(RegexNode innerExpression)
 {
     InnerExpression = innerExpression;
 }
Ejemplo n.º 6
0
 public RegexNodeGroup(RegexNode innerExpression, bool isCapturing)
 {
     InnerExpression = innerExpression;
     IsCapturing     = isCapturing;
 }
Ejemplo n.º 7
0
 public RegexNodeInlineOption(RegexOptions options, RegexNode innerExpression)
 {
     Options         = options;
     InnerExpression = innerExpression;
 }
 public RegexNodeConditionalMatch(string conditionGroupName, RegexNode trueMatchExpression, RegexNode falseMatchExpression)
 {
     ConditionGroupName   = conditionGroupName;
     TrueMatchExpression  = trueMatchExpression;
     FalseMatchExpression = falseMatchExpression;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Concatenates four nodes.
 /// </summary>
 /// <param name="node1">First node.</param>
 /// <param name="node2">Second node.</param>
 /// <param name="node3">Third node.</param>
 /// <param name="node4">Fourth node.</param>
 /// <param name="quantifier">Node quantifier.</param>
 /// <returns>An instance of RegexNode representing the concatenation of child nodes.</returns>
 public static RegexNodeConcatenation Concatenate(RegexNode node1, RegexNode node2, RegexNode node3, RegexNode node4, RegexQuantifier quantifier)
 {
     return(Concatenate(new[] { node1, node2, node3, node4 }, quantifier));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Generates a conditional match expression which uses a named group for condition evaluation ("(?(GroupName)|(true)|(false))").
 /// </summary>
 /// <param name="conditionGroupName">The name of the group to be used as a condition.</param>
 /// <param name="trueMatchExpression">True match expression.</param>
 /// <param name="falseMatchExpression">False match expression.</param>
 /// <param name="quantifier">Node quantifier.</param>
 /// <returns>An instance of RegexNode containing the conditional match expression.</returns>
 public static RegexNodeConditionalMatch ConditionalMatch(string conditionGroupName, RegexNode trueMatchExpression, RegexNode falseMatchExpression, RegexQuantifier quantifier)
 {
     return(new RegexNodeConditionalMatch(conditionGroupName, trueMatchExpression, falseMatchExpression)
     {
         Quantifier = quantifier
     });
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Generates a zero-width positive lookahead assertion ("match(?=lookahead)").
 /// </summary>
 /// <param name="lookupExpression">Lookahead expression.</param>
 /// <param name="matchExpression">Match expression.</param>
 /// <param name="quantifier">Node quantifier.</param>
 /// <returns>An instance of RegexNode containing the positive lookahead assertion.</returns>
 public static RegexNodeLookAround PositiveLookAhead(RegexNode lookupExpression, RegexNode matchExpression, RegexQuantifier quantifier)
 {
     return(new RegexNodeLookAround(RegexLookAround.PositiveLookAhead, lookupExpression, matchExpression)
     {
         Quantifier = quantifier
     });
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Generates a zero-width positive lookahead assertion ("match(?=lookahead)").
 /// </summary>
 /// <param name="lookupExpression">Lookahead expression.</param>
 /// <param name="matchExpression">Match expression.</param>
 /// <returns>An instance of RegexNode containing the positive lookahead assertion.</returns>
 public static RegexNodeLookAround PositiveLookAhead(RegexNode lookupExpression, RegexNode matchExpression)
 {
     return(new RegexNodeLookAround(RegexLookAround.PositiveLookAhead, lookupExpression, matchExpression));
 }
 public RegexNodeBacktrackingSuppression(RegexNode innerExpression)
 {
     InnerExpression = innerExpression;
 }
Ejemplo n.º 14
0
 public RegexNodeLookAround(RegexLookAround lookAroundType, RegexNode lookAroundExpression, RegexNode matchExpression)
 {
     LookAroundType       = lookAroundType;
     LookAroundExpression = lookAroundExpression;
     MatchExpression      = matchExpression;
 }
Ejemplo n.º 15
0
 public RegexNodeGroup(RegexNode innerExpression, string name)
 {
     InnerExpression = innerExpression;
     IsCapturing = true;
     Name = name;
 }
Ejemplo n.º 16
0
 public RegexNodeGroup(RegexNode innerExpression, bool isCapturing)
 {
     InnerExpression = innerExpression;
     IsCapturing = isCapturing;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Generates a conditional match expression ("(?(condition)|(true)|(false))").
 /// </summary>
 /// <param name="conditionExpression">Condition expression.</param>
 /// <param name="trueMatchExpression">True match expression.</param>
 /// <param name="falseMatchExpression">False match expression.</param>
 /// <param name="quantifier">Node quantifier.</param>
 /// <returns>An instance of RegexNode containing the conditional match expression.</returns>
 public static RegexNodeConditionalMatch ConditionalMatch(RegexNode conditionExpression, RegexNode trueMatchExpression, RegexNode falseMatchExpression, RegexQuantifier quantifier)
 {
     return(new RegexNodeConditionalMatch(conditionExpression, trueMatchExpression, falseMatchExpression)
     {
         Quantifier = quantifier
     });
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Generates a zero-width negative lookbehind assertion ("(?&lt;!lookbehind)match").
 /// </summary>
 /// <param name="lookupExpression">Lookbehind expression.</param>
 /// <param name="matchExpression">Match expression.</param>
 /// <returns>An instance of RegexNode containing the negative lookbehind assertion.</returns>
 public static RegexNodeLookAround NegativeLookBehind(RegexNode lookupExpression, RegexNode matchExpression)
 {
     return(new RegexNodeLookAround(RegexLookAround.NegativeLookBehind, lookupExpression, matchExpression));
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Concatenates four nodes.
 /// </summary>
 /// <param name="node1">First node.</param>
 /// <param name="node2">Second node.</param>
 /// <param name="node3">Third node.</param>
 /// <param name="node4">Fourth node.</param>
 /// <returns>An instance of RegexNode representing the concatenation of child nodes.</returns>
 public static RegexNodeConcatenation Concatenate(RegexNode node1, RegexNode node2, RegexNode node3, RegexNode node4)
 {
     return(Concatenate(new[] { node1, node2, node3, node4 }));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Generates a zero-width negative lookbehind assertion ("(?&lt;!lookbehind)match").
 /// </summary>
 /// <param name="lookupExpression">Lookbehind expression.</param>
 /// <param name="matchExpression">Match expression.</param>
 /// <param name="quantifier">Node quantifier.</param>
 /// <returns>An instance of RegexNode containing the negative lookbehind assertion.</returns>
 public static RegexNodeLookAround NegativeLookBehind(RegexNode lookupExpression, RegexNode matchExpression, RegexQuantifier quantifier)
 {
     return(new RegexNodeLookAround(RegexLookAround.NegativeLookBehind, lookupExpression, matchExpression)
     {
         Quantifier = quantifier
     });
 }
 public RegexNodeConditionalMatch(RegexNode conditionExpression, RegexNode trueMatchExpression, RegexNode falseMatchExpression)
 {
     ConditionExpression  = conditionExpression;
     TrueMatchExpression  = trueMatchExpression;
     FalseMatchExpression = falseMatchExpression;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Generates an unnamed capturing group with the specified subexpression.
 /// </summary>
 /// <param name="matchExpression">Inner expression.</param>
 /// <returns>An instance of RegexNode containing the unnamed capturing group.</returns>
 public static RegexNodeGroup Group(RegexNode matchExpression)
 {
     return(new RegexNodeGroup(matchExpression));
 }
Ejemplo n.º 23
0
 public RegexNodeLookAround(RegexLookAround lookAroundType, RegexNode lookAroundExpression, RegexNode matchExpression)
 {
     LookAroundType = lookAroundType;
     LookAroundExpression = lookAroundExpression;
     MatchExpression = matchExpression;
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Generates a named capturing group with the specified subexpression.
 /// </summary>
 /// <param name="groupName">Group name.</param>
 /// <param name="matchExpression">Inner expression.</param>
 /// <returns>An instance of RegexNode containing the named capturing group.</returns>
 public static RegexNodeGroup Group(string groupName, RegexNode matchExpression)
 {
     return(new RegexNodeGroup(matchExpression, groupName));
 }
Ejemplo n.º 25
0
 public RegexNodeGroup(RegexNode innerExpression)
 {
     InnerExpression = innerExpression;
     IsCapturing     = true;
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Generates a non-capturing group with the specified subexpression.
 /// </summary>
 /// <param name="matchExpression">Inner expression.</param>
 /// <returns>An instance of RegexNode containing the non-capturing group.</returns>
 public static RegexNodeGroup NonCapturingGroup(RegexNode matchExpression)
 {
     return(new RegexNodeGroup(matchExpression, false));
 }
Ejemplo n.º 27
0
 public RegexNodeGroup(RegexNode innerExpression, string name)
 {
     InnerExpression = innerExpression;
     IsCapturing     = true;
     Name            = name;
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Generates a subexpression with disabled backtracking ("(?&gt;expression)").
 /// </summary>
 /// <param name="innerExpression">Inner expression.</param>
 /// <returns>An instance of RegexNode containing the expression with suppressed backtracking.</returns>
 public static RegexNodeBacktrackingSuppression BacktrackingSuppression(RegexNode innerExpression)
 {
     return(new RegexNodeBacktrackingSuppression(innerExpression));
 }
 public RegexNodeConditionalMatch(RegexNode conditionExpression, RegexNode trueMatchExpression, RegexNode falseMatchExpression)
 {
     ConditionExpression = conditionExpression;
     TrueMatchExpression = trueMatchExpression;
     FalseMatchExpression = falseMatchExpression;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Generates an alternation expression with two options ("a|b").
 /// </summary>
 /// <param name="expression1">First option.</param>
 /// <param name="expression2">Second option.</param>
 /// <returns>An instance of RegexNode containing the alternation expression.</returns>
 public static RegexNodeAlternation Alternate(RegexNode expression1, RegexNode expression2)
 {
     return(new RegexNodeAlternation(expression1, expression2));
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Generates a conditional match expression ("(?(condition)|(true)|(false))").
 /// </summary>
 /// <param name="conditionExpression">Condition expression.</param>
 /// <param name="trueMatchExpression">True match expression.</param>
 /// <param name="falseMatchExpression">False match expression.</param>
 /// <returns>An instance of RegexNode containing the conditional match expression.</returns>
 public static RegexNodeConditionalMatch ConditionalMatch(RegexNode conditionExpression, RegexNode trueMatchExpression, RegexNode falseMatchExpression)
 {
     return(new RegexNodeConditionalMatch(conditionExpression, trueMatchExpression, falseMatchExpression));
 }
Ejemplo n.º 32
0
 public RegexNodeGroup(RegexNode innerExpression)
 {
     InnerExpression = innerExpression;
     IsCapturing = true;
 }