public Regex(string pattern, RegexOptions options)
{
this.pattern = pattern;
this.roptions = options;
this.machineFactory = cache.Lookup(pattern, options);
if (this.machineFactory == null)
{
// parse and install group mapping
Parser psr = new Parser();
RegularExpression re = psr.ParseRegularExpression(pattern, options);
this.group_count = re.GroupCount;
this.mapping = psr.GetMapping();
// compile
ICompiler cmp;
//if ((options & RegexOptions.Compiled) != 0)
// //throw new Exception ("Not implemented.");
// cmp = new CILCompiler ();
//else
cmp = new PatternCompiler();
re.Compile(cmp, RightToLeft);
// install machine factory and add to pattern cache
this.machineFactory = cmp.GetMachineFactory();
this.machineFactory.Mapping = mapping;
cache.Add(pattern, options, this.machineFactory);
}
else
{
this.group_count = this.machineFactory.GroupCount;
this.mapping = this.machineFactory.Mapping;
}
}