#ifndef __SCANNER_H
#define __SCANNER_H

#ifndef __FSTREAM_H
#include <fstream.h>
#endif

#ifndef __STRINGS_H
#include <strings.h>
#endif

#ifndef XVT_R3_API
#ifndef XVT_INCL_TYPE 
// @T
typedef struct s_rct {          /* mathematical rectangle */
  short top;                  /* top coordinate */
  short left;                 /* left coordinate */
  short bottom;               /* bottom coordinate */
  short right;                /* right coordinate */
} RCT;
#endif 
#else
#ifndef XVT_INCL_XVTTYPE
typedef struct s_rct {          /* mathematical rectangle */
  short top;                  /* top coordinate */
  short left;                 /* left coordinate */
  short bottom;               /* bottom coordinate */
  short right;                /* right coordinate */
} RCT;
#endif

#endif

// @C
class TScanner : private ifstream
{
  // @DPRIV
  TString _token, _key;
  bool _pushed;
  word _line;

public:
  // @FPUB
  TScanner(const char* filename);
  const TString& pop();
  const TString& key() const { return _key; }
  const TString& popkey() { pop(); return key(); }
  const TString& string();
  TString& line(char eol = '\n');
  const TString& equal() { return line('='); }
  void rectangle(RCT& rect);
  int integer();
  double number();
  const TString& operand();
  bool paragraph(const char* name);

  bool ok() { return good(); }

  void push(const char* tok = NULL);
  const TString& token() const { return _token; }
  word linenum() { return _line; }
};


#endif // __SCANNER_H