!636 !sf !string == !L !cast !class _javax 19 // this is only required because of #629 bugs... main { static O in; static boolean silent; psvm { if (in == null) in = "values (1,,'yo\"yo\"',3),(4,null,5);"; new main m; List data = m.process((S) in); if (!silent) print(structure(data)); in = data; } List data; List row; List process(String in) { data = null; debug(in); L tok = mysqlTok(in); data = new List; int i = indexOfIgnoreCase(tok, "values"), j = indexOfIgnoreCase(tok, ";"); if (i < 0 || j < 0) fail("ouch"); debug(i, j); for (i += 2; i < j; i += 2) { S token = tok.get(i); if (token == "(") { start_a_row(); } else if (token == ")") { end_row(); } else if (token == ",") { } else if (token.startsWith("\"") || token.startsWith("'")) save(mysqlUnquote(token)); else if (isInteger(token)) save(token); else if (token.equalsIgnoreCase("null")) save(null); else badToken(token); } return data; } void start_a_row() { debug("start_a_row"); row = new List; } boolean end_row() { debug("end_row"); if (row != null) { data.add(row); row = null; return true; } return false; } void save(Object value) { debug("save"); row.add(value); } static boolean debug; void debug(O... o) { if (debug) print(structure(o)); } void badToken(S token) { fail("Bad token: " + token); } }