michael@0: // michael@0: // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: #ifndef COMPILER_PREPROCESSOR_TOKENIZER_H_ michael@0: #define COMPILER_PREPROCESSOR_TOKENIZER_H_ michael@0: michael@0: #include "Input.h" michael@0: #include "Lexer.h" michael@0: #include "pp_utils.h" michael@0: michael@0: namespace pp michael@0: { michael@0: michael@0: class Diagnostics; michael@0: michael@0: class Tokenizer : public Lexer michael@0: { michael@0: public: michael@0: struct Context michael@0: { michael@0: Diagnostics* diagnostics; michael@0: michael@0: Input input; michael@0: // The location where yytext points to. Token location should track michael@0: // scanLoc instead of Input::mReadLoc because they may not be the same michael@0: // if text is buffered up in the scanner input buffer. michael@0: Input::Location scanLoc; michael@0: michael@0: bool leadingSpace; michael@0: bool lineStart; michael@0: }; michael@0: static const std::size_t kMaxTokenLength; michael@0: michael@0: Tokenizer(Diagnostics* diagnostics); michael@0: ~Tokenizer(); michael@0: michael@0: bool init(size_t count, const char* const string[], const int length[]); michael@0: michael@0: void setFileNumber(int file); michael@0: void setLineNumber(int line); michael@0: michael@0: virtual void lex(Token* token); michael@0: michael@0: private: michael@0: PP_DISALLOW_COPY_AND_ASSIGN(Tokenizer); michael@0: bool initScanner(); michael@0: void destroyScanner(); michael@0: michael@0: void* mHandle; // Scanner handle. michael@0: Context mContext; // Scanner extra. michael@0: }; michael@0: michael@0: } // namespace pp michael@0: #endif // COMPILER_PREPROCESSOR_TOKENIZER_H_ michael@0: