Commit Graph
188 Commits
Author SHA1 Message Date
Miguel de Icaza 183e538e52 2010-07-20 Miguel de Icaza <[email protected]>
* parser.cs (ParseEscape): Now parses with some context, whether
	we are parsing inside a character range which can not contain
	back-references or when we are parsing on a string context which
	can contain back references.

	This fixes bug #577346 which exposed a bug parsing this:

	new Regex("[\\177-\\377]")



svn path=/trunk/mcs/; revision=160626
2010-07-20 17:31:31 +00:00
Raja R Harinath 56c2a1dc07 Mitigate a possible source of unbounded memory growth
* interpreter.cs (Backtrack): Move mark_start back, and invalidate
discarded marks.

svn path=/trunk/mcs/; revision=159647
2010-06-29 07:20:12 +00:00
Raja R Harinath e587d2b7ea Make trace output resemble assembler listing
* compiler.cs (LinkRef.ToString) [TRACE_REGEX]: Add pretty-printer
in TRACE_REGEX mode.
(TraceRegexp): Indent the output.
(TraceRegexpLabel): New.  Prints out a line label.
(EmitCount): Don't trace.  All callers are traced.
(ResolveLink): Trace line labels.

svn path=/trunk/mcs/; revision=159646
2010-06-29 07:19:50 +00:00
Rodrigo Kumpera 9b460752ba 2010-06-21 Rodrigo Kumpera <[email protected]>
* compiler.cs: Use conditional compilation to enable
	tracing to avoid code bloat.

svn path=/trunk/mcs/; revision=159300
2010-06-21 22:01:57 +00:00
Rodrigo Kumpera 37ab7f11e3 2010-06-21 Rodrigo Kumpera <[email protected]>
* parser.cs: Handle repetition of position assertions.

	Fixes #610587.

svn path=/trunk/mcs/; revision=159287
2010-06-21 20:18:20 +00:00
Rodrigo Kumpera fc322e9315 2010-06-21 Rodrigo Kumpera <[email protected]>
* compiler.cs: Add new internal flag to switch on regexp
	* tracing.
	The code is a statc readonly variable so the JIT can eliminate
	all tracing code during normal runs.

svn path=/trunk/mcs/; revision=159286
2010-06-21 20:18:11 +00:00
Miguel de Icaza 833a86518a 2010-03-20 Miguel de Icaza <[email protected]>
* RxInterpreter.cs: Removed warnings.

svn path=/trunk/mcs/; revision=153948
2010-03-20 22:56:32 +00:00
Rodrigo Kumpera 22fb8fe69c 2010-02-03 Rodrigo Kumpera <[email protected]>
* BaseMachine.cs (Split): Don't add empty strings if they don't
	* come from
	the first capture group. Fixes #566117.

svn path=/trunk/mcs/; revision=150786
2010-02-03 21:10:16 +00:00
Miguel de Icaza 5529d196f3 2010-01-12 Miguel de Icaza <[email protected]>
* Regex.cs: Re-enable the new regex compiler as the bug seems to
	be gone now.

svn path=/trunk/mcs/; revision=149403
2010-01-12 13:54:19 +00:00
Raja R Harinath 2d8031df3c regex: A few more null and bounds checks
* Regex.cs (Escape, Unescape): Add null checks.
(validate_options): Add ECMAScript option checks.
(Replace, Split): Add a few bounds checks.

svn path=/trunk/mcs/; revision=141459
2009-09-07 17:14:37 +00:00
Raja R Harinath e8d4a97211 Add some null checks and bounds checks.
* Regex.cs (default_startat): New.  Replaces the fragment
'RightToLeft ?  input.Length : 0' with a null-safe variant.
(Replace) <string variant>: Add null checks for argument strings.
(Split): Likewise.
(.ctor): Likewise.  Validate regex options partially.
(Match): Add null check on string arguments, and bounds checks for
offset and length arguments.

svn path=/trunk/mcs/; revision=141457
2009-09-07 16:25:50 +00:00
Raja R Harinath 66fee73c0a Final piece of explicit numeric group support
* parser.cs (gap): New.
(GetMapping): Return it.
(ResolveReferences): Collect explicit numeric groups which may not
match their indices.
(HandleExplicitNumericGroups): New.  Process the above list to
assign appropriate indices, and compute the correct value of 'gap'.

