@@ -148,8 +148,34 @@ return next.access!T(lay,rest); } return null; } + + string toStringWithoutParen() const + { + string result; + bool first = true; + foreach(k, l2d; data) + foreach(l,d; l2d) + { + if(first) first=false; else result~=", "; + result ~= k; + result ~= l; + result ~= ":"; + result ~= text(cast(Value)d); + } + if( prototype !is null ) + { + result ~= " / "; + result ~= prototype.toStringWithoutParen(); + } + return result; + } + + string toString() const + { + return "{" ~ toStringWithoutParen() ~ "}"; + } private: Table prototype; Kind kind; @@ -245,10 +271,14 @@ throw genex!RuntimeException(cast(LexPosition)null, "Invalid AST (non-table in cons-list)"); return result; } -AST tableToAST( Layer theLayer, Table t ) +AST tableToAST( Layer theLayer, Value vvvv ) { + Table t = cast(Table)vvvv; + if( t is null ) + throw genex!RuntimeException(cast(LexPosition)null, "Invalid AST (not a table)"); + auto nodeType = t.access!StrValue(theLayer, "is"); if( nodeType is null ) throw genex!RuntimeException(cast(LexPosition)null, "Invalid AST {is:(not string)}"); auto pos = extractPos(t); @@ -307,18 +337,19 @@ foreach(lll; tableAsConsList(theLayer, ll)) if(auto l = cast(StrValue)lll) ls ~= l.data; else - throw genex!RuntimeException(cast(LexPosition)null, `Invalid AST {bad fun params}`); + throw genex!RuntimeException(cast(LexPosition)null, sprintf!`Invalid AST {bad fun params %s}`(lll)); ps ~= new Parameter(ss.data, ls); continue; } else { Layer[] emp; ps ~= new Parameter(ss.data, emp); + continue; } - throw genex!RuntimeException(cast(LexPosition)null, `Invalid AST {bad fun params}`); + throw genex!RuntimeException(cast(LexPosition)null, sprintf!`Invalid AST {bad fun params %s}`(v)); } auto bb = tableToAST(theLayer, b); return new FunLiteral(pos,ps,bb); }