X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.graph.compiler%2Ftests%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Ftests%2FRangeParsingTest.java;fp=bundles%2Forg.simantics.graph.compiler%2Ftests%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Ftests%2FRangeParsingTest.java;h=4d2e2f201ffb42294f113b45193038f41375fb33;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.graph.compiler/tests/org/simantics/graph/compiler/tests/RangeParsingTest.java b/bundles/org.simantics.graph.compiler/tests/org/simantics/graph/compiler/tests/RangeParsingTest.java new file mode 100644 index 000000000..4d2e2f201 --- /dev/null +++ b/bundles/org.simantics.graph.compiler/tests/org/simantics/graph/compiler/tests/RangeParsingTest.java @@ -0,0 +1,41 @@ +package org.simantics.graph.compiler.tests; + +import org.antlr.runtime.ANTLRStringStream; +import org.antlr.runtime.CharStream; +import org.antlr.runtime.CommonTokenStream; +import org.antlr.runtime.Token; +import org.antlr.runtime.TokenStream; +import org.antlr.runtime.tree.Tree; +import org.junit.Test; +import org.simantics.databoard.util.Range; +import org.simantics.graph.compiler.internal.parsing.GraphLexer; +import org.simantics.graph.compiler.internal.parsing.GraphParser; + +public class RangeParsingTest { + + public static GraphParser parse(String text) { + CharStream stream = new ANTLRStringStream(text); + GraphLexer lexer = new GraphLexer(stream); + TokenStream tokenStream = new CommonTokenStream(lexer); + for(int i=1;;++i) { + Token token = tokenStream.LT(i); + if(token.getType() == GraphParser.EOF) + break; + System.out.println( + GraphParser.tokenNames[token.getType()] + " " + token.getText()); + } + return new GraphParser(tokenStream); + } + + @Test + public void testRangeParsing() throws Exception { + Tree tree = (Tree)parse("[1..2.3]").parameterValue().getTree(); + System.out.println(tree.toStringTree()); + } + + @Test + public void testRangeInDataboard() throws Exception { + Range.valueOfUnchecked("[0..1]"); + } + +}