Line data Source code
1 : //
2 : // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
3 : // Use of this source code is governed by a BSD-style license that can be
4 : // found in the LICENSE file.
5 : //
6 :
7 : #ifndef COMPILER_PREPROCESSOR_PREPROCESSOR_H_
8 : #define COMPILER_PREPROCESSOR_PREPROCESSOR_H_
9 :
10 : #include <cstddef>
11 :
12 : #include "common/angleutils.h"
13 :
14 : namespace pp
15 : {
16 :
17 : class Diagnostics;
18 : class DirectiveHandler;
19 : struct PreprocessorImpl;
20 : struct Token;
21 :
22 : struct PreprocessorSettings : angle::NonCopyable
23 : {
24 0 : PreprocessorSettings() : maxMacroExpansionDepth(1000) {}
25 : int maxMacroExpansionDepth;
26 : };
27 :
28 : class Preprocessor : angle::NonCopyable
29 : {
30 : public:
31 : Preprocessor(Diagnostics *diagnostics,
32 : DirectiveHandler *directiveHandler,
33 : const PreprocessorSettings &settings);
34 : ~Preprocessor();
35 :
36 : // count: specifies the number of elements in the string and length arrays.
37 : // string: specifies an array of pointers to strings.
38 : // length: specifies an array of string lengths.
39 : // If length is NULL, each string is assumed to be null terminated.
40 : // If length is a value other than NULL, it points to an array containing
41 : // a string length for each of the corresponding elements of string.
42 : // Each element in the length array may contain the length of the
43 : // corresponding string or a value less than 0 to indicate that the string
44 : // is null terminated.
45 : bool init(size_t count, const char * const string[], const int length[]);
46 : // Adds a pre-defined macro.
47 : void predefineMacro(const char *name, int value);
48 :
49 : void lex(Token *token);
50 :
51 : // Set maximum preprocessor token size
52 : void setMaxTokenSize(size_t maxTokenSize);
53 :
54 : private:
55 : PreprocessorImpl *mImpl;
56 : };
57 :
58 : } // namespace pp
59 :
60 : #endif // COMPILER_PREPROCESSOR_PREPROCESSOR_H_
|