List<org.parboiled.Node<Node>> operators,
List<String> operatorTexts) {
if (operators == null || operators.isEmpty()) return operand.getValue();
Node current = operand.getValue();
for (int i = operators.size() - 1; i >= 0; i--) {
org.parboiled.Node<Node> operator = operators.get(i);
Node prev = current;
if (operator == null) continue;
if (!operator.getChildren().isEmpty() && "cast".equals(operator.getChildren().get(0).getLabel())) {
current = new Cast().rawOperand(current).rawTypeReference(operator.getValue());
} else {
String symbol = operatorTexts.get(i);
if (symbol == null) continue;
symbol = symbol.trim();
if (symbol.isEmpty()) continue;
UnaryOperator op = UnaryOperator.fromSymbol(symbol, false);
UnaryExpression expr = new UnaryExpression().rawOperand(current);
if (op != null) expr.astOperator(op);
current = expr;
}
if (prev != null && !prev.getPosition().isUnplaced() && prev != current && current != null) {
positionSpan(current, operator, operand);
}
}
return current;