home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 720 / PDF090B4-SorceCode / pdf / Lexer.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-30  |  1.9 KB  |  83 lines

  1. //========================================================================
  2. //
  3. // Lexer.h
  4. //
  5. // Copyright 1996 Derek B. Noonburg
  6. //
  7. //========================================================================
  8. //
  9. // Ported to EPOC by Sander van der Wal
  10. //
  11. // $Id: Lexer.h 1.2 2000-09-17 13:38:17+02 svdwal Exp svdwal $
  12.  
  13. #ifndef LEXER_H
  14. #define LEXER_H
  15.  
  16. #ifdef __GNUC__
  17. #pragma interface
  18. #endif
  19.  
  20. #ifndef __E32BASE_H__
  21. #include <e32base.h>
  22. #endif
  23.  
  24. #include "Object.h"
  25. #include "Stream.h"
  26.  
  27. #define tokBufSize 128        // size of token buffer
  28.  
  29. //------------------------------------------------------------------------
  30. // Lexer
  31. //------------------------------------------------------------------------
  32.  
  33. class Lexer: public CBase {
  34. public:
  35.  
  36.   // Construct a lexer for a single stream.  Deletes the stream when
  37.   // lexer is deleted.
  38.   Lexer(Stream *str);
  39.   void ConstructL();
  40.  
  41.   // Construct a lexer for a stream or array of streams (assumes obj
  42.   // is either a stream or array of streams).
  43.   Lexer();
  44.   void ConstructL(Object *obj);
  45.  
  46.   // Destructor.
  47.   ~Lexer();
  48.  
  49.   // Get the next object from the input stream.
  50.   Object *getObjL(Object *obj);
  51.  
  52.   // Skip to the beginning of the next line in the input stream.
  53.   void skipToNextLine();
  54.  
  55.   // Skip over one character.
  56.   void skipChar() { getChar(); }
  57.  
  58.   // Get stream.
  59.   Stream *getStream()
  60.     { return curStr.isNone() ? (Stream *)NULL : curStr.getStream(); }
  61.  
  62.   // Get current position in file.
  63.   int getPos()
  64.     { return curStr.isNone() ? -1 : curStr.streamGetPos(); }
  65.  
  66.   // Set position in file.
  67.   void setPos(int pos)
  68.     { if (!curStr.isNone()) curStr.streamSetPos(pos); }
  69.  
  70. private:
  71.  
  72.   int getChar();
  73.   int lookChar();
  74.  
  75.   Array *streams;        // array of input streams
  76.   int strPtr;            // index of current stream
  77.   Object curStr;        // current stream
  78.   GBool freeArray;        // should lexer free the streams array?
  79.   char tokBuf[tokBufSize];    // temporary token buffer
  80. };
  81.  
  82. #endif
  83.