File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments