Mercurial > projects > dang
diff src/parser/Action.d @ 207:e0551773a005
Added the correct version.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Tue, 12 Aug 2008 18:19:34 +0200 |
parents | d3c148ca429b |
children | 42e663451371 |
line wrap: on
line diff
--- a/src/parser/Action.d Tue Aug 12 18:14:56 2008 +0200 +++ b/src/parser/Action.d Tue Aug 12 18:19:34 2008 +0200 @@ -2,6 +2,8 @@ import lexer.Token; +import basic.Attribute; + /** Used to indicate what type of operator is used in a given binary expression (and unary expressions?) @@ -9,6 +11,11 @@ public enum Operator { Assign, + AddAssign, + SubAssign, + MulAssign, + DivAssign, + ModAssign, Eq, Ne, @@ -17,6 +24,8 @@ Add, Sub, Mul, Div, Mod, + + LeftShift, RightShift, UnsignedRightShift, } @@ -31,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; } @@ -43,11 +52,11 @@ Id id; } -class ArrayId : Id +class StaticArrayTypeId : Id { - public static ArrayId opCall(Id id, Object number) + public static StaticArrayTypeId opCall(Id id, Object number) { - auto a = new ArrayId(); + auto a = new StaticArrayTypeId(); a.id = id; a.number = number; return a; @@ -57,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. @@ -76,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. @@ -84,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 -- @@ -146,7 +170,12 @@ The other solution is an addParamToFunc or similar. */ - DeclT actOnDeclarator(ref Id type, ref Id name, ExprT init) + DeclT actOnDeclarator(ref Id type, ref Id name, ExprT init, Attribute att) + { + return null; + } + + DeclT actOnAliasDecl(DeclT decl, Attribute att) { return null; } @@ -154,7 +183,39 @@ /** Add a struct member to a struct. */ - void actOnStructMember(DeclT st_decl, DeclT m_decl) //ref Id type, ref Id name, ExprT init) + void actOnStructMember(DeclT st_decl, DeclT m_decl) + { + return null; + } + + /** + Add a class member to a struct. + */ + void actOnClassMember(DeclT cl_decl, DeclT m_decl) + { + return null; + } + + /** + Add a class member to a struct. + */ + void actOnClassBaseClass(DeclT cl_decl, ref Id name) + { + return null; + } + + /** + Add a class member to a struct. + */ + void actOnInterfaceMember(DeclT if_decl, DeclT m_decl) + { + return null; + } + + /** + Add a class member to a struct. + */ + void actOnInterfaceBaseClass(DeclT if_decl, ref Id name) { return null; } @@ -173,7 +234,7 @@ Called at the start of a function, doesn't get a lot of info - that is added later on, through addFuncArg and actOnEndOfFunction. */ - DeclT actOnStartOfFunctionDef(ref Id type, ref Id name) + DeclT actOnStartOfFunctionDef(ref Id type, ref Id name, Attribute att) { return null; } @@ -247,21 +308,28 @@ /** */ + StmtT actOnForStmt(ref Token forTok, StmtT init, ExprT cond, ExprT incre, StmtT forBody) + { + return null; + } + + /** + */ StmtT actOnDeclStmt(DeclT decl) { return null; } - StmtT actOnStartOfSwitchStmt() + StmtT actOnStartOfSwitchStmt(Token _switch, ExprT exp) { return null; } - void actOnCaseStmt() + void actOnCaseStmt(StmtT stmt, Token _case, ExprT[] exps, StmtT[] stmts) { } - void actOnDefaultStmt() + void actOnDefaultStmt(StmtT stmt, Token _default, StmtT[] stmts) { } @@ -298,6 +366,14 @@ } /** + This is called when strings are used in expression + */ + ExprT actOnStringExp(Token t) + { + return null; + } + + /** Unary operator. */ ExprT actOnUnaryOp(Token op, ExprT operand) @@ -338,7 +414,7 @@ /** Called when function calls are encountered. */ - ExprT actOnIndexEpr(ExprT array, ref Token left_bracket, ExprT index, + ExprT actOnIndexExpr(ExprT array, ref Token left_bracket, ExprT index, ref Token right_bracket) { return null; @@ -351,6 +427,30 @@ { return null; } + + /** + New expression. + */ + ExprT actOnNewExpr(ref Id type, ExprT[] a_args, ExprT[] c_args) + { + return null; + } + + /** + Array Literal expression. + */ + ExprT actOnArrayLiteralExpr(ExprT[] exps, SLoc start, SLoc end) + { + return null; + } + + /** + Null expression. + */ + ExprT actOnNullExpr(SLoc pos) + { + return null; + } } /**