blob: 167d5dda0fb210dba7dded1116e2b601d785e994 [file] [log] [blame]
Andreas Huberc9410c72016-07-28 12:18:40 -07001#ifndef AST_H_
2
3#define AST_H_
4
5#include <android-base/macros.h>
Andreas Hubereb1081f2016-07-28 13:13:24 -07006#include <string>
Andreas Huberc9410c72016-07-28 12:18:40 -07007#include <utils/Vector.h>
8
9namespace android {
10
11struct Formatter;
12struct Type;
13struct Scope;
14
15struct AST {
16 AST();
17 ~AST();
18
19 static AST *Parse(const char *path);
20
Andreas Hubereb1081f2016-07-28 13:13:24 -070021 void setVersion(const char *major, const char *minor);
Andreas Huber84f89de2016-07-28 15:39:51 -070022 bool setPackage(const char *package);
23 bool addImport(const char *import);
Andreas Hubereb1081f2016-07-28 13:13:24 -070024
Andreas Huberc9410c72016-07-28 12:18:40 -070025 void enterScope(Scope *container);
26 void leaveScope();
27 Scope *scope();
28
29 void *scanner();
30 void setScanner(void *scanner);
31
32 Type *lookupType(const char *name);
33
34 void dump(Formatter &out) const;
35
36private:
37 Vector<Scope *> mScopePath;
38
39 void *mScanner;
40 Scope *mRootScope;
41
Andreas Huber84f89de2016-07-28 15:39:51 -070042 std::string mVersion;
43 std::string mPackage;
44
Andreas Huberc9410c72016-07-28 12:18:40 -070045 DISALLOW_COPY_AND_ASSIGN(AST);
46};
47
48} // namespace android
49
50#endif // AST_H_