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_INPUT_H_
8 : #define COMPILER_PREPROCESSOR_INPUT_H_
9 :
10 : #include <cstddef>
11 : #include <vector>
12 :
13 : namespace pp
14 : {
15 :
16 : // Holds and reads input for Lexer.
17 0 : class Input
18 : {
19 : public:
20 : Input();
21 : Input(size_t count, const char *const string[], const int length[]);
22 :
23 0 : size_t count() const
24 : {
25 0 : return mCount;
26 : }
27 : const char *string(size_t index) const
28 : {
29 : return mString[index];
30 : }
31 0 : size_t length(size_t index) const
32 : {
33 0 : return mLength[index];
34 : }
35 :
36 : size_t read(char *buf, size_t maxSize, int *lineNo);
37 :
38 : struct Location
39 : {
40 : size_t sIndex; // String index;
41 : size_t cIndex; // Char index.
42 :
43 0 : Location()
44 0 : : sIndex(0),
45 0 : cIndex(0)
46 : {
47 0 : }
48 : };
49 : const Location &readLoc() const { return mReadLoc; }
50 :
51 : private:
52 : // Skip a character and return the next character after the one that was skipped.
53 : // Return nullptr if data runs out.
54 : const char *skipChar();
55 :
56 : // Input.
57 : size_t mCount;
58 : const char * const *mString;
59 : std::vector<size_t> mLength;
60 :
61 : Location mReadLoc;
62 : };
63 :
64 : } // namespace pp
65 :
66 : #endif // COMPILER_PREPROCESSOR_INPUT_H_
|