Пример #1
0
 void MulExpr(out NBase res)
 {
     res = null; NBase right = null;
     UnaryExpr(out res);
     while (la.kind == 35 || la.kind == 36 || la.kind == 37)
     {
         if (la.kind == 35)
         {
             Get();
             UnaryExpr(out right);
             res = new NBinary(NBinary.NKind.Mul, res, right);
         }
         else if (la.kind == 36)
         {
             Get();
             UnaryExpr(out right);
             res = new NBinary(NBinary.NKind.Div, res, right);
         }
         else
         {
             Get();
             UnaryExpr(out right);
             res = new NBinary(NBinary.NKind.Mod, res, right);
         }
     }
 }
Пример #2
0
 void AtomRootExpr(out NBase res)
 {
     res = null;
     if (Mode == ParserMode.BindingExpr)
     {
         AtomExpr(out res);
     }
     else if (Mode == ParserMode.BindingBackExpr)
     {
         Back_AtomExpr(out res);
     }
     else if (Mode == ParserMode.CommandExecute)
     {
         Execute_AtomExpr(out res);
     }
     else if (Mode == ParserMode.CommandCanExecute)
     {
         CanExecute_AtomExpr(out res);
     }
     else if (Mode == ParserMode.Event)
     {
         Event_AtomExpr(out res);
     }
     else
     {
         SynErr(75);
     }
 }
Пример #3
0
 void Back_Assign(out NBase res) {
  res = null; NBase left; NBase expr;
  Back_AssignLeft(out left);
  Expect(65);
  Expr(out expr);
  res = new NAssign((NIdentBase)left, expr);
 }
Пример #4
0
 void Back_AssignLeft(out NBase res)
 {
     res = null;
     if (StartOf(6))
     {
         RelativeExpr(out res);
     }
     else if (la.kind == 1)
     {
         IdentExpr(out res);
     }
     else if (la.kind == 59)
     {
         IndexExpr(out res);
     }
     else if (la.kind == 40)
     {
         Get();
         TypeIdentExpr(out res, false);
         ((NType)res).Kind = NType.NKind.Attached;
         Expect(41);
     }
     else
     {
         SynErr(87);
     }
     ReadNextIdents(ref res, false);
 }
Пример #5
0
 void ShiftExpr(out NBase res)
 {
     res = null; NBase right = null;
     AddExpr(out res);
     while (StartOf(4))
     {
         if (la.kind == 29 || la.kind == 30)
         {
             if (la.kind == 29)
             {
                 Get();
             }
             else
             {
                 Get();
             }
             AddExpr(out right);
             res = new NBinary(NBinary.NKind.ShiftLeft, res, right);
         }
         else
         {
             if (la.kind == 31)
             {
                 Get();
             }
             else
             {
                 Get();
             }
             AddExpr(out right);
             res = new NBinary(NBinary.NKind.ShiftRight, res, right);
         }
     }
 }
Пример #6
0
 void EqlExpr(out NBase res)
 {
     res = null; NBase right = null;
     RelExpr(out res);
     while (StartOf(2))
     {
         if (la.kind == 15 || la.kind == 16)
         {
             if (la.kind == 15)
             {
                 Get();
             }
             else
             {
                 Get();
             }
             RelExpr(out right);
             res = new NBinary(NBinary.NKind.NotEqual, res, right);
         }
         else
         {
             if (la.kind == 17)
             {
                 Get();
             }
             else
             {
                 Get();
             }
             RelExpr(out right);
             res = new NBinary(NBinary.NKind.Equal, res, right);
         }
     }
 }
Пример #7
0
 void TypeOfExpr(out NBase res) {
  Expect(56);
  Expect(40);
  TypeExpr(out res);
  Expect(41);
  ((NType)res).Kind = NType.NKind.TypeOf;
 }
