コード例 #1
0
ファイル: Parsers.cs プロジェクト: nskrypnik/News360Test
        public IEnumerable <RawMultiplier> Iterator()
        {
            RawMultiplier output = null;

            foreach (char c in this.rawExpression.rawString)
            {
                switch (this.state)
                {
                case ParseStates.Start:
                    this.HandleStart(c);
                    break;

                case ParseStates.WaitSymbols:
                    this.HandleWaitSymbols(c);
                    break;

                case ParseStates.WaitOperand:
                    output = this.HandleWaitOperand(c);
                    break;

                case ParseStates.EscapeSymbols:
                    this.HandleEscapeSymbols(c);
                    break;
                }

                if (output != null)
                {
                    yield return(output);

                    output = null;
                }

                this.index++;
                this.globalIndex++;
            }

            yield return(this.Finalize());

            this.reset();
        }
コード例 #2
0
ファイル: Parsers.cs プロジェクト: nskrypnik/News360Test
        private RawMultiplier HandleWaitOperand(char c)
        {
            if (c == '+' || c == '-')
            {
                string rawBlockString = this.rawExpression
                                        .rawString.Substring(this.blockOffset, index - this.blockOffset);
                RawMultiplier output = new RawMultiplier(this.blockOffset, rawBlockString, this.coeff);
                // define coefficent
                this.coeff = (c == '-') ? -1 : 1;
                this.state = ParseStates.WaitSymbols;

                return(output);
            }
            else
            {
                if (c == '(')
                {
                    this.state = ParseStates.EscapeSymbols;
                }
            }

            return(null);
        }
コード例 #3
0
ファイル: Parsers.cs プロジェクト: nskrypnik/News360Test
 public RawMultiplierParser(RawMultiplier rawMultiplier)
 {
     this.rawMultiplier = rawMultiplier;
 }
コード例 #4
0
        public void Parse(RawMultiplier rawMultiplier)
        {
            RawMultiplierParser parser = new RawMultiplierParser(rawMultiplier);

            this.expressions = parser.Parse();
        }
コード例 #5
0
 public Multiplier(RawMultiplier rawMultiplier)
 {
     this.rawMultiplier = rawMultiplier;
     this.coeff         = rawMultiplier.coeff;
     this.Parse(rawMultiplier);
 }