#include <perms.h>
static const int Integersize = 4;
static const int Realsize = 4;
static const int Bytesize = 1;
static const int Longrealsize = 8;
static const int Integertype = 1;
static const int Realtype = 2;
static const int Stringtype = 3;
static const int Bytetype = 5;
static const int Shortintegertype = 6;
static const int Longrealtype = 8;
static const int Maxint = ((unsigned)(-1) >> 1);
static const int Maxshort = ((unsigned)(-1) >> 16);
static const int Maxbyte = 255;
static const double Maxfloat = 3.3 @38;
static const int Maxstringlen = 255;
static int /* boolean */ Whitespace(int Ch) {
  if (Ch == ' ') return (1);
  if (Ch == 8) return (1);
  if (Ch == Nl) return (1);
  if (Ch == 13) return (1);
  return (0);
}
static int /* boolean */ Acceptabletype(int Type) {
  if (Type == Integertype) return (1);
  if (Type == Realtype) return (1);
  if (Type == Stringtype) return (1);
  if (Type == Bytetype) return (1);
  if (Type == Longrealtype) return (1);
  return (0);
}
void Read(_imp_name Ptr) {
  _imp_string S;
  int Ch;
  int Sign;
  int Digit;
  int Len;
  int Adr;
  int Type;
  int Base;
  int Found;
  double R;
  double Exp;
  double Frac;
  unsigned char *Dst;
  unsigned char *Src;
  int I;
  Len = Sizeof(Ptr);
  Adr = Addr(Ptr);
  Type = Typeof(Ptr);
  if (!Acceptabletype(Type)) _imp_signal(5, 5, Type, _imp_str_literal(""));
  while (Whitespace(Nextsymbol())) Skipsymbol();
  if (Type == Stringtype) {
    *Length(S) = 0;
    for (;;) {
      Ch = Nextsymbol();
      if (Whitespace(Ch)) break;
      if (*Length(S) < Maxstringlen) {
        *Length(S) = *Length(S) + 1;
        *Charno(S, *Length(S)) = Ch;
      }
      Skipsymbol();
    }
    if (*Length(S) > Len) _imp_signal(6, 1, 0, _imp_str_literal(""));
    for (I = 0; I <= *Length(S); I++) {
      Dst = Byteinteger(Adr + I);
      Src = Byteinteger(Addr(S) + I);
      *Dst = *Src;
    }
    return;
  }
  Base = 10;
  Sign = 0;
  if ((Nextsymbol() == '-') || (Nextsymbol() == '+')) Readsymbol(Sign);
  for (;;) {
    R = 0;
    Found = 0;
    for (;;) {
      Ch = Nextsymbol();
      if ('0' <= Ch && Ch <= '9')
        Digit = Ch - '0';
      else if ('A' <= (Ch & 95) && (Ch & 95) <= 'Z')
        Digit = (Ch & 95) - 'A' + 10;
      else
        break;
      if (Digit >= Base) break;
      Found = 1;
      Skipsymbol();
      R = R * Base + Digit;
    }
    if ((Ch != '_') || (R == 0)) break;
    Base = Int(R);
    Skipsymbol();
  }
  if (Type == Integertype) {
    if (Found == 0) _imp_signal(3, 1, Ch, _imp_str_literal(""));
    if (Type == Integertype) {
      if (R > Maxint) _imp_signal(1, 1, 0, _imp_str_literal(""));
      if (Sign == '-') R = -R;
      *Integer(Adr) = Int(R);
    }
    return;
  }
  if (Type == Bytetype) {
    if (Found == 0) _imp_signal(3, 1, Ch, _imp_str_literal(""));
    if ((R > Maxbyte) || (Sign == '-'))
      _imp_signal(1, 1, 0, _imp_str_literal(""));
    *Byteinteger(Adr) = Int(R);
    return;
  }
  if (Ch == '.') {
    Skipsymbol();
    Frac = 0;
    Exp = 10;
    for (;;) {
      Ch = Nextsymbol();
      if (('0' > Ch || Ch > '9')) break;
      Frac += (Ch - '0') / Exp;
      Exp = Exp * 10;
      Found = 1;
      Skipsymbol();
    }
    R += Frac;
  }
  if (Found == 0) _imp_signal(3, 1, Ch, _imp_str_literal(""));
  if ((Type == Realtype) && (R > Maxfloat))
    _imp_signal(1, 2, 0, _imp_str_literal(""));
  if (Sign == '-') R = -R;
  if (Type == Realtype)
    *Real(Adr) = R;
  else
    *Longreal(Adr) = R;
}
