Ejemplo n.º 1
0
        private bool CheckLookahead(RegexBuffer buffer)
        {
            Match match = new Regex("\r\n\t\t\t\t        ^                         # anchor to start of string\r\n\t\t\t\t\t\t\\?\r\n\t\t\t\t\t\t(?<Assertion><=|<!|=|!)   # assertion char\r\n\t\t\t\t\t\t(?<Rest>.+)               # The rest of the expression\r\n\t\t\t\t\t\t", RegexOptions.IgnorePatternWhitespace).Match(buffer.String);

            if (!match.Success)
            {
                return(false);
            }
            switch (match.Groups["Assertion"].Value)
            {
            case "=":
                this.description = "zero-width positive lookahead";
                break;

            case "!":
                this.description = "zero-width negative lookahead";
                break;

            case "<=":
                this.description = "zero-width positive lookbehind";
                break;

            case "<!":
                this.description = "zero-width negative lookbehind";
                break;
            }
            buffer.Offset  += match.Groups["Rest"].Index;
            this.expression = new RegexExpression(buffer);
            this.CheckClosingParen(buffer);
            return(true);
        }
Ejemplo n.º 2
0
 public void AddLookup(RegexItem item, int startLocation, int endLocation, bool canCoalesce)
 {
     if (this.inSeries)
     {
         if (canCoalesce)
         {
             RegexRef ref2 = (RegexRef)this.expressionLookup[this.expressionLookup.Count - 1];
             ref2.StringValue = ref2.StringValue + item.ToString(0);
             ref2.Length     += (endLocation - startLocation) + 1;
         }
         else
         {
             this.expressionLookup.Add(new RegexRef(item, startLocation, endLocation));
             this.inSeries = false;
         }
     }
     else
     {
         if (canCoalesce)
         {
             this.inSeries = true;
         }
         this.expressionLookup.Add(new RegexRef(item, startLocation, endLocation));
     }
 }
Ejemplo n.º 3
0
 private bool HandlePlainOldCapture(RegexBuffer buffer)
 {
     if (buffer.ExplicitCapture)
     {
         this.description = string.Format("Non-capturing Group", new object[0]);
     }
     this.expression = new RegexExpression(buffer);
     this.CheckClosingParen(buffer);
     return(true);
 }
