static void tok_recordDecls(L tok) { int i; while ((i = jfind(tok, "record (")) >= 0) { int argsFrom = i+6, argsTo = findCodeTokens(tok, i, false, ")"); int idx = findCodeTokens(tok, argsTo, false, "{"); int j = findEndOfBracketPart(tok, idx); S name = tok.get(i+2); bool noEq = eq(get(tok, i-2), "noeq"); if (noEq) tok.set(i-2, ""); new StringBuilder buf; L tArgs = subList(tok, argsFrom-1, argsTo); L> args = tok_typesAndNamesOfParams(tArgs); L contents = subList(tok, idx+1, j); for (Pair p : args) buf.append("\n " + p.a + " " + p.b + ";"); buf.append("\n *() {}"); buf.append("\n *(" + joinWithComma(map(args, func(Pair p) -> S { dropPrefix("new ", p.a) + " *" + p.b })) + ") {}"); if (!(jfind(contents, "toString {") >= 0 || jfind(contents, "toString()") >= 0)) buf.append("\n toString { ret " + quote(name + "(") + " + " + join([[ + ", " + ]], secondOfPairs(args)) + " + \")\"; }"); if (!noEq) buf.append("\n [stdEq]"); tok.set(idx, "{" + buf); tok.set(i, "class"); clearTokens(tok, argsFrom-2, argsTo+1); reTok(tok, i, idx+1); } }