using System; using System.IO; using System.Text; using YYClass; namespace Tools { public class GenBase { public ErrorHandler erh; protected GenBase(ErrorHandler eh) { erh = eh; } protected TextWriter m_outFile; protected Encoding m_scriptEncoding = Encoding.ASCII; protected bool toupper = false; protected string ScriptEncoding { set { m_scriptEncoding = Charset.GetEncoding(value,ref toupper,erh); } } public string m_outname = "tokens"; // convenience functions protected int Braces(int a,string b,ref int p,int max) { int rv = a; int quote = 0; for (;p0) { buf=inf.ReadLine(); if (buf==null) Error(47,q,"EOF in action or class def??"); max=buf.Length; p=0; rv += '\n'; brack = Braces(brack,buf,ref p,max); rv += buf.Substring(0,p); } return rv; } public bool White(string buf, ref int offset,int max) { while (offset=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 = (TOKEN)syms.Parse(str); if (s==null) { Error(48,p,"Bad class definition for "+name); return; } 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