Mercurial > projects > dang
diff 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 |
line wrap: on
line diff
--- a/parser/Action.d Thu Jul 24 12:27:34 2008 +0200 +++ b/parser/Action.d Thu Jul 24 20:31:24 2008 +0200 @@ -40,11 +40,11 @@ Token tok; } -class PointerId : Id +class PointerTypeId : Id { - public static PointerId opCall(Id id) + public static PointerTypeId opCall(Id id) { - auto p = new PointerId(); + auto p = new PointerTypeId(); p.id = id; return p; } @@ -52,11 +52,11 @@ Id id; } -class StaticArrayId : Id +class StaticArrayTypeId : Id { - public static StaticArrayId opCall(Id id, Object number) + public static StaticArrayTypeId opCall(Id id, Object number) { - auto a = new StaticArrayId(); + auto a = new StaticArrayTypeId(); a.id = id; a.number = number; return a; @@ -66,6 +66,20 @@ Object number; } +class FunctionTypeId : Id +{ + public static FunctionTypeId opCall(Id id, DeclT[] decls) + { + auto f = new FunctionTypeId(); + f.id = id; + f.decls = decls; + return f; + } + + Id id; + DeclT[] decls; +} + /** Represents a fully qualified name, with some packages and a final identifier. The identifier should always be set, but packages may have length 0. @@ -85,6 +99,18 @@ } } + /** + A few aliases to indicate what methods should be dealing with the same + types. + Not typesafe, and not using typedef because users would need a lot of + casts (and base type would be void*, so no possibility to synchronize, + print etc.) + */ +alias Object ExprT; +alias Object StmtT; /// ditto +alias Object DeclT; /// ditto +alias Object ModuleT; /// ditto + /** All methods are optional. @@ -93,18 +119,7 @@ */ abstract class Action { - /** - A few aliases to indicate what methods should be dealing with the same - types. - Not typesafe, and not using typedef because users would need a lot of - casts (and base type would be void*, so no possibility to synchronize, - print etc.) - */ - alias Object ExprT; - alias Object StmtT; /// ditto - alias Object DeclT; /// ditto - alias Object ModuleT; /// ditto // -- Modules --