コード例 #1
0
ファイル: Interpretator.cs プロジェクト: Vorontsova1347/Trees
 public NodeR(int Value)
 {
     Operation  = ' ';
     this.Value = Value;
     Right      = null;
     Left       = null;
 }
コード例 #2
0
ファイル: Interpretator.cs プロジェクト: Vorontsova1347/Trees
 public NodeR(char Operation, NodeR left, NodeR right)
 {
     this.Operation = Operation;
     this.Value     = 0;
     this.Left      = left;
     this.Right     = right;
 }
コード例 #3
0
ファイル: Interpretator.cs プロジェクト: Vorontsova1347/Trees
 public int Inter(string s)
 {
     PointError = new List <int>();
     Root       = null;
     FormTree(s);
     Root.GetValue();
     if (PointError.Count != 0)
     {
         throw new InputError();
     }
     return(Root.Value);
 }
コード例 #4
0
ファイル: Interpretator.cs プロジェクト: Vorontsova1347/Trees
        NodeR Expression(string s, ref int Cur)
        {
            try
            {
                DelGaps(s, ref Cur);
            }
            catch (InputError)
            {
                PointError.Add(Cur);
                throw new InputError();
            }
            NodeR A;

            try
            {
                A = ProcessNumber(s, ref Cur);
            }
            catch (InputError)
            {
                PointError.Add(Cur);
                A = new NodeR(0);
            }
            try
            {
                DelGaps(s, ref Cur);
            }
            catch (InputError)
            {
                return(A);
            }

            if (s[Cur] != '-' && s[Cur] != '+')
            {
                PointError.Add(Cur);
                Cur--;
                return(Expression(s, ref Cur));
            }
            else
            {
                Cur--;
                return(new NodeR(s[Cur + 1], A, Expression(s, ref Cur)));
                //1+2+3+4
            }
        }
コード例 #5
0
ファイル: Interpretator.cs プロジェクト: Vorontsova1347/Trees
        void FormTree(string s)
        {
            int Cur = s.Length - 1;

            Root = Expression(s, ref Cur);
        }