~ubuntu-branches/ubuntu/precise/ipe/precise

« back to all changes in this revision

Viewing changes to src/xpdflib/lexer.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2004-06-08 00:44:02 UTC
  • Revision ID: james.westby@ubuntu.com-20040608004402-72yu51xlh7vt6p9m
Tags: upstream-6.0pre16
ImportĀ upstreamĀ versionĀ 6.0pre16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- C++ -*-
 
2
//========================================================================
 
3
//
 
4
// Lexer.h
 
5
//
 
6
// Copyright 1996-2002 Glyph & Cog, LLC
 
7
//
 
8
//========================================================================
 
9
 
 
10
#ifndef LEXER_H
 
11
#define LEXER_H
 
12
 
 
13
#include "aconf.h"
 
14
 
 
15
#ifdef USE_GCC_PRAGMAS
 
16
#pragma interface
 
17
#endif
 
18
 
 
19
#include "object.h"
 
20
#include "stream.h"
 
21
 
 
22
class XRef;
 
23
 
 
24
#define tokBufSize 128          // size of token buffer
 
25
 
 
26
//------------------------------------------------------------------------
 
27
// Lexer
 
28
//------------------------------------------------------------------------
 
29
 
 
30
class Lexer {
 
31
public:
 
32
 
 
33
  // Construct a lexer for a single stream.  Deletes the stream when
 
34
  // lexer is deleted.
 
35
  Lexer(XRef *xref, Stream *str);
 
36
 
 
37
  // Construct a lexer for a stream or array of streams (assumes obj
 
38
  // is either a stream or array of streams).
 
39
  Lexer(XRef *xref, Object *obj);
 
40
 
 
41
  // Destructor.
 
42
  ~Lexer();
 
43
 
 
44
  // Get the next object from the input stream.
 
45
  Object *getObj(Object *obj);
 
46
 
 
47
  // Skip to the beginning of the next line in the input stream.
 
48
  void skipToNextLine();
 
49
 
 
50
  // Skip over one character.
 
51
  void skipChar() { getChar(); }
 
52
 
 
53
  // Get stream.
 
54
  Stream *getStream()
 
55
    { return curStr.isNone() ? (Stream *)NULL : curStr.getStream(); }
 
56
 
 
57
  // Get current position in file.  This is only used for error
 
58
  // messages, so it returns an int instead of a Guint.
 
59
  int getPos()
 
60
    { return curStr.isNone() ? -1 : (int)curStr.streamGetPos(); }
 
61
 
 
62
  // Set position in file.
 
63
  void setPos(Guint pos, int dir = 0)
 
64
    { if (!curStr.isNone()) curStr.streamSetPos(pos, dir); }
 
65
 
 
66
private:
 
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
 
 
78
#endif