예제 #1
0
파일: Regexp.cs 프로젝트: Belxjander/Asuna
		private void  compile(string exp)
		{
			Compiler rcstate = new Compiler();
			rcstate.parse = exp.ToCharArray();
			rcstate.off = 0;
			rcstate.npar = 1;
			rcstate.code = new System.Text.StringBuilder();
			
			rcstate.reg(false);
			
			program = rcstate.code.ToString().ToCharArray();
			npar = rcstate.npar;
			startChar = - 1;
			
			/* optimize */
			if (program[rcstate.regnext(0)] == END)
			{
				if (program[2] == BOL)
				{
					anchored = true;
				}
				else if (program[2] == EXACTLY)
				{
					startChar = (int) program[5];
				}
			}
			
			/*
			* If there's something expensive in the r.e., find the
			* longest literal string that must appear and make it the
			* regmust.  Resolve ties in favor of later strings, since
			* the regstart check works with the beginning of the r.e.
			* and avoiding duplication strengthens checking.  Not a
			* strong reason, but sufficient in the absence of others.
			*/
			/*
			if ((rcstate.flagp & Compiler.SPSTART) != 0) {
			int index = -1;
			int longest = 0;
			
			for (scan = 0; scan < program.length; ) {
			switch (program[scan]) {
			case EXACTLY:
			int length = program[scan + 2];
			if (length > longest) {
			index = scan;
			longest = length;
			}
			// fall through;
			
			case ANYOF:
			case ANYBUT:
			scan += 3 + program[scan + 2];
			break;
			
			default:
			scan += 2;
			break;
			}
			}
			if (longest > 0) {
			must = new String(program, index + 3, longest);
			}
			}*/
		}