Home | History | Annotate | Download | only in preprocessor
      1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //    http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #ifndef COMPILER_PREPROCESSOR_PREPROCESSOR_H_
     16 #define COMPILER_PREPROCESSOR_PREPROCESSOR_H_
     17 
     18 #include "pp_utils.h"
     19 
     20 namespace pp
     21 {
     22 
     23 class Diagnostics;
     24 class DirectiveHandler;
     25 struct PreprocessorImpl;
     26 struct Token;
     27 
     28 class Preprocessor
     29 {
     30 public:
     31 	Preprocessor(Diagnostics* diagnostics, DirectiveHandler* directiveHandler);
     32 	~Preprocessor();
     33 
     34 	// count: specifies the number of elements in the string and length arrays.
     35 	// string: specifies an array of pointers to strings.
     36 	// length: specifies an array of string lengths.
     37 	// If length is NULL, each string is assumed to be null terminated.
     38 	// If length is a value other than NULL, it points to an array containing
     39 	// a string length for each of the corresponding elements of string.
     40 	// Each element in the length array may contain the length of the
     41 	// corresponding string or a value less than 0 to indicate that the string
     42 	// is null terminated.
     43 	bool init(int count, const char* const string[], const int length[]);
     44 	// Adds a pre-defined macro.
     45 	void predefineMacro(const char* name, int value);
     46 
     47 	void lex(Token* token);
     48 
     49 private:
     50 	PP_DISALLOW_COPY_AND_ASSIGN(Preprocessor);
     51 
     52 	PreprocessorImpl* mImpl;
     53 };
     54 
     55 }  // namespace pp
     56 #endif  // COMPILER_PREPROCESSOR_PREPROCESSOR_H_
     57 
     58