Search in sources :

Example 71 with LexerGrammar

use of org.antlr.v4.tool.LexerGrammar in project antlr4 by tunnelvisionlabs.

the class TestATNConstruction method testCharSetUnicodePropertyInvertEscape.

@Test
public void testCharSetUnicodePropertyInvertEscape() throws Exception {
    LexerGrammar g = new LexerGrammar("lexer grammar P;\n" + "A : [\\P{Gothic}] ;");
    String expecting = "s0->RuleStart_A_1\n" + "RuleStart_A_1->s3\n" + "s3-{0..66351, 66379..1114111}->s4\n" + "s4->RuleStop_A_2\n";
    checkTokensRule(g, null, expecting);
}
Also used : LexerGrammar(org.antlr.v4.tool.LexerGrammar) Test(org.junit.Test)

Example 72 with LexerGrammar

use of org.antlr.v4.tool.LexerGrammar in project antlr4 by tunnelvisionlabs.

the class TestATNConstruction method testCharSetUnicodePropertyOverlap.

@Test
public void testCharSetUnicodePropertyOverlap() throws Exception {
    LexerGrammar g = new LexerGrammar("lexer grammar P;\n" + "A : [\\p{ASCII_Hex_Digit}\\p{Hex_Digit}] ;");
    String expecting = "s0->RuleStart_A_1\n" + "RuleStart_A_1->s3\n" + "s3-{48..57, 65..70, 97..102, 65296..65305, 65313..65318, 65345..65350}->s4\n" + "s4->RuleStop_A_2\n";
    checkTokensRule(g, null, expecting);
}
Also used : LexerGrammar(org.antlr.v4.tool.LexerGrammar) Test(org.junit.Test)

Example 73 with LexerGrammar

use of org.antlr.v4.tool.LexerGrammar in project antlr4 by tunnelvisionlabs.

the class TestATNConstruction method testCharSetUnicodeSMPEscape.

@Test
public void testCharSetUnicodeSMPEscape() throws Exception {
    LexerGrammar g = new LexerGrammar("lexer grammar P;\n" + "A : [\\u{10ABCD}] ;");
    String expecting = "s0->RuleStart_A_1\n" + "RuleStart_A_1->s3\n" + "s3-1092557->s4\n" + "s4->RuleStop_A_2\n";
    checkTokensRule(g, null, expecting);
}
Also used : LexerGrammar(org.antlr.v4.tool.LexerGrammar) Test(org.junit.Test)

Example 74 with LexerGrammar

use of org.antlr.v4.tool.LexerGrammar in project antlr4 by tunnelvisionlabs.

the class TestATNConstruction method testCharSetUnicodeMultiplePropertyEscape.

@Test
public void testCharSetUnicodeMultiplePropertyEscape() throws Exception {
    // Ditto the Mahajani script. Not going to change soon. I hope.
    LexerGrammar g = new LexerGrammar("lexer grammar P;\n" + "A : [\\p{Gothic}\\p{Mahajani}] ;");
    String expecting = "s0->RuleStart_A_1\n" + "RuleStart_A_1->s3\n" + "s3-{66352..66378, 69968..70006}->s4\n" + "s4->RuleStop_A_2\n";
    checkTokensRule(g, null, expecting);
}
Also used : LexerGrammar(org.antlr.v4.tool.LexerGrammar) Test(org.junit.Test)

Example 75 with LexerGrammar

use of org.antlr.v4.tool.LexerGrammar in project antlr4 by tunnelvisionlabs.

the class TestATNConstruction method testCharSet.

@Test
public void testCharSet() throws Exception {
    LexerGrammar g = new LexerGrammar("lexer grammar P;\n" + "A : [abc] ;");
    String expecting = "s0->RuleStart_A_1\n" + "RuleStart_A_1->s3\n" + "s3-{97..99}->s4\n" + "s4->RuleStop_A_2\n";
    checkTokensRule(g, null, expecting);
}
Also used : LexerGrammar(org.antlr.v4.tool.LexerGrammar) Test(org.junit.Test)

Aggregations

LexerGrammar (org.antlr.v4.tool.LexerGrammar)444 Test (org.junit.Test)410 Grammar (org.antlr.v4.tool.Grammar)140 LexerInterpreter (org.antlr.v4.runtime.LexerInterpreter)120 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)100 TokenStreamRewriter (org.antlr.v4.runtime.TokenStreamRewriter)86 ATN (org.antlr.v4.runtime.atn.ATN)72 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)58 BaseJavaTest (org.antlr.v4.test.runtime.java.BaseJavaTest)43 ParserATNFactory (org.antlr.v4.automata.ParserATNFactory)26 ParseTree (org.antlr.v4.runtime.tree.ParseTree)24 LexerATNFactory (org.antlr.v4.automata.LexerATNFactory)22 CharStream (org.antlr.v4.runtime.CharStream)20 TokenStream (org.antlr.v4.runtime.TokenStream)17 LexerATNSimulator (org.antlr.v4.runtime.atn.LexerATNSimulator)14 STGroupString (org.stringtemplate.v4.STGroupString)14 ArrayList (java.util.ArrayList)13 ATNFactory (org.antlr.v4.automata.ATNFactory)12 DFA (org.antlr.v4.runtime.dfa.DFA)12 SemanticPipeline (org.antlr.v4.semantics.SemanticPipeline)12