コード例 #1
0
ファイル: SimplifyNfa.cs プロジェクト: dw4dev/Phalanger
		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;
		}
コード例 #2
0
ファイル: Nfa.cs プロジェクト: dw4dev/Phalanger
		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;
		}
コード例 #3
0
ファイル: Nfa.cs プロジェクト: dw4dev/Phalanger
		public void SetCharSet(CharSet s)
		{
			this.cset = s;
		}
コード例 #4
0
ファイル: Nfa.cs プロジェクト: dw4dev/Phalanger
		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;
		}
コード例 #5
0
ファイル: MakeNfa.cs プロジェクト: dw4dev/Phalanger
		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();
			}
		}
コード例 #6
0
 public void SetCharSet(CharSet s)
 {
     cset = s;
 }
コード例 #7
0
ファイル: CharSet.cs プロジェクト: dw4dev/Phalanger
		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);
				}
			}
		}
コード例 #8
0
ファイル: CharSet.cs プロジェクト: dw4dev/Phalanger
		public void mimic(CharSet s)
		{
			this.compflag = s.compflag;
			this.set = new BitSet(s.set);
		}
コード例 #9
0
ファイル: Nfa.cs プロジェクト: petrroll/Parsers
 public void SetCharSet(CharSet s)
 {
     this.cset = s;
 }
コード例 #10
0
ファイル: Gen.cs プロジェクト: dw4dev/Phalanger
		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(']');
		}