svoid tok_qFunctions(LS tok) { tok_qFunctions(tok, "q", "dm_q"); tok_qFunctions(tok, "runInQAndWait", "dm_runInQAndWait"); } svoid tok_qFunctions(LS tok, S keyword, S function) { int i; while ((i = jfind_check(keyword, tok, "void " + keyword + " {")) >= 0) { int bracket = findCodeTokens(tok, i, false, "{"); int j = findEndOfBracketPart(tok, bracket); clearTokens(tok, i+4, i+6); tok.set(bracket, "{ " + function + "(module(), r {"); tok.set(j-1, "}); }"); reTok(tok, i+4, j); } while ((i = jfind_check(keyword, tok, ") " + keyword + " {")) >= 0) { int opening = findBeginningOfBracketPart(tok, i); S fname = assertIdentifier(get(tok, opening-2)); int bracket = findCodeTokens(tok, i, false, "{"); int j = findEndOfBracketPart(tok, bracket); clearTokens(tok, i+2, i+4); tok.set(bracket, "{ " + function + "(module(), r {"); tok.set(j-1, "}); }"); reTok(tok, i+4, j); tok_makeArgumentsFinal(tok, opening, i); } }