mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-20 07:10:24 +00:00
working tokenizer
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package structure;
|
||||
|
||||
import com.dfsek.terra.structure.v2.tokenizer.Lookahead;
|
||||
import com.dfsek.terra.api.structures.tokenizer.Lookahead;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
23
common/src/test/java/structure/TokenizerTest.java
Normal file
23
common/src/test/java/structure/TokenizerTest.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package structure;
|
||||
|
||||
import com.dfsek.terra.api.structures.tokenizer.Token;
|
||||
import com.dfsek.terra.api.structures.tokenizer.Tokenizer;
|
||||
import com.dfsek.terra.api.structures.tokenizer.exceptions.TokenizerException;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TokenizerTest {
|
||||
@Test
|
||||
public void tokens() throws IOException, TokenizerException {
|
||||
Tokenizer tokenizer = new Tokenizer(IOUtils.toString(getClass().getResourceAsStream("/test.tesf")));
|
||||
|
||||
for(int i = 0; i < 100; i++) {
|
||||
Token t = tokenizer.fetch();
|
||||
if(t == null) break;
|
||||
System.out.println(t);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
18
common/src/test/resources/test.tesf
Normal file
18
common/src/test/resources/test.tesf
Normal file
@@ -0,0 +1,18 @@
|
||||
FUNCTION(1, "hello");
|
||||
|
||||
;
|
||||
)
|
||||
|
||||
FUNCTION2(1.2, "he423llo");
|
||||
|
||||
// comment
|
||||
|
||||
FUNCTION3(3.4, "35234523452345");
|
||||
|
||||
/*
|
||||
block comment
|
||||
fsfsdf
|
||||
gsdfgsdfg
|
||||
*/
|
||||
|
||||
FUNCTION(1, "hello");
|
||||
Reference in New Issue
Block a user