svn path=/trunk/mcs/; revision=140290
2009-08-19 20:43:01 +00:00
Raja R Harinath 6dac1251cd * syntax.cs (CapturingGroup.Index): Rename from Number to clarify semantics.
(CapturingGroup.CompareTo): New.
* parser.cs, syntax.cs: Update to changes.

svn path=/trunk/mcs/; revision=140289
2009-08-19 20:42:36 +00:00
Raja R Harinath f6656df299 Implement some more group number/index distinction
* Regex.cs (gap, Gap): New.
(Init, InitNewRegex): Update it.
(GroupNumberFromName): If the 'name' is beyond the gap, it is an
explicit numeric group -- use the name as the group number.
GetGroupIndex): Use a binary search to map a group number to its
index when we know that they don't match.
(GroupNumbers): Use group number, not group index, for explicit
numeric groups.
* Match.cs (.ctor): Use the newly introduce 'Regex.Gap'.

svn path=/trunk/mcs/; revision=140288
2009-08-19 20:42:13 +00:00
Raja R Harinath 61c45d91d6 Minor code re-organization
* Regex.cs (group_numbers): New.
(GetGroupNumbers): Move array initialization ...
(GroupNumbers): ... to new on-demand initializer.

svn path=/trunk/mcs/; revision=140287
2009-08-19 20:41:51 +00:00
Raja R Harinath 27c8bd541f Use IDictionaryEnumerator in a loop where both key and value are used
* Regex.cs (group_names): Rename from _groupNumbersToNameMap.
(GetGroupNamesArray): Use an IDictionaryEnumerator to walk the
mapping, since both the key and value are used in the loop.

svn path=/trunk/mcs/; revision=140286
2009-08-19 20:41:26 +00:00
Raja R Harinath a21d173159 Introduce 'gap' concept into all the variants of regex
* arch.cs (IMachineFactory::Gap): New property.
* compiler.cs (InterpreterFactory): Update to changes.
* RxCompiler.cs (RxInterpreterFactory): Likewise.
* JvmReMachineFactory.cs: Likewise.
* parser.cs (GetMapping): Return the 'gap' index.  Move creation
of mapping dictionary ...
* Regex.cs (CreateMachineFactory): ... here.  Update to changes.

svn path=/trunk/mcs/; revision=140285
2009-08-19 20:41:03 +00:00
Raja R Harinath fb54e0e6c7 Distinguish between the internal index of a group and group number.
* Regex.cs (GetGroupIndex): New.
(GroupNameFromNumber): Use it.
* GroupCollection.cs (.ctor): Introduce 'gap' argument.  It is the
index of the first group whose group number differs from its index.
(Item.get): Likewise.

svn path=/trunk/mcs/; revision=140284
2009-08-19 20:40:39 +00:00
Raja R Harinath 4735fd50bc * parser.cs (GetMapping): Extend duplicate check for numeric groups too.
svn path=/trunk/mcs/; revision=140097
2009-08-17 19:26:40 +00:00
Raja R Harinath 51c4ad074a * parser.cs (ResolveReferences): Handle some cases of explicitly-named numeric groups.
svn path=/trunk/mcs/; revision=140096
2009-08-17 19:26:18 +00:00
Raja R Harinath 1c27a86429 * parser.cs (ResolveReferences): Rearrange slightly to prepare for future changes.
svn path=/trunk/mcs/; revision=140095
2009-08-17 19:25:50 +00:00
Raja R Harinath 3c675a0e62 * Regex.cs (GetGroupNumbers): List group numbers in ascending order.
(GetGroupNames): List names in order of group number.

svn path=/trunk/mcs/; revision=140051
2009-08-17 12:27:57 +00:00
Raja R Harinath 4d8fa96830 * syntax.cs (BackslashNumber.ResolveReference): Improve ECMAScript semantics.
svn path=/trunk/mcs/; revision=139731
2009-08-11 19:11:26 +00:00
Raja R Harinath 1163a482f7 regexp backreferences: Implement fallback to octal numbers, and ECMAScript semantics.
* syntax.cs (BackslashNumber.ResolveReference): Implement fallback
to octal numbers, and ECMAScript semantics.
* parser.cs (ResolveReferences): Use it.
* RegexMatchTests.cs (RegexTrial0054..60): New.