Пример #8
0
 void TypeExpr(out NBase res)
 {
     res = null; string type = string.Empty;
     if (TokenEquals(1, NType.PrimitiveTypes))
     {
         Expect(1);
         type = t.val;
     }
     else if (la.kind == 58)
     {
         Get();
         Expect(1);
         type = t.val;
         if (la.kind == 6)
         {
             Get();
             Expect(1);
             type = type + ":" + t.val;
         }
     }
     else
     {
         SynErr(74);
     }
     res = new NType(type, null, NType.NKind.Type, null);
     if (la.kind == 5)
     {
         Get();
         ((NType)res).IsNullable = true;
     }
 }
Пример #9
0
 void Event_AtomExpr(out NBase res) {
  res = null;
  if (StartOf(5)) {
   ConstExpr(out res);
  } else if (StartOf(8)) {
   Event_RelativeExpr(out res);
  } else if (la.kind == 56) {
   TypeOfExpr(out res);
  } else if (NextIs_TypeExpr(1)) {
   TypeIdentExpr(out res, true);
  } else if (NextIs_MethodExpr(1)) {
   MethodExpr(out res);
  } else if (la.kind == 1) {
   IdentExpr(out res);
  } else if (la.kind == 59) {
   IndexExpr(out res);
  } else if (la.kind == 40) {
   Get();
   if (NextIs_TypeExpr(1)) {
    TypeIdentExpr(out res, false);
    ((NType)res).Kind = NType.NKind.Attached;
   } else if (StartOf(1)) {
    Expr(out res);
   } else SynErr(81);
   Expect(41);
  } else SynErr(82);
  ReadNextIdents(ref res, true);
 }
Пример #10
0
 void UnaryExpr(out NBase res) {
  res = null; List<NUnaryBase> ops = new List<NUnaryBase>();
  while (StartOf(1)) {
   if (la.kind == 33) {
    Get();
    ops.Add(new NUnary(NUnary.NKind.Plus, null));
   } else if (la.kind == 34) {
    Get();
    ops.Add(new NUnary(NUnary.NKind.Minus, null));
   } else if (la.kind == 38) {
    Get();
    ops.Add(new NUnary(NUnary.NKind.Not, null));
   } else if (la.kind == 39) {
    Get();
    ops.Add(new NUnary(NUnary.NKind.Not, null));
   } else if (NextIs_TypeExprWrapped(1, "(", ")")) {
    Expect(40);
    NBase type;
    TypeExpr(out type);
    ops.Add(new NCast(NCast.NKind.Cast, null, (NType)type));
    Expect(41);
   } else {
    break;
   }
  }
  AtomRootExpr(out res);
  for(int i = 0; i < ops.Count - 1; i++) ops[i].Value = ops[i+1];
  if(ops.Count > 0) { ops.Last().Value = res; res = ops.First(); }
 }
Пример #11
0
 void RelExpr(out NBase res) {
  res = null; NBase right = null;
  ShiftExpr(out res);
  while (StartOf(3)) {
   switch (la.kind) {
   case 19: case 20: {
    if (la.kind == 19) {
     Get();
    } else {
     Get();
    }
    ShiftExpr(out right);
    res = new NBinary(NBinary.NKind.Less, res, right);
    break;
   }
   case 21: case 22: {
    if (la.kind == 21) {
     Get();
    } else {
     Get();
    }
    ShiftExpr(out right);
    res = new NBinary(NBinary.NKind.Greater, res, right);
    break;
   }
   case 23: case 24: {
    if (la.kind == 23) {
     Get();
    } else {
     Get();
    }
    ShiftExpr(out right);
    res = new NBinary(NBinary.NKind.LessOrEqual, res, right);
    break;
   }
   case 25: case 26: {
    if (la.kind == 25) {
     Get();
    } else {
     Get();
    }
    ShiftExpr(out right);
    res = new NBinary(NBinary.NKind.GreaterOrEqual, res, right);
    break;
   }
   case 27: {
    Get();
    TypeExpr(out right);
    res = new NCast(NCast.NKind.Is, res, (NType)right);
    break;
   }
   case 28: {
    Get();
    TypeExpr(out right);
    res = new NCast(NCast.NKind.As, res, (NType)right);
    break;
   }
   }
  }
 }
