예제 #1
0
 void Term(out ScriptVar v)
 {
     v = new ScriptVar(); var callOffset = int.MaxValue; var isCall = false;
     if (la.kind == 1)
     {
         Get();
         var identName = t.val;
         if (la.kind == 5)
         {
             Get();
             ScriptVar p; isCall = true; if (!_isParsing)
             {
                 callOffset = CallParams.Count;
             }
             if (StartOf(2))
             {
                 Expr(out p);
                 if (!_isParsing)
                 {
                     CallParams.Add(p);
                 }
                 while (la.kind == 6)
                 {
                     Get();
                     Expr(out p);
                     if (!_isParsing)
                     {
                         CallParams.Add(p);
                     }
                 }
             }
             Expect(7);
         }
         if (isCall)
         {
             if (!Vars.IsHostFunctionExists(identName))
             {
                 SemErr(string.Format("Cant find host function with name '{0}'", identName));
             }
         }
         if (!_isParsing)
         {
             if (isCall)
             {
                 CallParamsOffset = callOffset;
                 v = Vars.CallHostFunction(identName);
                 while (CallParams.Count > callOffset)
                 {
                     CallParams.RemoveAt(CallParams.Count - 1);
                 }
             }
             else
             {
                 if (!Vars.IsVarExists(t.val))
                 {
                     SemErr(string.Format("Variable '{0}' not found", identName));
                 }
                 v = Vars.GetVar(identName);
             }
         }
     }
     else if (la.kind == 2)
     {
         Get();
         if (!_isParsing)
         {
             v.AsNumber = t.val.ToFloatUnchecked();
         }
     }
     else if (la.kind == 3)
     {
         Get();
         if (!_isParsing)
         {
             v.AsString = t.val;
         }
     }
     else
     {
         SynErr(35);
     }
 }