source: trunk/poppler/mypoppler/poppler/Lexer.h @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 16 years ago

First import

File size: 1.9 KB
Line 
1//========================================================================
2//
3// Lexer.h
4//
5// Copyright 1996-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
9#ifndef LEXER_H
10#define LEXER_H
11
12#ifdef USE_GCC_PRAGMAS
13#pragma interface
14#endif
15
16#include "Object.h"
17#include "Stream.h"
18
19class XRef;
20
21#define tokBufSize 128          // size of token buffer
22
23//------------------------------------------------------------------------
24// Lexer
25//------------------------------------------------------------------------
26
27class Lexer {
28public:
29
30  // Construct a lexer for a single stream.  Deletes the stream when
31  // lexer is deleted.
32  Lexer(XRef *xrefA, Stream *str);
33
34  // Construct a lexer for a stream or array of streams (assumes obj
35  // is either a stream or array of streams).
36  Lexer(XRef *xrefA, Object *obj);
37
38  // Destructor.
39  ~Lexer();
40
41  // Get the next object from the input stream.
42  Object *getObj(Object *obj, int objNum = -1);
43
44  // Skip to the beginning of the next line in the input stream.
45  void skipToNextLine();
46
47  // Skip over one character.
48  void skipChar() { getChar(); }
49
50  // Get stream.
51  Stream *getStream()
52    { return curStr.isNone() ? (Stream *)NULL : curStr.getStream(); }
53
54  // Get current position in file.  This is only used for error
55  // messages, so it returns an int instead of a Guint.
56  int getPos()
57    { return curStr.isNone() ? -1 : (int)curStr.streamGetPos(); }
58
59  // Set position in file.
60  void setPos(Guint pos, int dir = 0)
61    { if (!curStr.isNone()) curStr.streamSetPos(pos, dir); }
62
63  // Returns true if <c> is a whitespace character.
64  static GBool isSpace(int c);
65
66private:
67
68  int getChar();
69  int lookChar();
70
71  Array *streams;               // array of input streams
72  int strPtr;                   // index of current stream
73  Object curStr;                // current stream
74  GBool freeArray;              // should lexer free the streams array?
75  char tokBuf[tokBufSize];      // temporary token buffer
76
77  XRef *xref;
78};
79
80#endif
Note: See TracBrowser for help on using the repository browser.