diff options
author | Jon Skeet <skeet@pobox.com> | 2009-01-27 14:56:10 +0000 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2009-01-27 14:56:10 +0000 |
commit | 0ca3fecfafe6b2f7b6de4a5e1b978353fcaae83b (patch) | |
tree | ecd4a9479bf913370884dd409272905830d790e9 /src | |
parent | 6a60ac33d0e90f25f7e9ac84917dd92b2e11619d (diff) | |
download | protobuf-0ca3fecfafe6b2f7b6de4a5e1b978353fcaae83b.tar.gz protobuf-0ca3fecfafe6b2f7b6de4a5e1b978353fcaae83b.tar.bz2 protobuf-0ca3fecfafe6b2f7b6de4a5e1b978353fcaae83b.zip |
Use atomic groups to mimic the possessive quantifier change in Java code
Diffstat (limited to 'src')
-rw-r--r-- | src/ProtocolBuffers/TextTokenizer.cs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/ProtocolBuffers/TextTokenizer.cs b/src/ProtocolBuffers/TextTokenizer.cs index ecd031ab..0787c03e 100644 --- a/src/ProtocolBuffers/TextTokenizer.cs +++ b/src/ProtocolBuffers/TextTokenizer.cs @@ -69,13 +69,14 @@ namespace Google.ProtocolBuffers { /// </summary> private int previousColumn = 0; - private static readonly Regex WhitespaceAndCommentPattern = new Regex("\\G(\\s|(#.*$))+", + // Note: atomic groups used to mimic possessive quantifiers in Java in both of these regexes + private static readonly Regex WhitespaceAndCommentPattern = new Regex("\\G(?>(\\s|(#.*$))+)", RegexOptions.Compiled | RegexOptions.Multiline); private static readonly Regex TokenPattern = new Regex( - "\\G[a-zA-Z_][0-9a-zA-Z_+-]*|" + // an identifier - "\\G[0-9+-][0-9a-zA-Z_.+-]*|" + // a number - "\\G\"([^\"\\\n\\\\]|\\\\.)*(\"|\\\\?$)|" + // a double-quoted string - "\\G\'([^\"\\\n\\\\]|\\\\.)*(\'|\\\\?$)", // a single-quoted string + "\\G[a-zA-Z_](?>[0-9a-zA-Z_+-]*)|" + // an identifier + "\\G[0-9+-](?>[0-9a-zA-Z_.+-]*)|" + // a number + "\\G\"(?>([^\"\\\n\\\\]|\\\\.)*)(\"|\\\\?$)|" + // a double-quoted string + "\\G\'(?>([^\"\\\n\\\\]|\\\\.)*)(\'|\\\\?$)", // a single-quoted string RegexOptions.Compiled | RegexOptions.Multiline); private static readonly Regex DoubleInfinity = new Regex("^-?inf(inity)?$", RegexOptions.Compiled | RegexOptions.IgnoreCase); |