From 5e8afd54e04f9d4fc4faf2ab6ee66bc3af29c0b9 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 30 Jul 2017 14:59:20 -0700 Subject: [PATCH] Add some comments. --- src/main/java/org/nwapw/abacus/Abacus.java | 5 ++++ .../org/nwapw/abacus/parsing/TreeBuilder.java | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/main/java/org/nwapw/abacus/Abacus.java b/src/main/java/org/nwapw/abacus/Abacus.java index 17aeb90..250c8b5 100644 --- a/src/main/java/org/nwapw/abacus/Abacus.java +++ b/src/main/java/org/nwapw/abacus/Abacus.java @@ -146,6 +146,11 @@ public class Abacus { return tree.reduce(numberReducer); } + /** + * Creates a number from a string. + * @param numberString the string to create the number from. + * @return the resulting number. + */ public NumberInterface numberFromString(String numberString){ Class toInstantiate = pluginManager.numberFor(configuration.getNumberImplementation()); diff --git a/src/main/java/org/nwapw/abacus/parsing/TreeBuilder.java b/src/main/java/org/nwapw/abacus/parsing/TreeBuilder.java index 57de6ed..76eebee 100644 --- a/src/main/java/org/nwapw/abacus/parsing/TreeBuilder.java +++ b/src/main/java/org/nwapw/abacus/parsing/TreeBuilder.java @@ -4,16 +4,40 @@ import org.nwapw.abacus.tree.TreeNode; import java.util.List; +/** + * TreeBuilder class used to piece together a Tokenizer and + * Parser of the same kind. This is used to essentially avoid + * working with any parameters at all, and the generics + * in this class are used only to ensure the tokenizer and parser + * are of the same type. + * @param the type of tokens created by the tokenizer and used by the parser. + */ public class TreeBuilder { + /** + * The tokenizer used to convert a string into tokens. + */ private Tokenizer tokenizer; + /** + * The parser used to parse a list of tokens into a tree. + */ private Parser parser; + /** + * Create a new Tree Builder with the given tokenizer and parser + * @param tokenizer the tokenizer to turn strings into tokens + * @param parser the parser to turn tokens into a tree + */ public TreeBuilder(Tokenizer tokenizer, Parser parser){ this.tokenizer = tokenizer; this.parser = parser; } + /** + * Parse the given string into a tree. + * @param input the string to parse into a tree. + * @return the resulting tree. + */ public TreeNode fromString(String input){ List tokens = tokenizer.tokenizeString(input); if(tokens == null) return null;