public FSAFloat() { state = State.START; int_part = 0; frac_part = 0; frac_count = 0; exp_part = 0; suffix = TokenFloat.Suffix.NONE; exp_pos = true; raw = ""; }
public override sealed void ReadChar(Char ch) { raw += ch; switch (state) { case State.ERROR: case State.END: state = State.ERROR; break; case State.START: if (Char.IsDigit(ch)) { int_part = ch - '0'; state = State.D; } else if (ch == '.') { state = State.P; } else { state = State.ERROR; } break; case State.D: if (Char.IsDigit(ch)) { int_part *= 10; int_part += ch - '0'; state = State.D; } else if (ch == 'e' || ch == 'E') { state = State.DE; } else if (ch == '.') { state = State.DP; } else { state = State.ERROR; } break; case State.P: if (Char.IsDigit(ch)) { frac_part = ch - '0'; frac_count = 1; state = State.PD; } else { state = State.ERROR; } break; case State.DP: if (Char.IsDigit(ch)) { frac_part = ch - '0'; frac_count = 1; state = State.PD; } else if (ch == 'e' || ch == 'E') { state = State.DE; } else if (ch == 'f' || ch == 'F') { suffix = TokenFloat.Suffix.F; state = State.PDF; } else if (ch == 'l' || ch == 'L') { suffix = TokenFloat.Suffix.L; state = State.DPL; } else { state = State.END; } break; case State.PD: if (Char.IsDigit(ch)) { frac_part *= 10; frac_part += ch - '0'; frac_count++; state = State.PD; } else if (ch == 'e' || ch == 'E') { state = State.DE; } else if (ch == 'f' || ch == 'F') { suffix = TokenFloat.Suffix.F; state = State.PDF; } else if (ch == 'l' || ch == 'L') { suffix = TokenFloat.Suffix.L; state = State.DPL; } else { state = State.END; } break; case State.DE: if (Char.IsDigit(ch)) { exp_part = ch - '0'; state = State.DED; } else if (ch == '+' || ch == '-') { if (ch == '-') { exp_pos = false; } state = State.DES; } else { state = State.ERROR; } break; case State.DES: if (Char.IsDigit(ch)) { exp_part = ch - '0'; state = State.DED; } else { state = State.ERROR; } break; case State.DPL: suffix = TokenFloat.Suffix.L; state = State.END; break; case State.DED: if (Char.IsDigit(ch)) { exp_part *= 10; exp_part += ch - '0'; state = State.DED; } else if (ch == 'f' || ch == 'F') { suffix = TokenFloat.Suffix.F; state = State.PDF; } else if (ch == 'l' || ch == 'L') { suffix = TokenFloat.Suffix.L; state = State.DPL; } else { state = State.END; } break; case State.PDF: state = State.END; break; default: state = State.ERROR; break; } }
public override sealed void Reset() { state = State.START; int_part = 0; frac_part = 0; frac_count = 0; exp_part = 0; suffix = TokenFloat.Suffix.NONE; exp_pos = true; raw = ""; }
public ConstFloat(Double value, TokenFloat.Suffix suffix) { this.value = value; this.suffix = suffix; }