Пример #12
0
        void ReadNextIdents(ref NBase n, bool allowMethod)
        {
            NIdentBase cur = n as NIdentBase; NBase next = null;

            while (la.kind == 59)
            {
                IndexExpr(out next);
                if (cur == null)
                {
                    cur = (NIdentBase)(n = new NExprIdent(n, null));
                }
                cur = cur.Next = (NIdentBase)next;
            }
            while (la.kind == 57)
            {
                NextIdentExpr(out next, allowMethod);
                if (cur == null)
                {
                    cur = (NIdentBase)(n = new NExprIdent(n, null));
                }
                cur = cur.Next = (NIdentBase)next;
                while (la.kind == 59)
                {
                    IndexExpr(out next);
                    cur = cur.Next = (NIdentBase)next;
                }
            }
        }
Пример #13
0
 public NTernary(NKind kind, NBase first, NBase second, NBase third)
 {
     Kind   = kind;
     First  = first;
     Second = second;
     Third  = third;
 }
Пример #14
0
 void Back_AtomExpr(out NBase res)
 {
     res = null;
     if (StartOf(5))
     {
         ConstExpr(out res);
     }
     else if (la.kind == 66 || la.kind == 67)
     {
         Back_RelativeValueExpr(out res);
     }
     else if (la.kind == 56)
     {
         TypeOfExpr(out res);
     }
     else if (NextIs_TypeExpr(1))
     {
         TypeIdentExpr(out res, true);
     }
     else if (la.kind == 40)
     {
         Get();
         Expr(out res);
         Expect(41);
     }
     else
     {
         SynErr(78);
     }
     ReadNextIdents(ref res, true);
 }
Пример #15
0
 void Back_AtomExpr(out NBase res)
 {
     res = null;
     if (StartOf(5))
     {
         ConstExpr(out res);
     }
     else if (la.kind == 67 || la.kind == 68)
     {
         Back_RelativeValueExpr(out res);
     }
     else if (la.kind == 58)
     {
         TypeOfExpr(out res);
     }
     else if (la.kind == 61)
     {
         TypeNewExpr(out res);
     }
     else if (NextIs_TypeExpr(1))
     {
         TypeIdentExpr(out res, true);
     }
     else if (la.kind == 42)
     {
         Get();
         Expr(out res);
         Expect(43);
     }
     else
     {
         SynErr(80);
     }
     ReadNextIdents(ref res, true);
 }
Пример #16
0
 void Execute_AtomExpr(out NBase res)
 {
     res = null;
     if (StartOf(5))
     {
         ConstExpr(out res);
     }
     else if (StartOf(7))
     {
         Execute_RelativeExpr(out res);
     }
     else if (la.kind == 58)
     {
         TypeOfExpr(out res);
     }
     else if (la.kind == 61)
     {
         TypeNewExpr(out res);
     }
     else if (NextIs_TypeExpr(1))
     {
         TypeIdentExpr(out res, true);
     }
     else if (NextIs_MethodExpr(1))
     {
         MethodExpr(out res);
     }
     else if (la.kind == 1)
     {
         IdentExpr(out res);
     }
     else if (la.kind == 62)
     {
         IndexExpr(out res);
     }
     else if (la.kind == 42)
     {
         Get();
         if (NextIs_TypeExpr(1))
         {
             TypeIdentExpr(out res, false);
             ((NType)res).Kind = NType.NKind.Attached;
         }
         else if (StartOf(1))
         {
             Expr(out res);
         }
         else
         {
             SynErr(81);
         }
         Expect(43);
     }
     else
     {
         SynErr(82);
     }
     ReadNextIdents(ref res, true);
 }
Пример #17
0
 void MethodExpr(out NBase res)
 {
     res = null; string name; NArgs args;
     Expect(1);
     name = t.val;
     MethodArgsExpr(out args);
     res = new NMethod(name, null, args);
 }
Пример #18
0
 void TypeNewExpr(out NBase res)
 {
     res = null; NBase type; NArgs args;
     Expect(61);
     TypeExpr(out type);
     MethodArgsExpr(out args);
     res = new NNew((NType)type, null, args);
 }
