Correctly handle invalid strings.

This commit is contained in:
Danila Fedorin 2017-07-26 13:25:12 -07:00
parent ec030607bf
commit f7d4d01bc8
1 changed files with 3 additions and 1 deletions

View File

@ -129,7 +129,9 @@ public abstract class TreeNode {
* @return the resulting tree.
*/
public static TreeNode fromString(String string){
ArrayList<Match<TokenType>> matches = intoPostfix(string, tokenize(string));
ArrayList<Match<TokenType>> matches = tokenize(string);
if(matches == null) return null;
matches = intoPostfix(string, matches);
if(matches == null) return null;
Collections.reverse(matches);