svn path=/trunk/mcs/; revision=139657
2009-08-10 16:25:10 +00:00
Raja R Harinath 54481772e9 Distinguish between the potentially ambiguous \nnn and the non-ambiguous \k<...> back-references
* syntax.cs (BackslashNumber): New class.
* parser.cs (ParseSpecial): Create it instead of 'Reference' if a
numeric backreference is seen.

svn path=/trunk/mcs/; revision=139656
2009-08-10 16:24:45 +00:00
Raja R Harinath 88c39f81b9 Regex.IsMatch("abcab", @"(?<ab>ab)c\1")
* System.Text.RegularExpressions/parser.cs (ResolveReferences):
Allow named groups to be referred-to by their group numbers too.
* RegexMatchTests.cs (RegexTrial0053): New.

svn path=/trunk/mcs/; revision=139655
2009-08-10 16:24:21 +00:00
Sebastien Pouliot 4f838e0e43 2009-04-23 Sebastien Pouliot <[email protected]>
* Regex.cs: Remove Compiler-related support for NET_2_1
	* RegexOptions.cs: Remove Compile from values available on NET_2_1


svn path=/trunk/mcs/; revision=132491
2009-04-23 17:34:25 +00:00
Zoltan Varga 34df9a2168 2009-03-04 Zoltan Varga <[email protected]>
* RxInterpreter.cs (ResetGroups): Avoid allocating larger than needed
	arrays.

svn path=/trunk/mcs/; revision=128509
2009-03-04 00:49:06 +00:00
Jonathan Pryor 247cfd34f0 * System.Text.RegularExpressions/Regex.cs (Replace): Check that input &
evaluator are not null, as documented in MSDN (and the variance found 
	  while testing DbLinq).
	* Test/System.Text.RegularExpressions/RegexReplace.cs: Add null 
	  argument checks for Regex.Replace().

svn path=/trunk/mcs/; revision=128241
2009-02-27 21:40:17 +00:00
Zoltan Varga 09047c897a 2009-02-27 Zoltan Varga <[email protected]>
* BaseMachine.cs (LTRReplace): Initialize the StringBuilder with an
	appropriate initial length.

svn path=/trunk/mcs/; revision=128158
2009-02-26 23:24:42 +00:00
Zoltan Varga dabd23ce6e 2009-02-24 Zoltan Varga <[email protected]>
* CILCompiler.cs: Partially inline calls to Char.ToLower () to speed
	up ignorecase matching.

svn path=/trunk/mcs/; revision=127898
2009-02-24 20:34:33 +00:00
Jb Evain 85e8848db2 2009-02-16 Jb Evain <[email protected]>
* Regex.cs: on the NET_2_1 profile, always use the old engine for now.


svn path=/trunk/mcs/; revision=127039
2009-02-16 15:28:14 +00:00
Zoltan Varga 69d48eba16 2009-02-14 Zoltan Varga <[email protected]>
* Regex.cs: Add a MONO_NEW_RX variable to enable the new regex
	engine.

svn path=/trunk/mcs/; revision=126923
2009-02-14 14:36:27 +00:00
Zoltan Varga f908a8a6c3 2009-02-04 Zoltan Varga <[email protected]>
* Regex.cs: Disable the new regex engine for now.

svn path=/trunk/mcs/; revision=125637
2009-02-04 02:18:48 +00:00
Zoltan Varga 824710f744 2009-01-14 Zoltan Varga <[email protected]>
* CILCompiler.cs: Avoid throwing exceptions for a few more unhandled opcodes.
	Implement the reverse/ignorecase versions of Reference. Fix the reverse
	version of Bitmap. Error out if a Jump opcode jumps outside the current
	pc range. This works around #466151.

svn path=/trunk/mcs/; revision=123417
2009-01-14 21:33:40 +00:00
Jb Evain dccb5600df 2009-01-12 Jb Evain <[email protected]>
* RxInterpreter.cs: set trace_rx to false for NET_2_1.
	* Regex.cs: set old_rx to false for NET_2_1.


svn path=/trunk/mcs/; revision=123110
2009-01-12 19:14:55 +00:00
Zoltan Varga 5c44702768 2009-01-07 Zoltan Varga <[email protected]>
* RxInterpreter.cs: Add support for constant strings in anchors. Fixes
	#464135.

svn path=/trunk/mcs/; revision=122700
2009-01-07 19:48:15 +00:00
Gonzalo Paniagua Javier 295e584514 2008-11-18 Gonzalo Paniagua Javier <[email protected]>
* cache.cs: avoid infinite loop.


