/// <summary>The translation of this syntax tree into NFA instruction code.</summary> /// <param name="builder">Data needed to construct an NFA.</param> /// <returns>The <see cref="NFA.Instruction"/> implementing this AST.</returns> public override NFA.Instruction ToInstruction(NFABuilder builder) { return new NFA.Instruction { test = NFA.TestCode.BoolProperty, arg1 = (int)Unicode7.Property.AnyChar, }; }
internal NFA(NFABuilder builder) { this.sameFinal = new Match.SameFinal(); this.Pending = new int[builder.TestDepth]; this.PendingTop = 0; this.Undos = new UndoStep[builder.MaxUndos + 2]; this.UndoTop = 0; AtomicCount = builder.ParseInfo.nAtomics; GroupNames = builder.ParseInfo.captures.ToArray(); QuantDepth = builder.ParseInfo.quantDepth; Anchored = builder.ParseInfo.anchor; Backrefs = builder.ParseInfo.backrefs; Instructions = builder.Instructions.ToArray(); nTransitions = 0; List<Transition[]> stateList = new List<Transition[]>(); foreach (List<Transition> transList in builder.States) { stateList.Add(transList.ToArray()); nTransitions += transList.Count; } States = stateList.ToArray(); FinalState = builder.FinalState; FirstTest = builder.FirstTest; FixedPrefix = builder.FixedPrefix; }
/// <summary>The translation of this syntax tree into NFA instruction code.</summary> /// <param name="builder">Data needed to construct an NFA.</param> /// <returns>The <see cref="NFA.Instruction"/> implementing this AST.</returns> public override NFA.Instruction ToInstruction(NFABuilder builder) { return new NFA.Instruction { test = Source.FoldsCase ? NFA.TestCode.BackrefCheckFC : NFA.TestCode.BackrefCheck, arg1 = Source.CaptureID, }; }
/// <summary>The translation of this syntax tree into NFA instruction code.</summary> /// <param name="builder">Data needed to construct an NFA.</param> /// <returns>The <see cref="NFA.Instruction"/> implementing this AST.</returns> public override NFA.Instruction ToInstruction(NFABuilder builder) { return new NFA.Instruction { test = NFA.TestCode.And, arg1 = builder.AddInstructions(Left), arg2 = builder.AddInstructions(Right), }; }
/// <summary>The translation of this syntax tree into NFA instruction code.</summary> /// <param name="builder">Data needed to construct an NFA.</param> /// <returns>The <see cref="NFA.Instruction"/> implementing this AST.</returns> public override NFA.Instruction ToInstruction(NFABuilder builder) { return new NFA.Instruction { test = IsExtended ? NFA.TestCode.ScriptExt : NFA.TestCode.Script, arg1 = (int)Script, }; }
/// <summary>The translation of this syntax tree into NFA instruction code.</summary> /// <param name="builder">Data needed to construct an NFA.</param> /// <returns>The <see cref="NFA.Instruction"/> implementing this AST.</returns> public override NFA.Instruction ToInstruction(NFABuilder builder) { return new NFA.Instruction { test = NFA.TestCode.Category, arg1 = (int)Category, }; }
/// <summary>The translation of this syntax tree into NFA instruction code.</summary> /// <param name="builder">Data needed to construct an NFA.</param> /// <returns>The <see cref="NFA.Instruction"/> implementing this AST.</returns> public override NFA.Instruction ToInstruction(NFABuilder builder) { return new NFA.Instruction { test = NFA.TestCode.Not, arg1 = builder.AddInstructions(Argument), }; }
/// <summary>The translation of this syntax tree into NFA instruction code.</summary> /// <param name="builder">Data needed to construct an NFA.</param> /// <returns>The <see cref="NFA.Instruction"/> implementing this AST.</returns> public abstract NFA.Instruction ToInstruction(NFABuilder builder);
/// <summary>Initializes and compiles a regular expression, with options that modify the pattern.</summary> /// <param name="rep">The pattern to be compiled.</param> /// <param name="opts">The options desired.</param> /// <exception cref="ArgumentException"><paramref name="rep"/> is an ill-formed pattern.</exception> public Regex(string rep, RegexOptions opts) { this.rep = rep; this.opts = opts; NFABuilder builder = new NFABuilder(rep, opts); Debug.WriteLine(String.Format("Parsed /{0}/{1}", rep, this.Options)); builder.Traverse(); Debug.WriteLine(String.Format("Canonical form = {0}, NFA:", builder.CanonicalForm)); nfa = new NFA(builder); #if DEBUG Debug.Indent(); Debug.WriteLine(String.Format("{0:d} non-* quantifiers, {1:d} atomic groups, {2}captures = ({3})", nfa.QuantDepth, nfa.AtomicCount, nfa.Anchored ? "anchored, " : "", String.Join(", ", nfa.GroupNames))); Debug.WriteLine(String.Format("Fixed prefix of match = \"{0}\", first character in {1}", nfa.FixedPrefix == null ? "" : nfa.FixedPrefix.Needle, nfa.InstructionString(nfa.FirstTest))); for (int s = 0; s < nfa.States.Length; s++) { Debug.Write(s); if (s == nfa.FinalState) Debug.Write(" accepts"); foreach (NFA.Transition tr in nfa.States[s]) Debug.Write(String.Format(", {0} -> {1:d}", nfa.InstructionString(tr.instruction), tr.target)); Debug.WriteLine(""); } Debug.Unindent(); #endif }
/// <summary>The translation of this syntax tree into NFA instruction code.</summary> /// <param name="builder">Data needed to construct an NFA.</param> /// <returns>The <see cref="NFA.Instruction"/> implementing this AST.</returns> public override NFA.Instruction ToInstruction(NFABuilder builder) { return new NFA.Instruction { test = NFA.TestCode.BackrefEmpty, arg1 = Source.CaptureID, }; }
/// <summary>The translation of this syntax tree into NFA instruction code.</summary> /// <param name="builder">Data needed to construct an NFA.</param> /// <returns>The <see cref="NFA.Instruction"/> implementing this AST.</returns> public override NFA.Instruction ToInstruction(NFABuilder builder) { return new NFA.Instruction { test = FoldsCase ? NFA.TestCode.RangeFC : NFA.TestCode.Range, arg1 = Min, arg2 = Max, }; }
/// <summary>The translation of this syntax tree into NFA instruction code.</summary> /// <param name="builder">Data needed to construct an NFA.</param> /// <returns>The <see cref="NFA.Instruction"/> implementing this AST.</returns> public override NFA.Instruction ToInstruction(NFABuilder builder) { return new NFA.Instruction { test = FoldsCase ? NFA.TestCode.CharacterFC : NFA.TestCode.Character, arg1 = Character, }; }
/// <summary>The translation of this syntax tree into NFA instruction code.</summary> /// <param name="builder">Data needed to construct an NFA.</param> /// <exception cref="NotImplementedException">The method should never be called.</exception> public override NFA.Instruction ToInstruction(NFABuilder builder) { throw new NotImplementedException(); }
/// <summary>The translation of this syntax tree into NFA instruction code.</summary> /// <param name="builder">Data needed to construct an NFA.</param> /// <returns>The <see cref="NFA.Instruction"/> implementing this AST.</returns> public override NFA.Instruction ToInstruction(NFABuilder builder) { return new NFA.Instruction { test = NFA.TestCode.CaptCheck, arg1 = Index, }; }