Mercurial > projects > dang
comparison parser/Action.d @ 172:01c2c49775ef
- Changed Parser to be more clean on type parsing.
- Parsing int function(int), and the like, types.(Function pointers)
- Fixed a design fault that made Symbol be wrong. Now Symbols are created with a factory with the help of types.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Thu, 24 Jul 2008 20:31:24 +0200 |
parents | 57b0b4464a0b |
children | 7b274cfdc1dc |
comparison
equal
deleted
inserted
replaced
171:f0385c044065 | 172:01c2c49775ef |
---|---|
38 return id; | 38 return id; |
39 } | 39 } |
40 Token tok; | 40 Token tok; |
41 } | 41 } |
42 | 42 |
43 class PointerId : Id | 43 class PointerTypeId : Id |
44 { | 44 { |
45 public static PointerId opCall(Id id) | 45 public static PointerTypeId opCall(Id id) |
46 { | 46 { |
47 auto p = new PointerId(); | 47 auto p = new PointerTypeId(); |
48 p.id = id; | 48 p.id = id; |
49 return p; | 49 return p; |
50 } | 50 } |
51 | 51 |
52 Id id; | 52 Id id; |
53 } | 53 } |
54 | 54 |
55 class StaticArrayId : Id | 55 class StaticArrayTypeId : Id |
56 { | 56 { |
57 public static StaticArrayId opCall(Id id, Object number) | 57 public static StaticArrayTypeId opCall(Id id, Object number) |
58 { | 58 { |
59 auto a = new StaticArrayId(); | 59 auto a = new StaticArrayTypeId(); |
60 a.id = id; | 60 a.id = id; |
61 a.number = number; | 61 a.number = number; |
62 return a; | 62 return a; |
63 } | 63 } |
64 | 64 |
65 Id id; | 65 Id id; |
66 Object number; | 66 Object number; |
67 } | |
68 | |
69 class FunctionTypeId : Id | |
70 { | |
71 public static FunctionTypeId opCall(Id id, DeclT[] decls) | |
72 { | |
73 auto f = new FunctionTypeId(); | |
74 f.id = id; | |
75 f.decls = decls; | |
76 return f; | |
77 } | |
78 | |
79 Id id; | |
80 DeclT[] decls; | |
67 } | 81 } |
68 | 82 |
69 /** | 83 /** |
70 Represents a fully qualified name, with some packages and a final identifier. | 84 Represents a fully qualified name, with some packages and a final identifier. |
71 The identifier should always be set, but packages may have length 0. | 85 The identifier should always be set, but packages may have length 0. |
83 r = r + identifier.tok.asRange(); | 97 r = r + identifier.tok.asRange(); |
84 return r; | 98 return r; |
85 } | 99 } |
86 } | 100 } |
87 | 101 |
102 /** | |
103 A few aliases to indicate what methods should be dealing with the same | |
104 types. | |
105 Not typesafe, and not using typedef because users would need a lot of | |
106 casts (and base type would be void*, so no possibility to synchronize, | |
107 print etc.) | |
108 */ | |
109 alias Object ExprT; | |
110 alias Object StmtT; /// ditto | |
111 alias Object DeclT; /// ditto | |
112 alias Object ModuleT; /// ditto | |
113 | |
88 /** | 114 /** |
89 All methods are optional. | 115 All methods are optional. |
90 | 116 |
91 Warning: Interface is not stable yet. Use the `override` keyword in all classes | 117 Warning: Interface is not stable yet. Use the `override` keyword in all classes |
92 inheriting from this to get warning if the interface changes. | 118 inheriting from this to get warning if the interface changes. |
93 */ | 119 */ |
94 abstract class Action | 120 abstract class Action |
95 { | 121 { |
96 /** | 122 |
97 A few aliases to indicate what methods should be dealing with the same | |
98 types. | |
99 | |
100 Not typesafe, and not using typedef because users would need a lot of | |
101 casts (and base type would be void*, so no possibility to synchronize, | |
102 print etc.) | |
103 */ | |
104 alias Object ExprT; | |
105 alias Object StmtT; /// ditto | |
106 alias Object DeclT; /// ditto | |
107 alias Object ModuleT; /// ditto | |
108 | 123 |
109 // -- Modules -- | 124 // -- Modules -- |
110 | 125 |
111 ModuleT actOnModule(ref Token _module, char[] name) | 126 ModuleT actOnModule(ref Token _module, char[] name) |
112 { | 127 { |