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(); }
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); }
public RawMultiplierParser(RawMultiplier rawMultiplier) { this.rawMultiplier = rawMultiplier; }
public void Parse(RawMultiplier rawMultiplier) { RawMultiplierParser parser = new RawMultiplierParser(rawMultiplier); this.expressions = parser.Parse(); }
public Multiplier(RawMultiplier rawMultiplier) { this.rawMultiplier = rawMultiplier; this.coeff = rawMultiplier.coeff; this.Parse(rawMultiplier); }