[svn] r7713: nemerle/trunk/macros/text.n
divan
svnadmin at nemerle.org
Sat Jun 23 13:46:44 CEST 2007
Log:
Make Regex object static in regexp match macro.
Author: divan
Date: Sat Jun 23 13:46:42 2007
New Revision: 7713
Modified:
nemerle/trunk/macros/text.n
Modified: nemerle/trunk/macros/text.n
==============================================================================
--- nemerle/trunk/macros/text.n (original)
+++ nemerle/trunk/macros/text.n Sat Jun 23 13:46:42 2007
@@ -267,11 +267,23 @@
// generation of final code for building regular expression and
// extracting its groups
- <[
- def regobj = Regex ($(pat.ToString () : string),
- RegexOptions.ExplicitCapture);
- def matchobj = regobj.Match ($val);
+ def ctx = Nemerle.Macros.ImplicitCTX ();
+ def tb = ctx.CurrentTypeBuilder;
+ def static_regobj = Macros.NewSymbol ("static_regobj");
+ def value = Macros.NewSymbol ("value");
+ unless (ctx.InErrorMode && !Nemerle.Macros.Manager ().IsIntelliSenseMode) {
+ def tb = tb.DefineNestedType (<[ decl:
+ private module $(static_regobj : name) {
+ public $(value : name) : Regex =
+ Regex ( $(pat.ToString () : string), RegexOptions.ExplicitCapture %| RegexOptions.Compiled );
+ }
+ ]>);
+ tb.Compile ();
+ }
+
+ <[
+ def matchobj = $(static_regobj : name).$(value : name).Match ($val);
match (matchobj.Success) {
| true => $(build_checking (alternatives))
More information about the svn
mailing list