1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-11-16 07:33:09 -08:00
Abacus/src/main/java/org/nwapw/abacus/parsing/TreeBuilder.java

24 lines
534 B
Java
Raw Normal View History

package org.nwapw.abacus.parsing;
import org.nwapw.abacus.tree.TreeNode;
import java.util.List;
public class TreeBuilder<T> {
private Tokenizer<T> tokenizer;
private Parser<T> parser;
public TreeBuilder(Tokenizer<T> tokenizer, Parser<T> parser){
this.tokenizer = tokenizer;
this.parser = parser;
}
public TreeNode fromString(String input){
List<T> tokens = tokenizer.tokenizeString(input);
if(tokens == null) return null;
return parser.constructTree(tokens);
}
}