Ejemplo n.º 4
0
        private bool CheckConditional(RegexBuffer buffer)
        {
            Match match = new Regex("\r\n\t\t\t\t        ^                         # anchor to start of string\r\n\t\t\t\t\t\t\\?\\(\r\n\t\t\t\t\t\t(?<Rest>.+)             # The rest of the expression\r\n\t\t\t\t\t\t", RegexOptions.IgnorePatternWhitespace).Match(buffer.String);

            if (match.Success)
            {
                this.description = string.Format("Conditional Subexpression", new object[0]);
                buffer.Offset   += match.Groups["Rest"].Index;
                this.expression  = new RegexConditional(buffer);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 5
0
        private bool CheckBalancedGroup(RegexBuffer buffer)
        {
            Match match = new Regex("\r\n\t\t\t\t        ^                         # anchor to start of string\r\n\t\t\t\t\t\t\\?[\\<|']                  # ?< or ?'\r\n\t\t\t\t\t\t(?<Name1>[a-zA-Z]+?)       # Capture name1\r\n\t\t\t\t\t\t-\r\n\t\t\t\t\t\t(?<Name2>[a-zA-Z]+?)       # Capture name2\r\n\t\t\t\t\t\t[\\>|']                    # ?> or ?'\r\n\t\t\t\t\t\t(?<Rest>.+)               # The rest of the expression\r\n\t\t\t\t\t\t", RegexOptions.IgnorePatternWhitespace).Match(buffer.String);

            if (match.Success)
            {
                this.description = string.Format("Balancing Group <{0}>-<{1}>", match.Groups["Name1"], match.Groups["Name2"]);
                buffer.Offset   += match.Groups["Rest"].Index;
                this.expression  = new RegexExpression(buffer);
                this.CheckClosingParen(buffer);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 6
0
        private bool CheckOptions(RegexBuffer buffer)
        {
            Match match = new Regex("\r\n\t\t\t\t        ^                         # anchor to start of string\r\n\t\t\t\t\t\t\\?(?<Options>[imnsx-]+):\r\n\t\t\t\t\t\t", RegexOptions.IgnorePatternWhitespace).Match(buffer.String);

            if (match.Success)
            {
                string text = match.Groups["Options"].Value;
                this.description = string.Format("Set options to {0}", optionNames[text]);
                this.expression  = null;
                buffer.Offset   += match.Groups[0].Length;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 7
0
        private bool CheckNonCapturing(RegexBuffer buffer)
        {
            Match match = new Regex("\r\n\t\t\t\t        ^                         # anchor to start of string\r\n\t\t\t\t\t\t\\?:\r\n\t\t\t\t\t\t(?<Rest>.+)             # The rest of the expression\r\n\t\t\t\t\t\t", RegexOptions.IgnorePatternWhitespace).Match(buffer.String);

            if (match.Success)
            {
                this.description = string.Format("Non-capturing Group", new object[0]);
                buffer.Offset   += match.Groups["Rest"].Index;
                this.expression  = new RegexExpression(buffer);
                this.CheckClosingParen(buffer);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 8
0
        private bool CheckNamed(RegexBuffer buffer)
        {
            Match match = new Regex("\r\n\t\t\t\t        ^                         # anchor to start of string\r\n\t\t\t\t\t\t\\?(\\<|')                  # ?< or ?'\r\n\t\t\t\t\t\t(?<Name>[a-zA-Z0-9]+?)    # Capture name\r\n\t\t\t\t\t\t(\\>|')                    # ?> or ?'\r\n\t\t\t\t\t\t(?<Rest>.+)               # The rest of the string\r\n\t\t\t\t\t\t", RegexOptions.IgnorePatternWhitespace).Match(buffer.String);

            if (match.Success)
            {
                this.description = string.Format("Capture to <{0}>", match.Groups["Name"]);
                buffer.Offset   += match.Groups["Rest"].Index;
                this.expression  = new RegexExpression(buffer);
                this.CheckClosingParen(buffer);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 9
0
 private bool CheckOptions(RegexBuffer buffer)
 {
     Match match = new Regex("\r\n\t\t\t\t        ^                         # anchor to start of string\r\n\t\t\t\t\t\t\\?(?<Options>[imnsx-]+):\r\n\t\t\t\t\t\t", RegexOptions.IgnorePatternWhitespace).Match(buffer.String);
     if (match.Success)
     {
         string text = match.Groups["Options"].Value;
         this.description = string.Format("Set options to {0}", optionNames[text]);
         this.expression = null;
         buffer.Offset += match.Groups[0].Length;
         return true;
     }
     return false;
 }
Ejemplo n.º 10
0
 private bool CheckNonCapturing(RegexBuffer buffer)
 {
     Match match = new Regex("\r\n\t\t\t\t        ^                         # anchor to start of string\r\n\t\t\t\t\t\t\\?:\r\n\t\t\t\t\t\t(?<Rest>.+)             # The rest of the expression\r\n\t\t\t\t\t\t", RegexOptions.IgnorePatternWhitespace).Match(buffer.String);
     if (match.Success)
     {
         this.description = string.Format("Non-capturing Group", new object[0]);
         buffer.Offset += match.Groups["Rest"].Index;
         this.expression = new RegexExpression(buffer);
         this.CheckClosingParen(buffer);
         return true;
     }
     return false;
 }
Ejemplo n.º 11
0
 private bool CheckNamed(RegexBuffer buffer)
 {
     Match match = new Regex("\r\n\t\t\t\t        ^                         # anchor to start of string\r\n\t\t\t\t\t\t\\?(\\<|')                  # ?< or ?'\r\n\t\t\t\t\t\t(?<Name>[a-zA-Z0-9]+?)    # Capture name\r\n\t\t\t\t\t\t(\\>|')                    # ?> or ?'\r\n\t\t\t\t\t\t(?<Rest>.+)               # The rest of the string\r\n\t\t\t\t\t\t", RegexOptions.IgnorePatternWhitespace).Match(buffer.String);
     if (match.Success)
     {
         this.description = string.Format("Capture to <{0}>", match.Groups["Name"]);
         buffer.Offset += match.Groups["Rest"].Index;
         this.expression = new RegexExpression(buffer);
         this.CheckClosingParen(buffer);
         return true;
     }
     return false;
 }
Ejemplo n.º 12
0
        private bool CheckLookahead(RegexBuffer buffer)
        {
            Match match = new Regex("\r\n\t\t\t\t        ^                         # anchor to start of string\r\n\t\t\t\t\t\t\\?\r\n\t\t\t\t\t\t(?<Assertion><=|<!|=|!)   # assertion char\r\n\t\t\t\t\t\t(?<Rest>.+)               # The rest of the expression\r\n\t\t\t\t\t\t", RegexOptions.IgnorePatternWhitespace).Match(buffer.String);
            if (!match.Success)
            {
                return false;
            }
            switch (match.Groups["Assertion"].Value)
            {
                case "=":
                    this.description = "zero-width positive lookahead";
                    break;

                case "!":
                    this.description = "zero-width negative lookahead";
                    break;

                case "<=":
                    this.description = "zero-width positive lookbehind";
                    break;

                case "<!":
                    this.description = "zero-width negative lookbehind";
                    break;
            }
            buffer.Offset += match.Groups["Rest"].Index;
            this.expression = new RegexExpression(buffer);
            this.CheckClosingParen(buffer);
            return true;
        }
Ejemplo n.º 13
0
 private bool CheckConditional(RegexBuffer buffer)
 {
     Match match = new Regex("\r\n\t\t\t\t        ^                         # anchor to start of string\r\n\t\t\t\t\t\t\\?\\(\r\n\t\t\t\t\t\t(?<Rest>.+)             # The rest of the expression\r\n\t\t\t\t\t\t", RegexOptions.IgnorePatternWhitespace).Match(buffer.String);
     if (match.Success)
     {
         this.description = string.Format("Conditional Subexpression", new object[0]);
         buffer.Offset += match.Groups["Rest"].Index;
         this.expression = new RegexConditional(buffer);
         return true;
     }
     return false;
 }
Ejemplo n.º 14
0
 public RegexRef(RegexItem regexItem, int start, int end)
 {
     this.stringValue = regexItem.ToString(0);
     this.start = start;
     this.end = end;
 }
Ejemplo n.º 15
0
 private bool HandlePlainOldCapture(RegexBuffer buffer)
 {
     if (buffer.ExplicitCapture)
     {
         this.description = string.Format("Non-capturing Group", new object[0]);
     }
     this.expression = new RegexExpression(buffer);
     this.CheckClosingParen(buffer);
     return true;
 }
Ejemplo n.º 16
0
 public void AddLookup(RegexItem item, int startLocation, int endLocation)
 {
     this.AddLookup(item, startLocation, endLocation, false);
 }
Ejemplo n.º 17
0
 private bool CheckBalancedGroup(RegexBuffer buffer)
 {
     Match match = new Regex("\r\n\t\t\t\t        ^                         # anchor to start of string\r\n\t\t\t\t\t\t\\?[\\<|']                  # ?< or ?'\r\n\t\t\t\t\t\t(?<Name1>[a-zA-Z]+?)       # Capture name1\r\n\t\t\t\t\t\t-\r\n\t\t\t\t\t\t(?<Name2>[a-zA-Z]+?)       # Capture name2\r\n\t\t\t\t\t\t[\\>|']                    # ?> or ?'\r\n\t\t\t\t\t\t(?<Rest>.+)               # The rest of the expression\r\n\t\t\t\t\t\t", RegexOptions.IgnorePatternWhitespace).Match(buffer.String);
     if (match.Success)
     {
         this.description = string.Format("Balancing Group <{0}>-<{1}>", match.Groups["Name1"], match.Groups["Name2"]);
         buffer.Offset += match.Groups["Rest"].Index;
         this.expression = new RegexExpression(buffer);
         this.CheckClosingParen(buffer);
         return true;
     }
     return false;
 }
Ejemplo n.º 18
0
 public RegexRef(RegexItem regexItem, int start, int end)
 {
     this.stringValue = regexItem.ToString(0);
     this.start       = start;
     this.end         = end;
 }