/* Input is e.g. "32p 8c". We want to get out the 2 operators. Then we apply a "puzzler" which tries to combine the operators in a useful way. // Operators p = scaleToHeight : IBWntegralImage -> BWImage c = posterize : BWImage -> BWImage // Juxtaposition of operators _ _ = juxtapose : Op, Op -> Op [left-assoc] */ sclass GazelleVParser > SimpleLeftToRightParser { CalculatedFieldIndexedList, S> operators = new(op -> op.name); *(S text) { super(text); set caseInsensitive; } void addOperators(Iterable> l) { addAll(operators, l); } void parse { while (mainLoop()) {} if (isInteger(token)) parsed.add(parseInt(token)); continue; } parsed.add(findOp(tpp())); } GAbstractOperator findOp(S name) { var ops = operators.getAllByKey(name); if (empty(ops)) warn("Unknown operator: " + name); if (l(ops) > 1) warn("Multiple operator definitions (please use GPolymorphicOperator instead): " + name); ret first(ops); } }