package dev.peerat.parser; import java.io.BufferedWriter; import java.util.LinkedList; import java.util.List; public interface ElementBuilder{ void build(Builder builder) throws Exception; public static class Builder{ private List tokens; public Builder(){ this.tokens = new LinkedList<>(); this.tokens.add(new Token(1,1,"", TokenType.GROUP)); } public void append(Token token){ if(token == null) throw new NullPointerException(); this.tokens.add(token); } public void append(String value){ Token last = tokens.get(tokens.size()-1); append(new Token(last.getLineNumber(), last.getCharacterNumber()+last.getValue().length(), value, TokenType.GROUP)); } public void build(BufferedWriter writer) throws Exception{ } } }