slight restructure

This commit is contained in:
ChUrl
2020-12-12 16:02:23 +01:00
parent f9dcebc82a
commit a14f15618d
7 changed files with 17 additions and 12 deletions

View File

@ -1,4 +1,4 @@
package util.ast;
package parser.ast;
import java.util.Objects;

View File

@ -1,13 +1,11 @@
package parser;
package parser.ast;
import parser.grammar.Grammar;
import util.ast.AST;
import util.ast.Node;
import java.util.Collection;
import java.util.HashSet;
import static util.tools.Logger.log;
import static util.Logger.log;
public final class ASTCompacter {

View File

@ -1,6 +1,7 @@
package util.ast;
package parser.ast;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
@ -91,6 +92,11 @@ public class Node {
this.children = children;
}
public void setChildren(Node... children) {
this.children = new ArrayList<>();
this.children.addAll(Arrays.asList(children));
}
public long size() {
int s = 0;

View File

@ -1,4 +1,4 @@
package parser;
package parser.grammar;
public enum Actions {
COMPACT,

View File

@ -1,4 +1,4 @@
package util.tools;
package util;
// Maximal professioneller Logger
public final class Logger {

View File

@ -4,8 +4,9 @@ import lexer.StupsLexer;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.Lexer;
import org.junit.jupiter.api.Test;
import parser.ast.AST;
import parser.ast.ASTCompacter;
import parser.grammar.Grammar;
import util.ast.AST;
import java.io.IOException;
import java.net.URISyntaxException;
@ -14,7 +15,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
class GeneralTest {
class Demo {
private Lexer initLexer(String program) {
try {
@ -29,7 +30,7 @@ class GeneralTest {
}
@Test
void testClean() throws URISyntaxException, IOException {
void demo() throws URISyntaxException, IOException {
Path path = Paths.get(this.getClass().getClassLoader().getResource("exampleGrammars/Grammar.grammar").toURI());
Grammar grammar = Grammar.fromFile(path);
LL1Parser parser = LL1Parser.fromGrammar(grammar);

View File

@ -1,4 +1,4 @@
package util.ast;
package parser.ast;
import org.junit.jupiter.api.Test;