--- src/Boo.Lang.Compiler/Steps/EmitAssembly.cs.orig Thu May 4 18:35:56 2006 +++ src/Boo.Lang.Compiler/Steps/EmitAssembly.cs Wed May 31 16:41:36 2006 @@ -90,6 +90,8 @@ static ConstructorInfo Hash_Constructor = Types.Hash.GetConstructor(new Type[0]); static ConstructorInfo Regex_Constructor = typeof(Regex).GetConstructor(new Type[] { Types.String }); + + static ConstructorInfo Regex_Constructor2 = typeof(Regex).GetConstructor(new Type[] { Types.String, typeof(RegexOptions) }); static MethodInfo Hash_Add = Types.Hash.GetMethod("Add", new Type[] { typeof(object), typeof(object) }); @@ -2297,10 +2299,56 @@ PushType(type); } + static Regex _reliteral_options = new Regex("^/(.*)/([imncsxe]*)$", RegexOptions.Compiled); + override public void OnRELiteralExpression(RELiteralExpression node) { - _il.Emit(OpCodes.Ldstr, RuntimeServices.Mid(node.Value, 1, -1)); - _il.Emit(OpCodes.Newobj, Regex_Constructor); + Match m; + if((m = _reliteral_options.Match(node.Value)).Success) + { + RegexOptions options = RegexOptions.None; + string soptions = m.Groups[2].Value; + for(int i = 0; i < soptions.Length; ++i) + switch(soptions[i]) + { + case 'i': + options |= RegexOptions.IgnoreCase; + break; + case 'm': + options |= RegexOptions.Multiline; + break; + case 'n': + options |= RegexOptions.ExplicitCapture; + break; + case 'c': + options |= RegexOptions.Compiled; + break; + case 's': + options |= RegexOptions.Singleline; + break; + case 'x': + options |= RegexOptions.IgnorePatternWhitespace; + break; + case 'e': + options |= RegexOptions.ECMAScript; + break; + } + _il.Emit(OpCodes.Ldstr, m.Groups[1].Value); + int ioptions = (int)options; + if(ioptions == 0) + { + _il.Emit(OpCodes.Newobj, Regex_Constructor); + } else { + if(ioptions > 0 && ioptions <= 128) + _il.Emit(OpCodes.Ldc_I4_S, (byte)ioptions); + else + _il.Emit(OpCodes.Ldc_I4, ioptions); + _il.Emit(OpCodes.Newobj, Regex_Constructor2); + } + } else { + _il.Emit(OpCodes.Ldstr, RuntimeServices.Mid(node.Value, 1, -1)); + _il.Emit(OpCodes.Newobj, Regex_Constructor); + } PushType(node.ExpressionType); } --- src/Boo.Lang.Parser/boo.g.orig Sun Apr 23 18:41:40 2006 +++ src/Boo.Lang.Parser/boo.g Wed May 31 16:38:01 2006 @@ -3254,7 +3254,7 @@ EOS: ';'; -X_RE_LITERAL: '@'!'/' (X_RE_CHAR)+ '/' { $setType(RE_LITERAL); }; +X_RE_LITERAL: '@'!'/' (X_RE_CHAR)+ '/' (RE_OPTION_CHAR)* { $setType(RE_LITERAL); }; protected NEWLINE: @@ -3310,10 +3310,13 @@ protected -RE_LITERAL : '/' (RE_CHAR)+ '/'; +RE_LITERAL : '/' (RE_CHAR)+ '/' (RE_OPTION_CHAR)*; protected RE_CHAR : RE_ESC | ~('/' | '\\' | '\r' | '\n' | ' ' | '\t' ); + +protected +RE_OPTION_CHAR : 'i' | 'm' | 'n' | 'c' | 's' | 'x' | 'e'; protected X_RE_CHAR: RE_CHAR | ' ' | '\t'; --- src/Boo.Lang.Parser/booel.g.orig Wed May 24 14:32:03 2006 +++ src/Boo.Lang.Parser/booel.g Wed May 31 16:38:15 2006 @@ -191,10 +191,13 @@ ( '\\'! {$setText("\\"); }); protected -RE_LITERAL : '/' (RE_CHAR)+ '/'; +RE_LITERAL : '/' (RE_CHAR)+ '/' (RE_OPTION_CHAR)*; protected RE_CHAR : RE_ESC | ~('/' | '\\' | '\r' | '\n' | ' ' | '\t'); + +protected +RE_OPTION_CHAR : 'i' | 'm' | 'n' | 'c' | 's' | 'x' | 'e'; protected RE_ESC : '\\' ( --- src/Boo.Lang.Parser/wsaboo.g.orig Sun Mar 5 14:51:36 2006 +++ src/Boo.Lang.Parser/wsaboo.g Wed May 31 16:38:41 2006 @@ -3002,7 +3002,7 @@ EOS: ';'; -X_RE_LITERAL: '@'!'/' (X_RE_CHAR)+ '/' { $setType(RE_LITERAL); }; +X_RE_LITERAL: '@'!'/' (X_RE_CHAR)+ '/' (RE_OPTION_CHAR)* { $setType(RE_LITERAL); }; NEWLINE: ( @@ -3070,10 +3070,13 @@ protected -RE_LITERAL : '/' (RE_CHAR)+ '/'; +RE_LITERAL : '/' (RE_CHAR)+ '/' (RE_OPTION_CHAR)*; protected RE_CHAR : RE_ESC | ~('/' | '\\' | '\r' | '\n' | ' ' | '\t' ); + +protected +RE_OPTION_CHAR : 'i' | 'm' | 'n' | 'c' | 's' | 'x' | 'e'; protected X_RE_CHAR: RE_CHAR | ' ' | '\t'; --- src/Boo.Lang.Parser/wsabooel.g.orig Wed Feb 22 20:11:32 2006 +++ src/Boo.Lang.Parser/wsabooel.g Wed May 31 16:38:56 2006 @@ -203,10 +203,13 @@ ( '\\'! {$setText("\\"); }); protected -RE_LITERAL : '/' (RE_CHAR)+ '/'; +RE_LITERAL : '/' (RE_CHAR)+ '/' (RE_OPTION_CHAR)*; protected RE_CHAR : RE_ESC | ~('/' | '\\' | '\r' | '\n' | ' ' | '\t'); + +protected +RE_OPTION_CHAR : 'i' | 'm' | 'n' | 'c' | 's' | 'x' | 'e'; protected RE_ESC : '\\' (