Coverage Report

Created: 2025-07-11 07:47

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