public List<String> toPrefix(String in) { List<String> tokens = buildTokens(alignINClause(in)); List<String> output = new ArrayList<String>(); List<String> stack = new ArrayList<String>(); for (String token : tokens) { if (isOperand(token)) { if (token.equals(")")) { while (openParanthesesFound(stack)) { output.add(stack.remove(stack.size() - 1)); } if (stack.size() > 0) { // temporarily fix for issue #189 stack.remove(stack.size() - 1); } } else { while (openParanthesesFound(stack) && !hasHigherPrecedence(token, stack.get(stack.size() - 1))) { output.add(stack.remove(stack.size() - 1)); } stack.add(token); } } else { output.add(token); } } while (stack.size() > 0) { output.add(stack.remove(stack.size() - 1)); } return output; }
public List<String> toPrefix(String in) { List<String> tokens = buildTokens(alignINClause(in)); List<String> output = new ArrayList<String>(); List<String> stack = new ArrayList<String>(); for (String token : tokens) { if (isOperand(token)) { if (token.equals(")")) { while (openParanthesesFound(stack)) { output.add(stack.remove(stack.size() - 1)); } if (stack.size() > 0) { // temporarily fix for issue #189 stack.remove(stack.size() - 1); } } else { while (openParanthesesFound(stack) && !hasHigherPrecedence(token, stack.get(stack.size() - 1))) { output.add(stack.remove(stack.size() - 1)); } stack.add(token); } } else { output.add(token); } } while (stack.size() > 0) { output.add(stack.remove(stack.size() - 1)); } return output; }
for (int i = 0; i < tokens.size(); i++) { Object tokenObj = tokens.get(i); if (tokenObj instanceof String && parser.isOperand((String) tokenObj)) { String token = (String) tokenObj; if ("=".equals(token) || "==".equals(token)) {
for (int i = 0; i < tokens.size(); i++) { Object tokenObj = tokens.get(i); if (tokenObj instanceof String && parser.isOperand((String) tokenObj)) { String token = (String) tokenObj; if ("=".equals(token) || "==".equals(token)) {