/* e.g. "he is called " => he is called $1 & $1 is (a name) */ sclass AngleBracketVarsToConditions { S mainLine; new LS conditions; swappable S makeDollarVar() { ret main makeDollarVar(); } swappable S categoryToNounPhrase(S s) { ret aOrAn_opt(s); } swappable S makeCondition(S var, S type) { ret var + " is " + roundOpt(categoryToNounPhrase(type)); } S go(S s) { LS tok = javaTokWithAngleBrackets(s); conditions.clear(); for (int i : indicesOfAngleBracketVars(tok)) { S var = makeDollarVar(); conditions.add(makeCondition(var, deAngleBracket(tok.get(i)))); tok.set(i, var); } ret mainLine = join(tok); } S joined() { ret joinWithAmpersand(itemPlusList(mainLine, conditions)); } }