comparison dmd/Parser.d @ 13:427f8aa74d28

On the road to make Phobos compilable
author korDen
date Mon, 12 Apr 2010 16:29:33 +0400
parents d706d958e4e8
children 460959608115
comparison
equal deleted inserted replaced
12:832f71e6f96c 13:427f8aa74d28
10 import dmd.ShrAssignExp; 10 import dmd.ShrAssignExp;
11 import dmd.UshrAssignExp; 11 import dmd.UshrAssignExp;
12 import dmd.CatAssignExp; 12 import dmd.CatAssignExp;
13 import dmd.StaticIfCondition; 13 import dmd.StaticIfCondition;
14 import dmd.TraitsExp; 14 import dmd.TraitsExp;
15 import dmd.TemplateMixin;
15 import dmd.BaseClass; 16 import dmd.BaseClass;
16 import dmd.AssignExp; 17 import dmd.AssignExp;
17 import dmd.TemplateInstance; 18 import dmd.TemplateInstance;
18 import dmd.NewExp; 19 import dmd.NewExp;
19 import dmd.ArrayExp; 20 import dmd.ArrayExp;
1074 1075
1075 Lerr: 1076 Lerr:
1076 return tpl; 1077 return tpl;
1077 } 1078 }
1078 1079
1080 /******************************************
1081 * Parse template mixin.
1082 * mixin Foo;
1083 * mixin Foo!(args);
1084 * mixin a.b.c!(args).Foo!(args);
1085 * mixin Foo!(args) identifier;
1086 * mixin typeof(expr).identifier!(args);
1087 */
1079 Dsymbol parseMixin() 1088 Dsymbol parseMixin()
1080 { 1089 {
1081 assert(false); 1090 TemplateMixin tm;
1091 Identifier id;
1092 Type tqual;
1093 Objects tiargs;
1094 Array idents;
1095
1096 //printf("parseMixin()\n");
1097 nextToken();
1098 tqual = null;
1099 if (token.value == TOKdot)
1100 {
1101 id = Id.empty;
1102 }
1103 else
1104 {
1105 if (token.value == TOKtypeof)
1106 {
1107 tqual = parseTypeof();
1108 check(TOKdot);
1109 }
1110 if (token.value != TOKidentifier)
1111 {
1112 error("identifier expected, not %s", token.toChars());
1113 id = Id.empty;
1114 }
1115 else
1116 id = token.ident;
1117 nextToken();
1118 }
1119
1120 idents = new Array();
1121 while (1)
1122 {
1123 tiargs = null;
1124 if (token.value == TOKnot)
1125 {
1126 nextToken();
1127 if (token.value == TOKlparen)
1128 tiargs = parseTemplateArgumentList();
1129 else
1130 tiargs = parseTemplateArgument();
1131 }
1132
1133 if (token.value != TOKdot)
1134 break;
1135
1136 if (tiargs)
1137 {
1138 TemplateInstance tempinst = new TemplateInstance(loc, id);
1139 tempinst.tiargs = tiargs;
1140 id = cast(Identifier)tempinst;
1141 tiargs = null;
1142 }
1143 idents.push(cast(void*)id);
1144
1145 nextToken();
1146 if (token.value != TOKidentifier)
1147 {
1148 error("identifier expected following '.' instead of '%s'", token.toChars());
1149 break;
1150 }
1151 id = token.ident;
1152 nextToken();
1153 }
1154 idents.push(cast(void*)id);
1155
1156 if (token.value == TOKidentifier)
1157 {
1158 id = token.ident;
1159 nextToken();
1160 }
1161 else
1162 id = null;
1163
1164 tm = new TemplateMixin(loc, id, tqual, idents, tiargs);
1165 if (token.value != TOKsemicolon)
1166 error("';' expected after mixin");
1167 nextToken();
1168
1169 return tm;
1082 } 1170 }
1083 1171
1084 /****************************************** 1172 /******************************************
1085 * Parse template argument list. 1173 * Parse template argument list.
1086 * Input: 1174 * Input: