Search in sources :

Example 11 with Result

use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.

the class TestIntervalSet method testEmptyIntersectionSingleElements.

@Test
public void testEmptyIntersectionSingleElements() throws Exception {
    IntervalSet s = IntervalSet.of('a');
    IntervalSet s2 = IntervalSet.of('d');
    String expecting = "{}";
    String result = (s.and(s2)).toString();
    assertEquals(expecting, result);
}
Also used : IntervalSet(org.antlr.v4.runtime.misc.IntervalSet) Test(org.junit.Test)

Example 12 with Result

use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.

the class TestIntervalSet method testNotRIntersectionNotT.

/** The following was broken:
	    {''..'s', 'u'..'￾'} & {''..'q', 's'..'￾'}=
	    {''..'q', 's'}!!!! broken...
	 	'q' is 113 ascii
	 	'u' is 117
	*/
@Test
public void testNotRIntersectionNotT() throws Exception {
    IntervalSet s = IntervalSet.of(0, 's');
    s.add('u', 200);
    IntervalSet s2 = IntervalSet.of(0, 'q');
    s2.add('s', 200);
    String expecting = "{0..113, 115, 117..200}";
    String result = (s.and(s2)).toString();
    assertEquals(expecting, result);
}
Also used : IntervalSet(org.antlr.v4.runtime.misc.IntervalSet) Test(org.junit.Test)

Example 13 with Result

use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.

the class TestIntervalSet method testComplement3.

@Test
public void testComplement3() throws Exception {
    IntervalSet s = IntervalSet.of(1, 96);
    s.add(99, Lexer.MAX_CHAR_VALUE);
    String expecting = "{97..98}";
    String result = (s.complement(1, Lexer.MAX_CHAR_VALUE)).toString();
    assertEquals(expecting, result);
}
Also used : IntervalSet(org.antlr.v4.runtime.misc.IntervalSet) Test(org.junit.Test)

Example 14 with Result

use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.

the class TestIntervalSet method testNotSingleElement.

@Test
public void testNotSingleElement() throws Exception {
    IntervalSet vocabulary = IntervalSet.of(1, 1000);
    vocabulary.add(2000, 3000);
    IntervalSet s = IntervalSet.of(50, 50);
    String expecting = "{1..49, 51..1000, 2000..3000}";
    String result = (s.complement(vocabulary)).toString();
    assertEquals(expecting, result);
}
Also used : IntervalSet(org.antlr.v4.runtime.misc.IntervalSet) Test(org.junit.Test)

Example 15 with Result

use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.

the class TestIntervalSet method testEmptyIntersection.

@Test
public void testEmptyIntersection() throws Exception {
    IntervalSet s = IntervalSet.of('a', 'z');
    IntervalSet s2 = IntervalSet.of('0', '9');
    String expecting = "{}";
    String result = (s.and(s2)).toString();
    assertEquals(expecting, result);
}
Also used : IntervalSet(org.antlr.v4.runtime.misc.IntervalSet) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)131 LexerGrammar (org.antlr.v4.tool.LexerGrammar)78 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)52 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)49 LexerInterpreter (org.antlr.v4.runtime.LexerInterpreter)44 ATN (org.antlr.v4.runtime.atn.ATN)44 TokenStreamRewriter (org.antlr.v4.runtime.TokenStreamRewriter)38 IntervalSet (org.antlr.v4.runtime.misc.IntervalSet)38 BaseJavaTest (org.antlr.v4.test.runtime.java.BaseJavaTest)38 ParseTree (org.antlr.v4.runtime.tree.ParseTree)29 ATNState (org.antlr.v4.runtime.atn.ATNState)11 Grammar (org.antlr.v4.tool.Grammar)10 STGroupString (org.stringtemplate.v4.STGroupString)10 ByteBuffer (java.nio.ByteBuffer)8 IntBuffer (java.nio.IntBuffer)8 UTF8CodePointDecoder (org.antlr.v4.runtime.UTF8CodePointDecoder)8 BaseRuntimeTest.antlrOnString (org.antlr.v4.test.runtime.BaseRuntimeTest.antlrOnString)8 DOTGenerator (org.antlr.v4.tool.DOTGenerator)8 ParserATNFactory (org.antlr.v4.automata.ParserATNFactory)7 Rule (org.antlr.v4.tool.Rule)7