public Cons_2_1(Parser yyq) : base(yyq) { cs0syntax cs0syntax = (cs0syntax)yyq; if (((TOKEN)yyq.StackAt(4).m_value).yytext.Trim() != cs0syntax.Cls) { this.yytext = ((TOKEN)yyq.StackAt(4).m_value).yytext + "(" + ((TOKEN)yyq.StackAt(2).m_value).yytext + ")"; } else { if (((TOKEN)yyq.StackAt(2).m_value).yytext.Length == 0) { this.yytext = ((TOKEN)yyq.StackAt(4).m_value).yytext + "(" + cs0syntax.Ctx + ")"; cs0syntax.defconseen = true; } else { this.yytext = ((TOKEN)yyq.StackAt(4).m_value).yytext + "(" + cs0syntax.Ctx + "," + ((TOKEN)yyq.StackAt(2).m_value).yytext + ")"; } if (((TOKEN)yyq.StackAt(0).m_value).yytext.Length == 0) { Cons_2_1 cons21 = this; cons21.yytext = cons21.yytext + ":base(" + cs0syntax.Par + ")"; } else { Cons_2_1 cons21 = this; cons21.yytext = cons21.yytext + ":" + ((TOKEN)yyq.StackAt(0).m_value).yytext.Substring(0, 4) + "(" + cs0syntax.Par + "," + ((TOKEN)yyq.StackAt(0).m_value).yytext.Substring(4) + ")"; } } }
public int EmitClassDefin(string b,ref int p,int max,CsReader inf,string defbas,out string bas, out string name,bool lx) { bool defconseen = false; name = ""; bas = defbas; if (lx) NonWhite(b,ref p,max); White(b,ref p,max); for(;p<max&&b[p]!='{'&&b[p]!=':'&&b[p]!=';'&&b[p]!=' '&&b[p]!='\t'&&b[p]!='\n';p++) name += b[p]; White(b,ref p,max); if (b[p]==':') { p++; White(b,ref p,max); for(bas="";p<max&&b[p]!=' '&&b[p]!='{'&&b[p]!='\t'&&b[p]!=';'&&b[p]!='\n';p++) bas += b[p]; } int num = new TokClassDef(this,name,bas).m_yynum; m_outFile.WriteLine("//%+{0}+{1}",name,num); m_outFile.Write("public class "); m_outFile.Write(name); m_outFile.Write(" : "+bas); m_outFile.WriteLine("{"); do { if (p>=max) { b += inf.ReadLine(); max = b.Length; } White(b,ref p,max); } while (p>=max); if (b[p]!=';') { cs0syntax syms = new cs0syntax(new yycs0syntax(),erh); cs0tokens tks = (cs0tokens)syms.m_lexer; tks.Out = m_outname; // syms.m_debug = true; syms.Cls = name; syms.Out = m_outname; if (lx) { syms.Ctx = "Lexer yyl"; syms.Par = "yym"; } else { syms.Ctx = "Parser yyp"; syms.Par = "yyq"; } string str = ToBraceIfFound(ref b,ref p, ref max,inf); TOKEN s = null; try // 4.7c { s = (TOKEN)syms.Parse(str); } catch (Exception) {} if (s==null) { Error(48,p,"Bad class definition for "+name); return -1; } s.yytext = s.yytext.Replace("yyq","(("+m_outname+")yyp)"); s.yytext = s.yytext.Replace("yym","(("+m_outname+")yyl)"); string[] ss = s.yytext.Split('\n'); for (int j=0;j<ss.Length;j++) m_outFile.WriteLine(ss[j]); defconseen = syms.defconseen; } m_outFile.WriteLine("public override string yyname { get { return \""+name+"\"; }}"); m_outFile.WriteLine("public override int yynum { get { return "+num+"; }}"); if (!defconseen) { if (lx) m_outFile.Write("public "+name+"(Lexer yyl):base(yyl){}"); else m_outFile.Write("public "+name+"(Parser yyp):base(yyp){}"); } m_outFile.WriteLine("}"); return num; }