mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 14:56:28 +00:00
completely redo internal TerraScript args
This commit is contained in:
@@ -3,27 +3,25 @@ package structure;
|
||||
import com.dfsek.terra.api.structures.parser.Parser;
|
||||
import com.dfsek.terra.api.structures.parser.exceptions.ParseException;
|
||||
import com.dfsek.terra.api.structures.parser.lang.Block;
|
||||
import com.dfsek.terra.api.structures.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.api.structures.parser.lang.Returnable;
|
||||
import com.dfsek.terra.api.structures.parser.lang.functions.Function;
|
||||
import com.dfsek.terra.api.structures.parser.lang.functions.FunctionBuilder;
|
||||
import com.dfsek.terra.api.structures.structure.Rotation;
|
||||
import com.dfsek.terra.api.structures.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.structures.tokenizer.Position;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class ParserTest {
|
||||
@Test
|
||||
public void parse() throws IOException, ParseException {
|
||||
Parser parser = new Parser(IOUtils.toString(getClass().getResourceAsStream("/test.tesf")));
|
||||
|
||||
parser.addFunction("test", new FunctionBuilder<Test1>() {
|
||||
parser.registerFunction("test", new FunctionBuilder<Test1>() {
|
||||
@Override
|
||||
public Test1 build(List<Returnable<?>> argumentList, Position position) throws ParseException {
|
||||
public Test1 build(List<Returnable<?>> argumentList, Position position) {
|
||||
return new Test1(argumentList.get(0), argumentList.get(1), position);
|
||||
}
|
||||
|
||||
@@ -51,9 +49,9 @@ public class ParserTest {
|
||||
long t = System.nanoTime() - l;
|
||||
System.out.println("Took " + (double) t / 1000000);
|
||||
|
||||
block.apply(null, Rotation.NONE, new Random(), 0);
|
||||
block.apply(null);
|
||||
|
||||
block.apply(null, Rotation.NONE, new Random(), 0);
|
||||
block.apply(null);
|
||||
}
|
||||
|
||||
private static class Test1 implements Function<Void> {
|
||||
@@ -68,8 +66,8 @@ public class ParserTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void apply(Buffer buffer, Rotation rotation, Random random, int recursions) {
|
||||
System.out.println("string: " + a.apply(buffer, rotation, random, recursions) + ", double: " + b.apply(buffer, rotation, random, recursions));
|
||||
public Void apply(ImplementationArguments implementationArguments) {
|
||||
System.out.println("string: " + a.apply(implementationArguments) + ", double: " + b.apply(implementationArguments));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user