From 51ca0a9ae2c927bc9211e914166585b882c1f69c Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 26 Jul 2017 17:26:26 -0700 Subject: [PATCH] Make some operator-related fields protected in TreeNode. This should allow for the implementation of toString in child nodes. --- src/org/nwapw/abacus/tree/TreeNode.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/org/nwapw/abacus/tree/TreeNode.java b/src/org/nwapw/abacus/tree/TreeNode.java index 8540677..accdefa 100644 --- a/src/org/nwapw/abacus/tree/TreeNode.java +++ b/src/org/nwapw/abacus/tree/TreeNode.java @@ -13,7 +13,7 @@ public abstract class TreeNode { /** * The lexer used to lex tokens. */ - private static Lexer lexer = new Lexer(){{ + protected static Lexer lexer = new Lexer(){{ register("\\+|-|\\*|/|^", TokenType.OP); register("[0-9]+(\\.[0-9]+)?", TokenType.NUM); register("[a-zA-Z]+", TokenType.WORD); @@ -23,7 +23,7 @@ public abstract class TreeNode { /** * A map that maps operations to their precedence. */ - private static HashMap precedenceMap = new HashMap(){{ + protected static HashMap precedenceMap = new HashMap(){{ put("+", 0); put("-", 0); put("*", 1); @@ -33,7 +33,7 @@ public abstract class TreeNode { /** * A map that maps operations to their associativity. */ - private static HashMap associativityMap = + protected static HashMap associativityMap = new HashMap() {{ put("+", OperatorAssociativity.LEFT); put("-", OperatorAssociativity.LEFT); @@ -45,7 +45,7 @@ public abstract class TreeNode { /** * Comparator used to sort token types. */ - private static Comparator tokenSorter = Comparator.comparingInt(e -> e.priority); + protected static Comparator tokenSorter = Comparator.comparingInt(e -> e.priority); /** * Tokenizes a string, converting it into matches