0
In this way, it is returning some errors and it seems that it may present conflicts in the cases of 2-character operators.
Example: "++" being replaced by "#++#" while the next replaceAll()
it will replace the operands of "#++#" to "##+##+##".
private String[] sliptBySpecialCharacteres(String lexeme) {
return lexeme.replaceAll("==", "#==#")
.replaceAll("&&", "#&&#")
.replaceAll("=", "#=#")
.replaceAll(">", "#>#")
.replaceAll("++", "#++#")
.replaceAll("<=", "#<=#")
.replaceAll("!", "#!#")
.replaceAll("-", "#-#")
.replaceAll("--", "#--#")
.replaceAll("+", "#+#")
.replaceAll("+=", "#+=#")
.replaceAll("*", "#*#")
.replaceAll(",", "#,#")
.replaceAll(".", "#.#")
.replaceAll("[", "#[#")
.replaceAll("{", "#{#")
.replaceAll("(", "#(#")
.replaceAll(")", "#)#")
.replaceAll("}", "#}#")
.replaceAll("]", "#]#")
.split("#");
}
The goal is to go from
++
for##+##+##
? And if it is<=
or]
would look like ?– Isac