comparison trunk/src/dil/ast/Expressions.d @ 631:2feb88f5c867

Added dil.parser.ExpressionParser and dil.parser.Factory.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 12 Jan 2008 01:56:04 +0100
parents 2ac14bb6b84e
children 20dddcc54621
comparison
equal deleted inserted replaced
630:5197bd351e5f 631:2feb88f5c867
10 import dil.ast.Declarations; 10 import dil.ast.Declarations;
11 import dil.ast.Statements; 11 import dil.ast.Statements;
12 import dil.ast.Parameters; 12 import dil.ast.Parameters;
13 import dil.ast.BaseClass; 13 import dil.ast.BaseClass;
14 import dil.lexer.Identifier; 14 import dil.lexer.Identifier;
15 import dil.parser.ExpressionParser;
15 import dil.semantic.Scope; 16 import dil.semantic.Scope;
16 import dil.semantic.Types; 17 import dil.semantic.Types;
17 import common; 18 import common;
18 19
19 class EmptyExpression : Expression 20 class EmptyExpression : Expression
928 mixin(set_kind); 929 mixin(set_kind);
929 addChild(expr); 930 addChild(expr);
930 this.expr = expr; 931 this.expr = expr;
931 } 932 }
932 933
933 // import dil.Parser;
934 override Expression semantic(Scope scop) 934 override Expression semantic(Scope scop)
935 { 935 {
936 if (type)
937 return this.expr;
936 // TODO: 938 // TODO:
937 /+
938 auto expr = this.expr.semantic(scop); 939 auto expr = this.expr.semantic(scop);
939 auto strExpr = Cast!(StringExpression)(expr); 940 expr = expr.evaluate();
940 // if (strExpr is null) 941 if (expr is null)
941 // error(scop, MID.MixinExpressionMustBeString); 942 return this;
942 auto parser = new Parser(strExpr.getString(), "", scop.infoMan); 943 auto strExpr = TryCast!(StringExpression)(expr);
943 expr = parser.start2(); 944 if (strExpr is null)
945 error(scop, MSG.MixinArgumentMustBeString);
946 else
947 {
948 auto loc = this.begin.getLocation();
949 auto filePath = loc.filePath;
950 auto parser = new_ExpressionParser(strExpr.getString(), filePath, scop.infoMan);
951 expr = parser.parse();
952 expr = expr.semantic(scop);
953 }
954 this.expr = expr;
955 this.type = expr.type;
944 return expr; 956 return expr;
945 +/
946 return null;
947 } 957 }
948 } 958 }
949 959
950 class ImportExpression : Expression 960 class ImportExpression : Expression
951 { 961 {