]> git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/Lexer.h
Merge changes from 1.1.x into 1.2 devel.
[thirdparty/cups.git] / pdftops / Lexer.h
1 //========================================================================
2 //
3 // Lexer.h
4 //
5 // Copyright 1996 Derek B. Noonburg
6 //
7 //========================================================================
8
9 #ifndef LEXER_H
10 #define LEXER_H
11
12 #ifdef __GNUC__
13 #pragma interface
14 #endif
15
16 #include "Object.h"
17 #include "Stream.h"
18
19 class XRef;
20
21 #define tokBufSize 128 // size of token buffer
22
23 //------------------------------------------------------------------------
24 // Lexer
25 //------------------------------------------------------------------------
26
27 class Lexer {
28 public:
29
30 // Construct a lexer for a single stream. Deletes the stream when
31 // lexer is deleted.
32 Lexer(XRef *xref, 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 *xref, Object *obj);
37
38 // Destructor.
39 ~Lexer();
40
41 // Get the next object from the input stream.
42 Object *getObj(Object *obj);
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.
55 int getPos()
56 { return curStr.isNone() ? -1 : curStr.streamGetPos(); }
57
58 // Set position in file.
59 void setPos(int pos)
60 { if (!curStr.isNone()) curStr.streamSetPos(pos); }
61
62 private:
63
64 int getChar();
65 int lookChar();
66
67 Array *streams; // array of input streams
68 int strPtr; // index of current stream
69 Object curStr; // current stream
70 GBool freeArray; // should lexer free the streams array?
71 char tokBuf[tokBufSize]; // temporary token buffer
72 };
73
74 #endif