public bool DoSL(Parser p) { bool flag = false; var g = guard as Guard; g.Eval(p); if (g.GetBool(p)) { expr.Eval(p); flag = true; } return(flag); }
public override Node Eval(Parser p) { try { lhs.Eval(p); rhs.Eval(p); double lVal = this.lhs.GetValue(p); double rVal = this.rhs.GetValue(p); switch (this.Tag) { case NodeTag.div: value = lVal / rVal; break; case NodeTag.minus: value = lVal - rVal; break; case NodeTag.plus: value = lVal + rVal; break; case NodeTag.rem: value = lVal % rVal; break; case NodeTag.mul: value = lVal * rVal; break; default: throw new Exception("bad tag"); } } finally { this.Epilog(); } return(this); }
public override Node Eval(Parser p) { remain.Eval(p); var sls = remain as SLNode; if (sls != null) { bool flag = true; while (flag) { flag = sls.DoSL(p); } } else { bool flag = true; while (flag) { flag = (remain as Cond).DoSL(p); } } return(this); }
public override Node Eval(Parser p) { lhs.Eval(p); rhs.Eval(p); value = Check(op, lhs.GetValue(p), rhs.GetValue(p)); return(this); }
public override Node Eval(Parser p) { try { child.Eval(p); value = -child.GetValue(p); return(this); } finally { this.Epilog(); } }
private void Display(Node node) { try { double result = node.Eval(this); Console.WriteLine("result: " + result.ToString()); } catch (CircularEvalException) { Scanner.yyerror("Eval has circular dependencies"); } catch { Scanner.yyerror("Invalid expression evaluation"); } }
private double Eval(Node node) { try { return(node.Eval(this)); } catch (CircularEvalException) { Scanner.yyerror("Eval has circular dependencies"); } catch { Scanner.yyerror("Invalid expression evaluation"); } return(0.0); }
public override Node Eval(Parser p) { try { lhs.Eval(p); rhs.Eval(p); } finally { this.Epilog(); } return(this); }
public override Node Eval(Parser p) { remain.Eval(p); var sls = remain as SLNode; bool flag = false; if (sls != null) { flag = sls.DoSL(p); } else { flag = (remain as Cond).DoSL(p); } if (!flag) { Console.WriteLine("ERRRRRRORRRR IFFFF ALLLLL FAAAAAAAAALSSSSEEEEE"); } return(this); }
public override Node Eval(Parser p) { try { id.Eval(p); expr.Eval(p); if (remain == null) { var l = id as Leaf; idList.Add(l); exprList.Add(expr); } else { NextAssign = remain as AssignNode; NextAssign.isChild = true; NextAssign.Eval(p); List <Leaf> k = new List <Leaf>(); List <Node> kk = new List <Node>(); k.Add(id as Leaf); for (int i = 0; i < NextAssign.idList.Count; i++) { k.Add(NextAssign.idList[i]); } for (int i = 0; i < NextAssign.idList.Count; i++) { kk.Add(NextAssign.exprList[i]); } kk.Add(expr); idList = k; exprList = kk; } if (!isChild) { Dictionary <string, double> nDic = new Dictionary <string, double>(); for (int i = 0; i < idList.Count; i++) { idList[i].Eval(p); exprList[i].Eval(p); nDic[idList[i].name] = exprList[i].GetValue(p); } foreach (var dd in nDic) { p.idInitDic[dd.Key] = true; p.idDic[dd.Key] = dd.Value; } } } catch (Exception e) { } return(this); }
public override Node Eval(Parser p) { guard.Eval(p); return(this); }