Skip to content

Commit 2f1c294

Browse files
committed
Renamed src/ast/TypeDeclaration.h --> src/ast/Type.h
1 parent 1118926 commit 2f1c294

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

src/ast/Type.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#ifndef RSMS_AST_TYPE_DECLARATION_H
2+
#define RSMS_AST_TYPE_DECLARATION_H
3+
#include <string>
4+
#include <vector>
5+
namespace rsms { namespace ast {
6+
7+
// Declares a type, e.g. Float (double precision number) or [Int] (list of integer numbers)
8+
class Type {
9+
public:
10+
enum TypeID {
11+
Unknown = 0,
12+
Named,
13+
Int,
14+
Float,
15+
Func,
16+
};
17+
18+
Type(TypeID typeID) : typeID_(typeID) {}
19+
Type(const std::string& name) : typeID_(Named), name_(name) {}
20+
21+
inline const TypeID& typeID() const { return typeID_; }
22+
inline const std::string& name() const { return name_; }
23+
24+
std::string toString() const {
25+
switch (typeID_) {
26+
case Named: return name_;
27+
case Int: return "Int";
28+
case Float: return "Float";
29+
case Func: return "func";
30+
default: return "?";
31+
}
32+
}
33+
private:
34+
TypeID typeID_;
35+
std::string name_;
36+
};
37+
38+
typedef std::vector<Type*> TypeList;
39+
40+
}} // namespace rsms::ast
41+
#endif // RSMS_AST_TYPE_DECLARATION_H

0 commit comments

Comments
 (0)