From b1b8af014dd943cf204f9d111ffcf6f36d4084ae Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sat, 5 Aug 2017 16:01:08 -0700 Subject: [PATCH] Prevent leaving unparsed tokens ignored, throwing error instead. --- src/main/java/org/nwapw/abacus/parsing/ShuntingYardParser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/nwapw/abacus/parsing/ShuntingYardParser.java b/src/main/java/org/nwapw/abacus/parsing/ShuntingYardParser.java index e6e930d..5d35032 100644 --- a/src/main/java/org/nwapw/abacus/parsing/ShuntingYardParser.java +++ b/src/main/java/org/nwapw/abacus/parsing/ShuntingYardParser.java @@ -164,7 +164,8 @@ public class ShuntingYardParser implements Parser>, PluginListe tokens = intoPostfix(new ArrayList<>(tokens)); if(tokens == null) return null; Collections.reverse(tokens); - return constructRecursive(tokens); + TreeNode constructedTree = constructRecursive(tokens); + return tokens.size() == 0 ? constructedTree : null; } @Override