コード例 #1
0
ファイル: TestParser.cs プロジェクト: marcpiulachs/noahylk
        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);
        }
コード例 #2
0
ファイル: TestParser.cs プロジェクト: marcpiulachs/noahylk
        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);
        }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
ファイル: CalcEngine.cs プロジェクト: marcpiulachs/noahylk
 private SyntaxTreeNode GetTree(string exp)
 {
     Parser psr = new Parser(exp, this);
     psr.Parse();
     return psr.Tree;
 }
コード例 #5
0
ファイル: TestParser.cs プロジェクト: marcpiulachs/noahylk
 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();
 }
コード例 #6
0
ファイル: TestParser.cs プロジェクト: marcpiulachs/noahylk
 public void TestMethod2()
 {
     string exp = "1 + 2(3 - 4 - 5)";
     Parser ps = new Parser(exp);
     ps.Parse();
 }