Пример #19
0
 void TypeOfExpr(out NBase res)
 {
     Expect(58);
     Expect(42);
     TypeExpr(out res);
     Expect(43);
     ((NType)res).Kind = NType.NKind.TypeOf;
 }
Пример #20
0
 void Back_RelativeValueExpr(out NBase res) {
  res = null;
  if (la.kind == 66) {
   Get();
  } else if (la.kind == 67) {
   Get();
  } else SynErr(88);
  res = new NRelative(t.val, null, NRelative.NKind.Value);
 }
Пример #21
0
 void NullCoalescingExpr(out NBase res) {
  res = null; NBase right = null;
  OrExpr(out res);
  while (la.kind == 7) {
   Get();
   OrExpr(out right);
   res = new NBinary(NBinary.NKind.Coalesce, res, right);
  }
 }
Пример #22
0
 void BitAndExpr(out NBase res) {
  res = null; NBase right = null;
  EqlExpr(out res);
  while (la.kind == 14) {
   Get();
   EqlExpr(out right);
   res = new NBinary(NBinary.NKind.And, res, right);
  }
 }
Пример #23
0
 void Execute_RelativeExpr(out NBase res) {
  res = null;
  if (StartOf(6)) {
   RelativeExpr(out res);
  } else if (la.kind == 68) {
   Get();
   res = new NRelative(t.val, null, NRelative.NKind.Parameter);
  } else SynErr(90);
 }
Пример #24
0
 void BitXorExpr(out NBase res) {
  res = null; NBase right = null;
  BitAndExpr(out res);
  while (la.kind == 13) {
   Get();
   BitAndExpr(out right);
   res = new NBinary(NBinary.NKind.Xor, res, right);
  }
 }
Пример #25
0
 void ConditionExpr(out NBase res) {
  res = null; NBase second = null; NBase third = null;
  NullCoalescingExpr(out res);
  if (la.kind == 5) {
   Get();
   Expr(out second);
   Expect(6);
   Expr(out third);
   res = new NTernary(NTernary.NKind.Condition, res, second, third);
  }
 }
Пример #26
0
 void Event_RelativeExpr(out NBase res) {
  res = null;
  if (StartOf(6)) {
   RelativeExpr(out res);
  } else if (la.kind == 69) {
   Get();
   res = new NRelative(t.val, null, NRelative.NKind.Sender);
  } else if (la.kind == 70) {
   Get();
   res = new NRelative(t.val, null, NRelative.NKind.Args);
  } else SynErr(92);
 }
Пример #27
0
 void TypeIdentExpr(out NBase res, bool allowMethod) {
  res = null; NBase ident = null;
  TypeExpr(out res);
  Expect(57);
  ((NType)res).Kind = NType.NKind.Static;
  if (allowMethod && NextIs_MethodExpr(1)) {
   MethodExpr(out ident);
  } else if (la.kind == 1) {
   IdentExpr(out ident);
  } else SynErr(85);
  ((NType)res).Ident = (NIdentBase)ident;
 }
Пример #28
0
 void OrExpr(out NBase res) {
  res = null; NBase right = null;
  AndExpr(out res);
  while (la.kind == 8 || la.kind == 9) {
   if (la.kind == 8) {
    Get();
   } else {
    Get();
   }
   AndExpr(out right);
   res = new NBinary(NBinary.NKind.OrElse, res, right);
  }
 }
Пример #29
0
 void AndExpr(out NBase res) {
  res = null; NBase right = null;
  BitOrExpr(out res);
  while (la.kind == 10 || la.kind == 11) {
   if (la.kind == 10) {
    Get();
   } else {
    Get();
   }
   BitOrExpr(out right);
   res = new NBinary(NBinary.NKind.AndAlso, res, right);
  }
 }
Пример #30
0
 void IndexExpr(out NBase res) {
  res = null; List<NBase> args = new List<NBase>(); NBase arg = null;
  Expect(59);
  Expr(out arg);
  args.Add(arg);
  while (la.kind == 55) {
   Get();
   Expr(out arg);
   args.Add(arg);
  }
  Expect(60);
  res = new NIndex(null, args.ToArray());
 }