public override void Reset() { this._state = State.START; this._val = 0; this._raw = ""; this._suffix = TokenInt.IntSuffix.NONE; }
public FSAInt() { this._state = State.START; this._val = 0; this._raw = ""; this._suffix = TokenInt.IntSuffix.NONE; }
public override void ReadChar(Char ch) { this._raw += ch; switch (this._state) { case State.ERROR: case State.END: this._state = State.ERROR; break; case State.START: if (ch == '0') { this._state = State.Z; } else if (Char.IsDigit(ch)) { this._state = State.D; this._val += ch - '0'; } else { this._state = State.ERROR; } break; case State.Z: if (ch == 'x' || ch == 'X') { this._state = State.ZX; } else if (Utils.IsOctDigit(ch)) { this._val *= 8; this._val += ch - '0'; this._state = State.O; } else if (ch == 'u' || ch == 'U') { this._suffix = TokenInt.IntSuffix.U; this._state = State.U; } else if (ch == 'l' || ch == 'L') { this._suffix = TokenInt.IntSuffix.L; this._state = State.L; } else { this._state = State.END; } break; case State.D: if (Char.IsDigit(ch)) { this._val *= 10; this._val += ch - '0'; this._state = State.D; } else if (ch == 'u' || ch == 'U') { this._suffix = TokenInt.IntSuffix.U; this._state = State.U; } else if (ch == 'l' || ch == 'L') { this._suffix = TokenInt.IntSuffix.L; this._state = State.L; } else { this._state = State.END; } break; case State.ZX: if (Utils.IsHexDigit(ch)) { this._val *= 0x10; this._val += Utils.GetHexDigit(ch); this._state = State.H; } else { this._state = State.ERROR; } break; case State.O: if (Utils.IsOctDigit(ch)) { this._val *= 8; this._val += ch - '0'; this._state = State.O; } else if (ch == 'u' || ch == 'U') { this._suffix = TokenInt.IntSuffix.U; this._state = State.U; } else if (ch == 'l' || ch == 'L') { this._suffix = TokenInt.IntSuffix.L; this._state = State.L; } else { this._state = State.END; } break; case State.L: if (ch == 'u' || ch == 'U') { this._suffix = TokenInt.IntSuffix.UL; this._state = State.UL; } else { this._state = State.END; } break; case State.H: if (Utils.IsHexDigit(ch)) { this._val *= 0x10; this._val += Utils.GetHexDigit(ch); this._state = State.H; } else if (ch == 'u' || ch == 'U') { this._suffix = TokenInt.IntSuffix.U; this._state = State.U; } else if (ch == 'l' || ch == 'L') { this._suffix = TokenInt.IntSuffix.L; this._state = State.L; } else { this._state = State.END; } break; case State.U: if (ch == 'l' || ch == 'L') { this._suffix = TokenInt.IntSuffix.UL; this._state = State.UL; } else { this._state = State.END; } break; case State.UL: this._state = State.END; break; default: this._state = State.ERROR; break; } }
public IntLiteral(Int64 value, TokenInt.IntSuffix suffix) { this.Value = value; this.Suffix = suffix; }