public void TestMethod3() { string exp = "1 + 2 * $s(#12, #24) + (@3 - @4 - 5) + $c(@11 >= 15, 100, 200)"; Parser ps = new Parser(exp); ps.Parse(); string expected = "1+2*$s(#12,#24)+(@3-@4-5)+$c(@11>=15,100,200)"; string res = ps.Tree.ToString(); Assert.AreEqual(expected, res); }
public void TestMethod1() { string exp = "1 + 2 * (3 - 4 - 5 - 6)"; Parser ps = new Parser(exp); ps.Parse(); string expected = "1+2*(3-4-5-6)"; string res = ps.Tree.ToString(); Assert.AreEqual(expected, res); Assert.AreEqual(-23.00, ps.Tree.Value); }
private bool CheckFomula() { try { Parser par = new Parser(exp); par.Parse(); List<string> loopPath = new List<string>(); if (fconv.HasLoopCalc(itemid, exp, loopPath)) { string curname = fconv.GetShownString(new Token(TokenType.Id, itemid)); string path = curname + " -> "; for (int i = loopPath.Count - 1; i >= 0; i--) { path += loopPath[i]; path += " -> "; } path += curname; MessageBox.Show("存在循环计算:" + path); return false; } return true; } catch (ParseException ex) { MessageBox.Show(ex.Message + fconv.GetShownString(ex.Token)); return false; } }
private SyntaxTreeNode GetTree(string exp) { Parser psr = new Parser(exp, this); psr.Parse(); return psr.Tree; }
public void TestMethod4() { string exp = "$1 + 2 * $s(#12, #24) + (@3 - @4 - 5) + $c(@11 >= 15, 100, 200)"; Parser ps = new Parser(exp); ps.Parse(); }
public void TestMethod2() { string exp = "1 + 2(3 - 4 - 5)"; Parser ps = new Parser(exp); ps.Parse(); }