1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/angle/src/compiler/preprocessor/Tokenizer.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +// 1.5 +// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. 1.6 +// Use of this source code is governed by a BSD-style license that can be 1.7 +// found in the LICENSE file. 1.8 +// 1.9 + 1.10 +#ifndef COMPILER_PREPROCESSOR_TOKENIZER_H_ 1.11 +#define COMPILER_PREPROCESSOR_TOKENIZER_H_ 1.12 + 1.13 +#include "Input.h" 1.14 +#include "Lexer.h" 1.15 +#include "pp_utils.h" 1.16 + 1.17 +namespace pp 1.18 +{ 1.19 + 1.20 +class Diagnostics; 1.21 + 1.22 +class Tokenizer : public Lexer 1.23 +{ 1.24 + public: 1.25 + struct Context 1.26 + { 1.27 + Diagnostics* diagnostics; 1.28 + 1.29 + Input input; 1.30 + // The location where yytext points to. Token location should track 1.31 + // scanLoc instead of Input::mReadLoc because they may not be the same 1.32 + // if text is buffered up in the scanner input buffer. 1.33 + Input::Location scanLoc; 1.34 + 1.35 + bool leadingSpace; 1.36 + bool lineStart; 1.37 + }; 1.38 + static const std::size_t kMaxTokenLength; 1.39 + 1.40 + Tokenizer(Diagnostics* diagnostics); 1.41 + ~Tokenizer(); 1.42 + 1.43 + bool init(size_t count, const char* const string[], const int length[]); 1.44 + 1.45 + void setFileNumber(int file); 1.46 + void setLineNumber(int line); 1.47 + 1.48 + virtual void lex(Token* token); 1.49 + 1.50 + private: 1.51 + PP_DISALLOW_COPY_AND_ASSIGN(Tokenizer); 1.52 + bool initScanner(); 1.53 + void destroyScanner(); 1.54 + 1.55 + void* mHandle; // Scanner handle. 1.56 + Context mContext; // Scanner extra. 1.57 +}; 1.58 + 1.59 +} // namespace pp 1.60 +#endif // COMPILER_PREPROCESSOR_TOKENIZER_H_ 1.61 +