svn path=/trunk/mcs/; revision=119193
2008-11-18 17:46:59 +00:00
Gonzalo Paniagua Javier e75ce1dcee 2008-11-14 Gonzalo Paniagua Javier <[email protected]>
* cache.cs:
	* Regex.cs: honor CacheSize value.


svn path=/trunk/mcs/; revision=118878
2008-11-14 18:51:42 +00:00
Zoltan Varga b9e2040044 2008-11-13 Zoltan Varga <[email protected]>
* RxInterpreter.cs: Fix pc computation in various opcodes. Fixes #443841.

svn path=/trunk/mcs/; revision=118729
2008-11-13 17:13:43 +00:00
Zoltan Varga c935db2360 2008-11-11 Zoltan Varga <[email protected]>
* CILCompiler.cs: Implement Reference opcode.

svn path=/trunk/mcs/; revision=118484
2008-11-11 11:16:33 +00:00
Zoltan Varga f02d458b56 2008-10-30 Zoltan Varga <[email protected]>
* CILCompiler.cs: Implement SubExpression opcode.

svn path=/trunk/mcs/; revision=117485
2008-10-30 15:59:21 +00:00
Zoltan Varga e917f14f6f 2008-10-30 Zoltan Varga <[email protected]>
* CILCompiler.cs: Save and restore strpos in the Test opcode. Fixes
	#439947.

svn path=/trunk/mcs/; revision=117484
2008-10-30 15:41:03 +00:00
Zoltan Varga 02a61b0826 2008-10-25 Zoltan Varga <[email protected]>
* CILCompiler.cs: Implement Test opcode.

svn path=/trunk/mcs/; revision=117064
2008-10-25 17:58:51 +00:00
Gonzalo Paniagua Javier 942296071d 2008-10-25 Gonzalo Paniagua Javier <[email protected]>
* RxInterpreter.cs: implement missing Unicode* opcodes and
	StringReverseIgnoreCase.


svn path=/trunk/mcs/; revision=117048
2008-10-25 14:49:46 +00:00
Zoltan Varga 6941113b7a 2008-10-25 Zoltan Varga <[email protected]>
* RxOp.cs: Remove unused Generic opcodes.

	* RxCompiler.cs: Emit opcodes with flags using methods which can be 
	overriden by CILCompiler.cs, so we only have to override a few methods.

	* CILCompiler.cs: Simplify based on the RxCompiler changes. Implement
	UnicodeString opcode. Throw a NotImplementedException when an unsupported
	opcode is encountered, since the IL compiler is now believed to be feature 
	complete.

svn path=/trunk/mcs/; revision=117047
2008-10-25 14:00:58 +00:00
Zoltan Varga bd2d887d95 2008-10-24 Zoltan Varga <[email protected]>
* RxInterpreter.cs CILCompiler.cs gen-interp.cs: Fix the reading of short 
	values from the instruction stream.

svn path=/trunk/mcs/; revision=116964
2008-10-24 17:23:52 +00:00
Zoltan Varga e3892be8ab 2008-10-24 Zoltan Varga <[email protected]>
* RxOp.cs: Add some missing unicode opcodes.

	* gen-interp.cs RxInterpreter.cs: Generate Bitmap/UnicodeBitmap opcodes too.

	* CILCompiler.cs (EmitEvalMethodBody): Add an 'end_pc' argument to mark the
	end of the bytecode range which needs to be compiled. Use it to avoid
	compiling the same bytecode multiple times in various opcodes. Fix
	RxOp.Jump implementation. Add implementation for unicode opcodes.

svn path=/trunk/mcs/; revision=116926
2008-10-24 12:21:55 +00:00
Zoltan Varga 51f5de6c95 2008-10-09 Zoltan Varga <[email protected]>
* CILCompiler.cs: Implement NoBitmap/NoBitmapIgnoreCase. Fixes #432172.

svn path=/trunk/mcs/; revision=115310
2008-10-09 07:48:52 +00:00
Zoltan Varga 1b29e7e9c2 2008-09-14 Zoltan Varga <[email protected]>
* gen-interp.cs: New file to generate the all variants of the character 
	checking opcodes in RxInterpreter.cs.

	* RxInterpreter.cs: Replace hand written code with code generated by
	gen-interp.cs.

svn path=/trunk/mcs/; revision=112947
2008-09-14 01:46:53 +00:00