GetMachineFactory() public method

public GetMachineFactory ( ) : IMachineFactory
return IMachineFactory
示例#1
0
文件: regex.cs 项目: ForNeVeR/pnet
        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;
            }
        }
示例#2
0
        private static IMachineFactory CreateMachineFactory(string pattern, RegexOptions options)
        {
            Parser            psr = new Parser();
            RegularExpression re  = psr.ParseRegularExpression(pattern, options);

            ICompiler cmp;

            //if ((options & RegexOptions.Compiled) != 0)
            //	//throw new Exception ("Not implemented.");
            //	cmp = new CILCompiler ();
            //else
            cmp = new PatternCompiler();

            re.Compile(cmp, (options & RegexOptions.RightToLeft) != 0);

            IMachineFactory machineFactory = cmp.GetMachineFactory();

            machineFactory.Mapping      = psr.GetMapping();
            machineFactory.NamesMapping = GetGroupNamesArray(machineFactory.GroupCount, machineFactory.Mapping);

            return(machineFactory);
        }
示例#3
0
		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;
			}
		}