aboutsummaryrefslogtreecommitdiff
path: root/lib/TableGen/TGPreprocessor.h
blob: 2b9ed9c1566f294a60c9f26595d1494080360a22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//===- TGPreprocessor.h - Preprocessor for TableGen Files -------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This class represents the Preprocessor for tablegen files.
//
//===----------------------------------------------------------------------===//

#ifndef TGPREPROCESSOR_H
#define TGPREPROCESSOR_H

#include <vector>

namespace llvm {
class MemoryBuffer;
class SourceMgr;
class tool_output_file;

class TGPPLexer;
class TGPPRange;
class TGPPRecord;

typedef std::vector<TGPPRecord> TGPPRecords;

class TGPreprocessor {
  SourceMgr &SrcMgr;
  tool_output_file &Out;

  TGPPLexer *Lexer;
  TGPPRecords *CurRecords;

  bool ParseBlock(bool TopLevel);
  bool ParseForLoop();
  bool ParseRange(TGPPRange *Range);

public:
  TGPreprocessor(SourceMgr &SM, tool_output_file &O)
    : SrcMgr(SM), Out(O), Lexer(NULL), CurRecords(NULL) {
  }

  /// PreprocessFile - Main entrypoint for preprocess a tblgen file.  These
  /// preprocess routines return true on error, or false on success.
  bool PreprocessFile();
};
} // namespace llvm

#endif /* TGPREPROCESSOR_H */