Tue, 03 Feb 2015 04:03:19 +0200
- now parses to tokens
923 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 - 2015 Teemu Piippo | |
4 | * | |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation, either version 3 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | #pragma once | |
20 | #include "../main.h" | |
21 | ||
22 | namespace Script | |
23 | { | |
24 | class Type | |
25 | { | |
26 | public: | |
27 | Type(); | |
28 | virtual QString asString() const = 0; | |
29 | }; | |
30 | ||
31 | class BasicType : public Type | |
32 | { | |
33 | public: | |
34 | enum Kind | |
35 | { | |
36 | VAR, // mixed | |
37 | INT, | |
38 | REAL, | |
39 | STRING, | |
40 | TYPE, // heh | |
41 | OBJECT, | |
42 | }; | |
43 | ||
44 | QString asString() const override; | |
45 | Kind kind() const { return m_kind; } | |
46 | ||
47 | private: | |
48 | Kind m_kind; | |
49 | }; | |
50 | ||
51 | class ContainerType : public Type | |
52 | { | |
53 | public: | |
54 | enum Kind | |
55 | { | |
56 | ARRAY, | |
57 | TUPLE, | |
58 | MATRIX | |
59 | }; | |
60 | ||
61 | ContainerType (Kind kind, int n1, int n2) : | |
62 | m_kind (kind), m_n1 (n1), m_n2 (n2) {} | |
63 | ||
64 | QString asString() const override; | |
65 | Kind kind() const { return m_kind; } | |
66 | int n1() const { return m_n1; } | |
67 | int n2() const { return m_n1; } | |
68 | QSharedPointer<Type> elementType() const { return m_elementType; } | |
69 | ||
70 | private: | |
71 | Kind m_kind; | |
72 | QSharedPointer<Type> m_elementType; | |
73 | int m_n1; | |
74 | int m_n2; | |
75 | }; | |
76 | } |