alokp@chromium.org | 4e4b807 | 2011-08-07 05:36:04 +0000 | [diff] [blame] | 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_INPUT_H_ |
| 8 | #define COMPILER_PREPROCESSOR_INPUT_H_ |
| 9 | |
alokp@chromium.org | 30a487c | 2012-05-02 17:30:46 +0000 | [diff] [blame] | 10 | #include <vector> |
alokp@chromium.org | 98eec91 | 2012-05-01 10:04:08 +0000 | [diff] [blame] | 11 | |
alokp@chromium.org | 4e4b807 | 2011-08-07 05:36:04 +0000 | [diff] [blame] | 12 | namespace pp |
| 13 | { |
| 14 | |
alokp@chromium.org | 98eec91 | 2012-05-01 10:04:08 +0000 | [diff] [blame] | 15 | // Holds and reads input for Lexer. |
| 16 | class Input |
alokp@chromium.org | 4e4b807 | 2011-08-07 05:36:04 +0000 | [diff] [blame] | 17 | { |
alokp@chromium.org | 98eec91 | 2012-05-01 10:04:08 +0000 | [diff] [blame] | 18 | public: |
alokp@chromium.org | 2818248 | 2012-04-24 23:07:34 +0000 | [diff] [blame] | 19 | Input(); |
alokp@chromium.org | 98eec91 | 2012-05-01 10:04:08 +0000 | [diff] [blame] | 20 | Input(int count, const char* const string[], const int length[]); |
alokp@chromium.org | 98eec91 | 2012-05-01 10:04:08 +0000 | [diff] [blame] | 21 | |
| 22 | int count() const { return mCount; } |
| 23 | const char* string(int index) const { return mString[index]; } |
| 24 | int length(int index) const { return mLength[index]; } |
| 25 | |
| 26 | int read(char* buf, int maxSize); |
| 27 | |
| 28 | struct Location |
| 29 | { |
| 30 | int sIndex; // String index; |
| 31 | int cIndex; // Char index. |
| 32 | |
| 33 | Location() : sIndex(0), cIndex(0) { } |
| 34 | }; |
| 35 | const Location& readLoc() const { return mReadLoc; } |
| 36 | |
| 37 | private: |
alokp@chromium.org | 98eec91 | 2012-05-01 10:04:08 +0000 | [diff] [blame] | 38 | // Input. |
| 39 | int mCount; |
| 40 | const char* const* mString; |
alokp@chromium.org | 30a487c | 2012-05-02 17:30:46 +0000 | [diff] [blame] | 41 | std::vector<int> mLength; |
alokp@chromium.org | 98eec91 | 2012-05-01 10:04:08 +0000 | [diff] [blame] | 42 | |
| 43 | Location mReadLoc; |
alokp@chromium.org | 4e4b807 | 2011-08-07 05:36:04 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | } // namespace pp |
| 47 | #endif // COMPILER_PREPROCESSOR_INPUT_H_ |
| 48 | |