当前位置: 首页>>代码示例>>C#>>正文


C# Tools.CSymbol类代码示例

本文整理汇总了C#中Tools.CSymbol的典型用法代码示例。如果您正苦于以下问题:C# CSymbol类的具体用法?C# CSymbol怎么用?C# CSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CSymbol类属于Tools命名空间,在下文中一共展示了CSymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SimpleAction

	public override void SimpleAction(ParserSimpleAction a) 
	{
		string str = a.yytext.Substring(1, a.yytext.Length-1);
		if (str=="null") 
		{
			m_lexer.yytext = "Null";
			a.m_sym = (new CSymbol(this)).Resolve();
			NewConstructor(ref a.m_sym,", "+m_prod.m_lhs.m_yynum+"){}");
			return;
		}
		if (str.Length==0)
			str = m_prod.m_lhs.yytext;
		CSymbol s = (CSymbol)m_symbols.symbols[str];
		if (s==null) 
		{ // not there: define a new node type
			//Console.WriteLine("Symbol {0} needs defining",str);
			m_lexer.yytext = str;
			s = new CSymbol(this);
			m_symbols.symbols[str] = s;
			s.m_symtype = CSymbol.SymType.nodesymbol;
			s.m_refSymbol = (CSymbol)m_prod.m_lhs;
			s.m_emitted = true;
			m_outFile.WriteLine("public class "+str+" : "+s.m_refSymbol.yytext+" { ");
			m_outFile.WriteLine("  public "+str+"(Parser yyq):base(yyq) { }}");
		} 
		else if (s.m_refSymbol!=null) // 4.5c
		{
			CSymbol t=s; // 4.5d
			while (t!=null && t!=(CSymbol)m_prod.m_lhs)
				t=t.m_refSymbol;
			if (t==null)
				Error(46,m_lexer.m_pch,"Simple action "+s.yytext+" does not match symbol type "+m_prod.m_lhs.yytext); // 4.5d
		}   // 4.5c
		else 
			s.m_refSymbol = (CSymbol)m_prod.m_lhs;
		a.m_sym = s;
		int ch;
		str = ")";
		NextNonWhite(out ch);
		if (ch=='(') 
		{
			ch = m_lexer.GetChar();
			str = ","+GetBracketedSeq(ref ch,')').Substring(1);
			NextNonWhite(out ch);
		}
		if (str==",)") // 4.0d
			str=")";
		string init = "{}";
		if (ch=='{') 
		{
			ch = m_lexer.GetChar();
			string ts = GetBracketedSeq(ref ch,'}');			   // 4.5g
			init = "{ "+m_outname+" yyp=("+m_outname+")yyq;\n"+ ts.Substring(1); // 4.5g 4.5h
			NextNonWhite(out ch);
		}
		init = str + init;
		NewConstructor(ref a.m_sym,init);
	}
开发者ID:Belxjander,项目名称:Asuna,代码行数:58,代码来源:pg.cs

示例2: GetParser

		public void GetParser(Lexer m_lexer)
		{
			Serialiser b = new Serialiser(arr);
			b.VersionCheck();
			m_startSymbol = (CSymbol)b.Deserialise();
			m_startSymbol.kids = new ObjectList(); // 4.2a
			m_accept = (ParseState)b.Deserialise();
			m_states = (Hashtable)b.Deserialise();
			literals = (Hashtable)b.Deserialise();
			symbolInfo = (Hashtable)b.Deserialise();
			m_concrete = (bool)b.Deserialise();
			GetEOF(m_lexer);
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:13,代码来源:parser.cs

示例3: Path

		public Path(ParseState q,CSymbol[] x) 
		{
			m_states = new ParseState[x.Length+1];
			ParseState c;
			c = m_states[0] = q;
			for (int j=0;j<x.Length;j++)
			{
				int k;
				for (k=j;k<x.Length;k++)
					if (!x[k].IsAction())
						break;
				if (k>=x.Length)
				{
					m_states[j+1] = c;
					continue;
				}
				Transition t = (Transition)c.m_transitions[x[k].yytext];
				if (t==null || t.m_next==null)
				{
					valid = false;
					break;
				}
				c = m_states[j+1] = t.m_next.m_next;
			}
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:25,代码来源:parser.cs

示例4: Contains

		public bool Contains(CSymbol a) { return m_set.Contains(a); }
开发者ID:Belxjander,项目名称:Asuna,代码行数:1,代码来源:parser.cs

示例5: ClassInit

		public void ClassInit(SymbolsGen yyp)   
		{
			Special = new CSymbol(yyp); Special.yytext="S'"; 
			EOFSymbol = new EOF(yyp).Resolve();
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:5,代码来源:parser.cs

示例6: Hashtable

		public Hashtable m_transitions = new Hashtable(); // string -> Transition
		public Transition GetTransition(CSymbol s)
		{
			Transition t = (Transition)m_transitions[s.yytext];
			if (t!=null)
				return t;
			return new Transition(this,s);
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:8,代码来源:parser.cs

示例7: NewConstructor

	// proxies for constructors
	internal void NewConstructor(ref CSymbol s,string str)
	{ // may update s to a new node type
		// we have just seen a new initialiser for s
		if (str.Length==0)
			return;
		CSymbol bas = s;
		string newname;
		for (int variant=1;;variant++)
		{ // get a genuinely new identifier
			newname = String.Format("{0}_{1}", bas.yytext, variant);
			s = (CSymbol)m_symbols.symbols[newname];
			if (s==null)
				break;
		}
		m_lexer.yytext = newname;
		s = (new CSymbol(this)).Resolve();
		s.m_symtype = CSymbol.SymType.nodesymbol;
		s.m_refSymbol = bas;
		s.m_emitted = true;
		m_outFile.WriteLine();
		m_outFile.WriteLine(@"/// <summary/>");
		m_outFile.WriteLine("public class "+newname+" : "+bas.yytext+" {");
		m_outFile.WriteLine(@"/// <summary/>");
		m_outFile.WriteLine(@"/// <param name='yyq'></param>");
		m_outFile.WriteLine("  public "+newname+"(Parser yyq):base(yyq"+str+"}");
	}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:27,代码来源:pg.cs

示例8: SimpleAction

	public override void SimpleAction(ParserSimpleAction a)
	{
		string str = a.yytext.Substring(1, a.yytext.Length-1);
		if (str=="null")
		{
			m_lexer.yytext = "Null";
			a.m_sym = (new CSymbol(this)).Resolve();
			NewConstructor(ref a.m_sym,",\""+m_prod.m_lhs.yytext+"\"){}");
			return;
		}
		if (str.Length==0)
			str = m_prod.m_lhs.yytext;
		CSymbol s = (CSymbol)m_symbols.symbols[str];
		if (s==null)
		{ // not there: define a new node type
			//Console.WriteLine("Symbol {0} needs defining",str);
			m_lexer.yytext = str;
			s = new CSymbol(this);
			m_symbols.symbols[str] = s;
			s.m_symtype = CSymbol.SymType.nodesymbol;
			s.m_refSymbol = (CSymbol)m_prod.m_lhs;
			s.m_emitted = true;
			m_outFile.WriteLine(@"/// <summary/>");
			m_outFile.WriteLine("public class "+str+" : "+s.m_refSymbol.yytext+" { ");
			m_outFile.WriteLine(@"/// <summary/>");
			m_outFile.WriteLine(@"/// <param name='yyq'></param>");
			m_outFile.WriteLine("  public "+str+"(Parser yyq):base(yyq) { }}");
		}
		a.m_sym = s;
		int ch;
		str = ")";
		NextNonWhite(out ch);
		if (ch=='(')
		{
			ch = m_lexer.GetChar();
			str = ","+GetBracketedSeq(ref ch,')').Substring(1);
			NextNonWhite(out ch);
		}
		if (str==",)") // 4.0d
			str=")";
		string init = "{}";
		if (ch=='{')
		{
			ch = m_lexer.GetChar();
			init = "yyp=("+m_outname+")yyq;\n"+ GetBracketedSeq(ref ch,'}');
			NextNonWhite(out ch);
		}
		init = str + init;
		NewConstructor(ref a.m_sym,init);
	}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:50,代码来源:pg.cs

示例9: ClassInit

		public void ClassInit(SymbolsGen yyp)
		{
			EmptySequence = new CSymbol(yyp); EmptySequence.yytext="e";
			Special = new CSymbol(yyp); Special.yytext="S'";
			EOFSymbol = new EOF(yyp).Resolve();
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:6,代码来源:parser.cs

示例10: PrecReference

	public PrecReference(Lexer lx,TOKEN t) : base(lx)
	{
		precref = ((CSymbol)t).Resolve();
		new SymbolType(((ptokens)lx).m_sgen,t.yytext,true);
	}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:5,代码来源:pg.cs

示例11: Print

		public override void Print(ParseState ps,CSymbol s)
		{
			base.Print(ps,s);
			Console.Write("  ");
			m_lookAhead.Print();
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:6,代码来源:parser.cs

示例12: Prefix

		public CSymbol[] Prefix(int i)
		{
			CSymbol[] r = new CSymbol[i];
			for (int j=0;j<i;j++)
				r[j] = (CSymbol)m_rhs[j];
			return r;
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:7,代码来源:parser.cs

示例13: Check

		public static int Check(CSymbol s, Production p, int d) 
		{
			if (s.m_prec==null)
				return 0;
			int a = CheckType(s.m_prec, PrecType.after,d+1);
			int b = CheckType(s.m_prec, PrecType.left,d+1);
			if (a>b)
				return a - p.m_prec;
			else
				return b - p.m_prec;
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:11,代码来源:parser.cs

示例14: SymbolType

		public SymbolType(SymbolsGen yyp,string name,bool defined) 
		{ 
			Lexer yyl = yyp.m_lexer;
			int p = name.IndexOf("+");
			int num = 0;
			if (p>0)
			{
				num = int.Parse(name.Substring(p+1));
				if (num> yyp.LastSymbol)
					yyp.LastSymbol = num;
				name = name.Substring(0,p);
			}
			yyl.yytext = name;
			CSymbol s = new CSymbol(yyp);
			if (num>0)
				s.m_yynum = num;
			s = s.Resolve();
			if (defined) 
				s.m_defined = true;
			m_name = name; m_next=yyp.stypes; yyp.stypes=this;
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:21,代码来源:parser.cs

示例15: CouldStart

		public bool CouldStart(CSymbol nonterm) { return false; }
开发者ID:Belxjander,项目名称:Asuna,代码行数:1,代码来源:parser.cs


注:本文中的Tools.CSymbol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。