Warning: session_start(): open(/var/lib/php/sessions/sess_1g50m4b7mrrijq53ddjp3fjh5o, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
static void tok_recordDecls(L tok) {
int i;
bool re = false;
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, "");
bool noToString = eq(get(tok, i-2), "noToString");
if (noToString) 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 " + jreplace(p.a, "...", "[]") + " " + p.b + ";");
buf.append("\n *() {}");
buf.append("\n *(" + joinWithComma(map(args, func(Pair p) -> S {
dropPrefix("new ", p.a) + " *" + p.b })) + ") {}");
if (!noToString && !(jfind(contents, "toString {") >= 0 || jfind(contents, "toString()") >= 0))
buf.append("\n toString { ret "
+ quote(name + "(")
+ " + "
+ join([[ + ", " + ]], secondOfPairs(args))
+ " + \")\"; }");
if (!noEq) {
//buf.append("\n [stdEq]");
buf.append(tok_genEqualsAndHashCode(name, args));
}
tok.set(idx, "{" + buf);
tok.set(i, "class");
clearTokens(tok, argsFrom-2, argsTo+1);
reTok(tok, i, idx+1);
tok_addFieldOrder(tok, i);
set re;
}
if (re) reTok(tok);
}
static bool allVarNames_debug;
static L allVarNames(L tok) {
print(join(tok));
bool debug = allVarNames_debug;
Map bracketMap = getBracketMap(tok);
new L varNames;
for (int i = 3; i < tok.size(); i += 2) {
S t = tok.get(i);
print("Got token: " + t);
if (eqOneOf(t, "=", ";", ",")) {
S v = tok.get(i-2);
if (isIdentifier(v))
varNames.add(v);
if (eq(t, "=")) {
i = scanToEndOfInitializer(tok, bracketMap, i)+1;
assertTrue(odd(i));
}
} else if (eq(t, "<")) {
i = findEndOfTypeArgs(tok, i)+1;
if (debug)
print("Skipped type args: " + struct(subList(tok, i)));
} else if (eqOneOf(t, "{", "("))
i = findEndOfBracketPart(tok, i)+1; // skip function/class bodies
}
return varNames;
}
p-exp {
LS tok = javaTok([[record Definition(S word, S definition) {}]]);
tok_recordDecls(tok);
print(join(tok));
assertTrue(join(tok).contains([[_fieldOrder = "word definition"]]));
print("OK");
}