void MulExpr(out OqlExpression expression) { OqlExpression child; OqlExpression result = new OqlExpression(la.line, la.col); string newOp = null; Unary(out child); result.Add(child); while (StartOf(4)) { if (la.kind == 33) { Get(); newOp = "*"; } else if (la.kind == 34) { Get(); newOp = "/"; } else if (la.kind == 35) { Get(); newOp = "%"; } else { Get(); newOp = "MOD"; } Unary(out child); result.Add(child, newOp); } expression = result.Simplify(); }
void Unary(out OqlExpression expression) { OqlExpression child; OqlExpression result = new OqlExpression(la.line, la.col); string newOp = null; if (la.kind == 31 || la.kind == 32 || la.kind == 36) { if (la.kind == 31) { Get(); newOp = "+"; } else if (la.kind == 32) { Get(); newOp = "-"; } else { Get(); newOp = "~"; } } Primary(out child); result.Add(child); child.UnaryOp = newOp; expression = result.Simplify(); }
void AndExpr(out OqlExpression expression) { OqlExpression child; OqlExpression result = new OqlExpression(la.line, la.col); EqlExpr(out child); result.Add(child); while (la.kind == 5) { Get(); bool negated = false; if (la.kind == 7) { Get(); negated = true; } EqlExpr(out child); if (negated) { child.UnaryOp = "NOT"; } result.Add(child, "AND"); } expression = result.Simplify(); }
void AddExpr(out OqlExpression expression) { OqlExpression child; OqlExpression result = new OqlExpression(la.line, la.col); string newOp = null; MulExpr(out child); result.Add(child); while (la.kind == 31 || la.kind == 32) { if (la.kind == 31) { Get(); newOp = "+"; } else { Get(); newOp = "-"; } MulExpr(out child); result.Add(child, newOp); } expression = result.Simplify(); }
void BitAndExpr(out OqlExpression expression) { OqlExpression child; OqlExpression result = new OqlExpression(la.line, la.col); AddExpr(out child); result.Add(child); while (la.kind == 30) { Get(); AddExpr(out child); result.Add(child, "&"); } expression = result.Simplify(); }
void BitOrExpr(out OqlExpression expression) { OqlExpression child; OqlExpression result = new OqlExpression(la.line, la.col); BitXorExpr(out child); result.Add(child); while (la.kind == 28) { Get(); BitXorExpr(out child); result.Add(child, "|"); } expression = result.Simplify(); }
void RootExpr(out OqlExpression expression) { OqlExpression child; OqlExpression result = new OqlExpression(la.line, la.col); bool negated = false; if (la.kind == 7) { Get(); negated = true; } OrExpr(out child); if (negated) { result.UnaryOp = "NOT"; } result.Add(child); expression = result.Simplify(); }
void RelExpr(out OqlExpression expression) { OqlExpression child; OqlExpression result = new OqlExpression(la.line, la.col); string newOp = null; bool negated = false; BitOrExpr(out child); result.Add(child); if (StartOf(2)) { if (StartOf(3)) { switch (la.kind) { case 22: { Get(); newOp = "<"; break; } case 23: { Get(); newOp = ">"; break; } case 24: { Get(); newOp = "<="; break; } case 25: { Get(); newOp = ">="; break; } case 26: { Get(); newOp = ">="; break; } case 27: { Get(); newOp = "<="; break; } } BitOrExpr(out child); result.Add(child, newOp); } else if (la.kind == 11) { Get(); if (la.kind == 7) { Get(); negated = true; } Expect(12); result.Add(new NamedConstantExpression("NULL", negated, t.line, t.col), "IS"); } else { if (la.kind == 7) { Get(); negated = true; } Expect(10); BitOrExpr(out child); result.Add(child, "BETWEEN"); Expect(5); BitOrExpr(out child); result.Add(child, "BETWEEN"); } } expression = result.Simplify(); }
void EqlExpr(out OqlExpression expression) { OqlExpression child; OqlExpression result = new OqlExpression(la.line, la.col); string newOp = null; bool negated = false; if (!(scanner.Peek().kind == _IN)) { RelExpr(out child); result.Add(child); while (StartOf(1)) { if (la.kind == 17) { Get(); newOp = "<>"; } else if (la.kind == 18) { Get(); newOp = "<>"; } else if (la.kind == 19) { Get(); newOp = "="; if (la.kind == 7) { Get(); negated = true; } } else { Get(); newOp = "LIKE"; } RelExpr(out child); if (negated) { child.UnaryOp = "NOT"; } result.Add(child, newOp); } } else if (la.kind == 1) { Identifier(out child); result.Add(child); Expect(15); Expect(20); if (la.kind == 2 || la.kind == 3) { NumList(out child); child.HasBrackets = true; result.Add(child, "IN"); } else if (la.kind == 4) { StringList(out child); child.HasBrackets = true; result.Add(child, "IN"); } else { SynErr(40); } Expect(21); } else { SynErr(41); } expression = result.Simplify(); }