1 //========================================================================
5 // Copyright 1996-2003 Glyph & Cog, LLC
7 //========================================================================
9 //========================================================================
11 // Modified under the Poppler project - http://poppler.freedesktop.org
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
16 // Copyright (C) 2006, 2007, 2010, 2013 Albert Astals Cid <aacid@kde.org>
17 // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
18 // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
19 // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
21 // To see a description of the changes please see the Changelog file that
22 // came with your tarball or type make ChangeLog if you are building from git
24 //========================================================================
29 #ifdef USE_GCC_PRAGMAS
38 #define tokBufSize 128 // size of token buffer
40 //------------------------------------------------------------------------
42 //------------------------------------------------------------------------
47 // Construct a lexer for a single stream. Deletes the stream when
49 Lexer(XRef
*xrefA
, Stream
*str
);
51 // Construct a lexer for a stream or array of streams (assumes obj
52 // is either a stream or array of streams).
53 Lexer(XRef
*xrefA
, Object
*obj
);
58 // Get the next object from the input stream.
59 Object
*getObj(Object
*obj
, int objNum
= -1);
60 Object
*getObj(Object
*obj
, const char *cmdA
, int objNum
);
62 // Skip to the beginning of the next line in the input stream.
63 void skipToNextLine();
65 // Skip over one character.
66 void skipChar() { getChar(); }
70 { return curStr
.isStream() ? curStr
.getStream() : (Stream
*)NULL
; }
72 // Get current position in file. This is only used for error
75 { return curStr
.isStream() ? curStr
.streamGetPos() : -1; }
77 // Set position in file.
78 void setPos(Goffset pos
, int dir
= 0)
79 { if (curStr
.isStream()) curStr
.streamSetPos(pos
, dir
); }
81 // Returns true if <c> is a whitespace character.
82 static GBool
isSpace(int c
);
85 // often (e.g. ~30% on PDF Refernce 1.6 pdf file from Adobe site) getChar
86 // is called right after lookChar. In order to avoid expensive re-doing
87 // getChar() of underlying stream, we cache the last value found by
88 // lookChar() in lookCharLastValueCached. A special value
89 // LOOK_VALUE_NOT_CACHED that should never be part of stream indicates
90 // that no value was cached
91 static const int LOOK_VALUE_NOT_CACHED
= -3;
92 int lookCharLastValueCached
;
96 int getChar(GBool comesFromLook
= gFalse
);
99 Array
*streams
; // array of input streams
100 int strPtr
; // index of current stream
101 Object curStr
; // current stream
102 GBool freeArray
; // should lexer free the streams array?
103 char tokBuf
[tokBufSize
]; // temporary token buffer