Esempio n. 1
0
        private void Brackets()
        {
            int a = 0;

            while (a != tokens.Count && tokens[a].type != Types.OBRACKET)
            {
                a++;
            }
            if (a != tokens.Count)
            {
                //token t = new token();
                //t.type = Types.CBRACKET;
                //t.val = ")";
                int b = a;
                while (b != tokens.Count && tokens[b].type != Types.CBRACKET)
                {
                    if (tokens[b].val != "(")
                    {
                        b++;
                    }
                    else
                    {
                        a = b;
                        b++;
                    }
                }
                if (b != 0)
                {
                    TokenList tok = SubList(a + 1, b - 1);
                    double    res = tok.GetResult();
                    token     w   = new token();
                    w.type = Types.NUM;
                    w.val  = res.ToString();
                    Replace(a, b, w);
                }
            }
        }
Esempio n. 2
0
 public Parser()
 {
     tokens = new TokenList();
 }