Beispiel #1
0
		internal static void simplify(Spec spec)
		{
			SimplifyNfa.computeClasses(spec);
			for (int i = 0; i < spec.nfa_states.Count; i++)
			{
				Nfa nfa = spec.nfa_states[i];
				if (nfa.Edge != '�' && nfa.Edge != '')
				{
					if (nfa.Edge == '￾')
					{
						CharSet charSet = new CharSet();
						charSet.map(nfa.GetCharSet(), SimplifyNfa.ccls);
						nfa.SetCharSet(charSet);
					}
					else
					{
						nfa.Edge = SimplifyNfa.ccls[(int)nfa.Edge];
					}
				}
			}
			spec.ccls_map = SimplifyNfa.ccls;
			spec.dtrans_ncols = SimplifyNfa.mapped_charset_size;
		}
Beispiel #2
0
		public Nfa()
		{
			this.edge = '�';
			this.cset = null;
			this.next = null;
			this.sibling = null;
			this.accept = null;
			this.anchor = 0;
			this.label = -1;
			this.states = null;
		}
Beispiel #3
0
		public void SetCharSet(CharSet s)
		{
			this.cset = s;
		}
Beispiel #4
0
		public void mimic(Nfa nfa)
		{
			this.edge = nfa.edge;
			if (nfa.cset != null)
			{
				if (this.cset == null)
				{
					this.cset = new CharSet();
				}
				this.cset.mimic(nfa.cset);
			}
			else
			{
				this.cset = null;
			}
			this.next = nfa.next;
			this.sibling = nfa.sibling;
			this.accept = nfa.accept;
			this.anchor = nfa.anchor;
			if (nfa.states != null)
			{
				this.states = new BitSet(nfa.states);
				return;
			}
			this.states = null;
		}
Beispiel #5
0
		private static void dodash(CharSet set)
		{
			int i = -1;
			while (Tokens.EOS != MakeNfa.spec.current_token && Tokens.CCL_END != MakeNfa.spec.current_token)
			{
				if (Tokens.DASH == MakeNfa.spec.current_token && -1 != i)
				{
					MakeNfa.gen.Advance();
					if (MakeNfa.spec.current_token == Tokens.CCL_END)
					{
						set.add(45);
						return;
					}
					while (i <= (int)MakeNfa.spec.current_token_value)
					{
						if (MakeNfa.spec.IgnoreCase)
						{
							set.addncase((char)i);
						}
						else
						{
							set.add(i);
						}
						i++;
					}
				}
				else
				{
					i = (int)MakeNfa.spec.current_token_value;
					if (MakeNfa.spec.IgnoreCase)
					{
						set.addncase(MakeNfa.spec.current_token_value);
					}
					else
					{
						set.add((int)MakeNfa.spec.current_token_value);
					}
				}
				MakeNfa.gen.Advance();
			}
		}
Beispiel #6
0
 public void SetCharSet(CharSet s)
 {
     cset = s;
 }
Beispiel #7
0
		public void map(CharSet old, char[] mapping)
		{
			this.compflag = old.compflag;
			this.set = new BitSet();
			foreach (int current in old)
			{
				if (current < mapping.Length)
				{
					this.set.Set((int)mapping[current], true);
				}
			}
		}
Beispiel #8
0
		public void mimic(CharSet s)
		{
			this.compflag = s.compflag;
			this.set = new BitSet(s.set);
		}
Beispiel #9
0
 public void SetCharSet(CharSet s)
 {
     this.cset = s;
 }
Beispiel #10
0
		private void printccl(CharSet cset)
		{
			Console.Write(" [");
			for (int i = 0; i < this.spec.dtrans_ncols; i++)
			{
				if (cset.contains(i))
				{
					Console.Write(this.interp_int(i));
				}
			}
			Console.Write(']');
		}