Coverage Report

Created: 2022-03-21 07:20

/src/xpdf-4.03/xpdf/Lexer.h
Line
Count
Source (jump to first uncovered 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
#include <aconf.h>
13
14
#ifdef USE_GCC_PRAGMAS
15
#pragma interface
16
#endif
17
18
#include "Object.h"
19
#include "Stream.h"
20
21
class XRef;
22
23
337M
#define tokBufSize 128    // size of token buffer
24
25
//------------------------------------------------------------------------
26
// Lexer
27
//------------------------------------------------------------------------
28
29
class Lexer {
30
public:
31
32
  // Construct a lexer for a single stream.  Deletes the stream when
33
  // lexer is deleted.
34
  Lexer(XRef *xref, Stream *str);
35
36
  // Construct a lexer for a stream or array of streams (assumes obj
37
  // is either a stream or array of streams).
38
  Lexer(XRef *xref, Object *obj);
39
40
  // Destructor.
41
  ~Lexer();
42
43
  // Get the next object from the input stream.
44
  Object *getObj(Object *obj);
45
46
  // Skip to the beginning of the next line in the input stream.
47
  void skipToNextLine();
48
49
  // Skip to the end of the input stream.
50
  void skipToEOF();
51
52
  // Skip over one character.
53
2
  void skipChar() { getChar(); }
54
55
  // Get stream index (for arrays of streams).
56
0
  int getStreamIndex() { return strPtr; }
57
58
  // Get stream.
59
  Stream *getStream()
60
3.61k
    { return curStr.isNone() ? (Stream *)NULL : curStr.getStream(); }
61
62
  // Get current position in file.
63
  GFileOffset getPos()
64
478k
    { return curStr.isNone() ? -1 : curStr.streamGetPos(); }
65
66
  // Set position in file.
67
  void setPos(GFileOffset pos, int dir = 0)
68
902
    { if (!curStr.isNone()) curStr.streamSetPos(pos, dir); }
69
70
  // Returns true if <c> is a whitespace character.
71
  static GBool isSpace(int c);
72
73
private:
74
75
  int getChar();
76
  int lookChar();
77
78
  Array *streams;   // array of input streams
79
  int strPtr;     // index of current stream
80
  Object curStr;    // current stream
81
  GBool freeArray;    // should lexer free the streams array?
82
  char tokBuf[tokBufSize];  // temporary token buffer
83
};
84
85
#endif