Beispiel #1
0
 private bool ReadSwitch(StringReader p, ref CodeBlock block)
 {
     if (p.ThisWord("switch"))
     {
         var jsswitch = new SwitchCode();
         ReqText(p, "(");
         ReqVal(p, out jsswitch.Arg);
         ReqText(p, ")");
         ReqText(p, "{");
         while (ReadCase(p, jsswitch)) ;
         if (p.ThisWord("default"))
         {
             ReqText(p, ":");
             ReadCodes(p, ref jsswitch.Default);
         }
         ReqText(p, "}");
         AddCode(ref block, jsswitch);
         return true;
     }
     return false;
 }
Beispiel #2
0
 private bool ReadCase(StringReader p, SwitchCode jsswitch)
 {
     if (p.ThisWord("case"))
     {
         var jscase = new SwitchCaseCode();
         ReqVal(p, out jscase.Test);
         ReqText(p, ":");
         ReadCodes(p, ref jscase.Code);
         (jsswitch.Cases ?? (jsswitch.Cases = new List<SwitchCaseCode>())).Add(jscase);
         return true;
     }
     return false;
 }