blob: e951cb4d5fe00d3cdcac127281d507f8397aa794 [file] [log] [blame]
alokp@chromium.org4e4b8072011-08-07 05:36:04 +00001//
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
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +000010#include <stddef.h>
alokp@chromium.org30a487c2012-05-02 17:30:46 +000011#include <vector>
alokp@chromium.org98eec912012-05-01 10:04:08 +000012
alokp@chromium.org4e4b8072011-08-07 05:36:04 +000013namespace pp
14{
15
alokp@chromium.org98eec912012-05-01 10:04:08 +000016// Holds and reads input for Lexer.
17class Input
alokp@chromium.org4e4b8072011-08-07 05:36:04 +000018{
alokp@chromium.org98eec912012-05-01 10:04:08 +000019 public:
alokp@chromium.org28182482012-04-24 23:07:34 +000020 Input();
Zhenyao Mod526f982014-05-13 14:51:19 -070021 Input(size_t count, const char *const string[], const int length[]);
alokp@chromium.org98eec912012-05-01 10:04:08 +000022
Zhenyao Mod526f982014-05-13 14:51:19 -070023 size_t count() const
24 {
25 return mCount;
26 }
27 const char *string(size_t index) const
28 {
29 return mString[index];
30 }
31 size_t length(size_t index) const
32 {
33 return mLength[index];
34 }
alokp@chromium.org98eec912012-05-01 10:04:08 +000035
Zhenyao Mod526f982014-05-13 14:51:19 -070036 size_t read(char *buf, size_t maxSize);
alokp@chromium.org98eec912012-05-01 10:04:08 +000037
38 struct Location
39 {
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +000040 size_t sIndex; // String index;
41 size_t cIndex; // Char index.
alokp@chromium.org98eec912012-05-01 10:04:08 +000042
Zhenyao Mod526f982014-05-13 14:51:19 -070043 Location()
44 : sIndex(0),
45 cIndex(0)
46 {
47 }
alokp@chromium.org98eec912012-05-01 10:04:08 +000048 };
Zhenyao Mod526f982014-05-13 14:51:19 -070049 const Location &readLoc() const { return mReadLoc; }
alokp@chromium.org98eec912012-05-01 10:04:08 +000050
51 private:
alokp@chromium.org98eec912012-05-01 10:04:08 +000052 // Input.
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +000053 size_t mCount;
Zhenyao Mod526f982014-05-13 14:51:19 -070054 const char * const *mString;
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +000055 std::vector<size_t> mLength;
alokp@chromium.org98eec912012-05-01 10:04:08 +000056
57 Location mReadLoc;
alokp@chromium.org4e4b8072011-08-07 05:36:04 +000058};
59
60} // namespace pp
alokp@chromium.org4e4b8072011-08-07 05:36:04 +000061
Geoff Lang0a73dd82014-11-19 16:18:08 -050062#endif // COMPILER_PREPROCESSOR_INPUT_H_