Esempio n. 1
0
 public void GenParserMethods(CSharpWriter csw)
 {
     Rule.Chain.WriteParserMembers(csw, this);
     csw.Method(Rule.GetResultType(), Rule.ParseFuncName);
     csw.WriteLine("var args = new {0}();", Rule.ArgsClassName);
     csw.WriteLine("bool ok = {0}(args);", Rule.Chain.ParseFuncName);
     csw.Begin("if (ok)");
     csw.WriteLine("var res = new {0}();", Rule.GetResultType());
     foreach (var vd in Vars)
     {
         csw.WriteLine("res.{0} = args.{0};", vd.Name);
         if (vd.TypeGroup == VariableTypeGroup.SubNode)
         {
             csw.WriteLine("if (res.{0} != null) res.{0}.Parent = res;", vd.Name);
         }
     }
     csw.WriteLine("return res;");
     csw.End(); // if (ok)
     csw.WriteLine("return null;");
     csw.End(); // method
 }