Example #1
0
        public void Analyser(string expression)
        {
            var pos = expression.LastIndexOf('+');
            if (pos == -1) {
                pos = expression.LastIndexOf('-');
            }

            if (pos == -1) { // Valeur
                this.Droite = new Atome();
                this.Droite.Analyser(expression);
                this.Gauche = null;
            } else { // Multiplication + Valeur
                this.Gauche = new Addition();
                this.Gauche.Analyser(expression.Substring(0, pos - 1));
                this.Droite = new Atome();
                this.Droite.Analyser(expression.Substring(pos + 1));
            }
        }
Example #2
0
        public void Analyser(string expression)
        {
            var pos = expression.LastIndexOf('+');

            if (pos == -1)
            {
                pos = expression.LastIndexOf('-');
            }

            if (pos == -1)   // Valeur
            {
                this.Droite = new Atome();
                this.Droite.Analyser(expression);
                this.Gauche = null;
            }
            else     // Multiplication + Valeur
            {
                this.Gauche = new Addition();
                this.Gauche.Analyser(expression.Substring(0, pos - 1));
                this.Droite = new Atome();
                this.Droite.Analyser(expression.Substring(pos + 1));
            }
        }