Mercurial > projects > dang
diff sema/AstAction.d @ 126:c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Tue, 27 May 2008 10:32:31 +0200 |
parents | 3a0cd42de9cc |
children | 2be29b296081 |
line wrap: on
line diff
--- a/sema/AstAction.d Sun May 25 21:13:56 2008 +0200 +++ b/sema/AstAction.d Tue May 27 10:32:31 2008 +0200 @@ -4,7 +4,8 @@ import lexer.Token; -import basic.SourceManager; +import basic.SourceManager, + basic.Attribute; import ast.Module, ast.Exp, @@ -81,13 +82,17 @@ d.explicitSymbols ~= [t, n]; } - override DeclT actOnDeclarator(ref Id type, ref Id id, ExprT init) + override DeclT actOnDeclarator(ref Id type, ref Id id, ExprT init, Attribute att) { + Decl d; Exp exp = cast(Exp)init; if(type.tok.type == Tok.Struct) - return new StructDecl(identifierFromTok(id.tok)); + d = new StructDecl(identifierFromTok(id.tok)); else - return new VarDecl(handleType(type), identifierFromTok(id.tok), exp); + d = new VarDecl(handleType(type), identifierFromTok(id.tok), exp); + + d.att = att; + return d; } override void actOnStructMember(DeclT st_decl, DeclT m_decl) //ref Id type, ref Id name, ExprT init) @@ -186,12 +191,18 @@ { Exp left = cast(Exp)l; Exp right = cast(Exp)r; - if (op == Operator.Assign) - return new AssignExp(op_loc, left, right); - else + switch(op) { - BinaryExp.Operator bin_op = cast(BinaryExp.Operator)op; - return new BinaryExp(op_loc, bin_op, left, right); + case Operator.Assign: + case Operator.AddAssign: + case Operator.SubAssign: + case Operator.MulAssign: + case Operator.DivAssign: + case Operator.ModAssign: + return new AssignExp(op_loc, cast(BinaryExp.Operator)op, left, right); + default: + BinaryExp.Operator bin_op = cast(BinaryExp.Operator)op; + return new BinaryExp(op_loc, bin_op, left, right); } }