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); } } }
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); } }
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); }
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); }
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); } } }
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); } } }
void TypeOfExpr(out NBase res) { Expect(56); Expect(40); TypeExpr(out res); Expect(41); ((NType)res).Kind = NType.NKind.TypeOf; }
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; } }
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); }
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(); } }
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; } } } }
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; } } }
public NTernary(NKind kind, NBase first, NBase second, NBase third) { Kind = kind; First = first; Second = second; Third = third; }
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); }
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); }
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); }
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); }
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); }
void TypeOfExpr(out NBase res) { Expect(58); Expect(42); TypeExpr(out res); Expect(43); ((NType)res).Kind = NType.NKind.TypeOf; }
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); }
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); } }
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); } }
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); }
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); } }
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); } }
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); }
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; }
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); } }
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); } }
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()); }