예제 #1
0
        public Regexp Build()
        {
            Node n   = Parse();
            Node acc = new AcceptNode(positions.Count);

            positions.Add(acc);
            n = new SequenceNode(n, acc);

            n.ComputeNullable();
            n.ComputeFirstPos(this);
            n.ComputeLastPos(this);
            n.ComputeFollowPos(this);

#if DEBUG
            StringBuilder sb = new StringBuilder();
            n.Dump(sb);
            Debug.WriteLine(sb.ToString());
#endif
            State []       states = BuildDfaTable(n);
            TableCompacter tc     = new TableCompacter(states, charClasses);
            tc.Compact();
            return(new Regexp(alphabet, tc.ReStates, tc.Next, tc.Check));
        }
예제 #2
0
		public Regexp Build()
		{
			Node n = Parse();
			Node acc = new AcceptNode(positions.Count);
			positions.Add(acc);
			n = new SequenceNode(n, acc);

			n.ComputeNullable();
			n.ComputeFirstPos(this);
			n.ComputeLastPos(this);
			n.ComputeFollowPos(this);

#if DEBUG
			StringBuilder sb = new StringBuilder();
			n.Dump(sb);
			Debug.WriteLine(sb.ToString());
#endif
			State [] states = BuildDfaTable(n);
			TableCompacter tc = new TableCompacter(states, charClasses);
			tc.Compact();
			return new Regexp(alphabet, tc.ReStates, tc.Next, tc.Check);
		}