Differences From Artifact [10fa9090c50cdaf9]:
- File
polemy/value.d
- 2010-11-20 12:57:15 - part of checkin [3f6f41b558] on branch trunk - ast - table conversion (NOT AT ALL TESTED) (user: kinaba) [annotate]
To Artifact [ff42bce4fb7dc674]:
- File
polemy/value.d
- 2010-11-20 14:04:44 - part of checkin [8e3db9ef20] on branch trunk - macro worked! (user: kinaba) [annotate]
145 else 145 else
146 { 146 {
147 if(auto next = this.access!Table(lay,path)) 147 if(auto next = this.access!Table(lay,path))
148 return next.access!T(lay,rest); 148 return next.access!T(lay,rest);
149 } 149 }
150 return null; 150 return null;
151 } 151 }
> 152
> 153 string toStringWithoutParen() const
> 154 {
> 155 string result;
> 156 bool first = true;
> 157 foreach(k, l2d; data)
> 158 foreach(l,d; l2d)
> 159 {
> 160 if(first) first=false; else result~=", ";
> 161 result ~= k;
> 162 result ~= l;
> 163 result ~= ":";
> 164 result ~= text(cast(Value)d);
> 165 }
> 166 if( prototype !is null )
> 167 {
> 168 result ~= " / ";
> 169 result ~= prototype.toStringWithoutParen();
> 170 }
> 171 return result;
> 172 }
> 173
> 174 string toString() const
> 175 {
> 176 return "{" ~ toStringWithoutParen() ~ "}";
> 177 }
152 178
153 private: 179 private:
154 Table prototype; 180 Table prototype;
155 Kind kind; 181 Kind kind;
156 Value[Layer][string] data; 182 Value[Layer][string] data;
157 183
158 bool setIfExist(string i, Layer lay, Value v) 184 bool setIfExist(string i, Layer lay, Value v)
................................................................................................................................................................................
242 if(auto t = cast(Table)v) 268 if(auto t = cast(Table)v)
243 result ~= tableToAST(theLayer,t); 269 result ~= tableToAST(theLayer,t);
244 else 270 else
245 throw genex!RuntimeException(cast(LexPosition)null, "Inv 271 throw genex!RuntimeException(cast(LexPosition)null, "Inv
246 return result; 272 return result;
247 } 273 }
248 274
249 AST tableToAST( Layer theLayer, Table t ) | 275 AST tableToAST( Layer theLayer, Value vvvv )
250 { 276 {
> 277 Table t = cast(Table)vvvv;
> 278 if( t is null )
> 279 throw genex!RuntimeException(cast(LexPosition)null, "Invalid AST
> 280
251 auto nodeType = t.access!StrValue(theLayer, "is"); 281 auto nodeType = t.access!StrValue(theLayer, "is");
252 if( nodeType is null ) 282 if( nodeType is null )
253 throw genex!RuntimeException(cast(LexPosition)null, "Invalid AST 283 throw genex!RuntimeException(cast(LexPosition)null, "Invalid AST
254 auto pos = extractPos(t); 284 auto pos = extractPos(t);
255 switch(nodeType.data) 285 switch(nodeType.data)
256 { 286 {
257 case "int": 287 case "int":
................................................................................................................................................................................
304 if(auto ll = tt.access!Table(theLayer, "layer")) 334 if(auto ll = tt.access!Table(theLayer, "layer"))
305 { 335 {
306 Layer[] ls; 336 Layer[] ls;
307 foreach(lll; tableAsConsList(theLayer, l 337 foreach(lll; tableAsConsList(theLayer, l
308 if(auto l = cast(StrValue)lll) 338 if(auto l = cast(StrValue)lll)
309 ls ~= l.data; 339 ls ~= l.data;
310 else 340 else
311 throw genex!RuntimeExcep | 341 throw genex!RuntimeExcep
312 ps ~= new Parameter(ss.data, ls); 342 ps ~= new Parameter(ss.data, ls);
313 continue; 343 continue;
314 } 344 }
315 else 345 else
316 { 346 {
317 Layer[] emp; 347 Layer[] emp;
318 ps ~= new Parameter(ss.data, emp); 348 ps ~= new Parameter(ss.data, emp);
> 349 continue;
319 } 350 }
320 throw genex!RuntimeException(cast(LexPosition)nu | 351 throw genex!RuntimeException(cast(LexPosition)nu
321 } 352 }
322 auto bb = tableToAST(theLayer, b); 353 auto bb = tableToAST(theLayer, b);
323 return new FunLiteral(pos,ps,bb); 354 return new FunLiteral(pos,ps,bb);
324 } 355 }
325 throw genex!RuntimeException(cast(LexPosition)null, `Invalid AST 356 throw genex!RuntimeException(cast(LexPosition)null, `Invalid AST
326 default: 357 default:
327 throw genex!RuntimeException(cast(LexPosition)null, sprintf!`Inv 358 throw genex!RuntimeException(cast(LexPosition)null, sprintf!`Inv
328 } 359 }
329 } 360 }