Search in sources :

Example 36 with CodePointCharStream

use of org.antlr.v4.runtime.CodePointCharStream in project antlr4 by antlr.

the class TestCodePointCharStream method singleCJKCodePointHasSize1.

@Test
public void singleCJKCodePointHasSize1() {
    CodePointCharStream s = CharStreams.fromString("愛");
    assertEquals(1, s.size());
    assertEquals(0, s.index());
}
Also used : CodePointCharStream(org.antlr.v4.runtime.CodePointCharStream) Test(org.junit.Test)

Example 37 with CodePointCharStream

use of org.antlr.v4.runtime.CodePointCharStream in project antlr4 by antlr.

the class TestCodePointCharStream method singleCJKCodePointLookAheadShouldReturnCodePoint.

@Test
public void singleCJKCodePointLookAheadShouldReturnCodePoint() {
    CodePointCharStream s = CharStreams.fromString("愛");
    assertEquals(0x611B, s.LA(1));
    assertEquals(0, s.index());
}
Also used : CodePointCharStream(org.antlr.v4.runtime.CodePointCharStream) Test(org.junit.Test)

Example 38 with CodePointCharStream

use of org.antlr.v4.runtime.CodePointCharStream in project antlr4 by antlr.

the class TestCodePointCharStream method seekWithLatin.

@Test
public void seekWithLatin() {
    CodePointCharStream s = CharStreams.fromString("0123456789");
    s.seek(5);
    assertEquals('5', s.LA(1));
}
Also used : CodePointCharStream(org.antlr.v4.runtime.CodePointCharStream) Test(org.junit.Test)

Example 39 with CodePointCharStream

use of org.antlr.v4.runtime.CodePointCharStream in project bmoth by hhu-stups.

the class Parser method getParser.

private BMoThParser getParser(String inputString) {
    CodePointCharStream fromString = CharStreams.fromString(inputString);
    final BMoThLexer lexer = new BMoThLexer(fromString);
    // create a buffer of tokens pulled from the lexer
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    BMoThParser bMoThParser = new BMoThParser(tokens);
    bMoThParser.removeErrorListeners();
    ErrorListener errorListener = new ErrorListener();
    bMoThParser.addErrorListener(errorListener);
    return bMoThParser;
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) BMoThParser(de.bmoth.antlr.BMoThParser) BMoThLexer(de.bmoth.antlr.BMoThLexer) CodePointCharStream(org.antlr.v4.runtime.CodePointCharStream)

Example 40 with CodePointCharStream

use of org.antlr.v4.runtime.CodePointCharStream in project drill by apache.

the class SchemaExprParser method initParser.

private static SchemaParser initParser(String value) {
    CodePointCharStream stream = CharStreams.fromString(value);
    UpperCaseCharStream upperCaseStream = new UpperCaseCharStream(stream);
    SchemaLexer lexer = new SchemaLexer(upperCaseStream);
    lexer.removeErrorListeners();
    lexer.addErrorListener(ErrorListener.INSTANCE);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    SchemaParser parser = new SchemaParser(tokens);
    parser.removeErrorListeners();
    parser.addErrorListener(ErrorListener.INSTANCE);
    return parser;
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) CodePointCharStream(org.antlr.v4.runtime.CodePointCharStream)

Aggregations

CodePointCharStream (org.antlr.v4.runtime.CodePointCharStream)37 Test (org.junit.Test)34 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)5 JavaLanguageLexer (com.puppycrawl.tools.checkstyle.grammar.java.JavaLanguageLexer)2 JavaLanguageParser (com.puppycrawl.tools.checkstyle.grammar.java.JavaLanguageParser)2 BMoThLexer (de.bmoth.antlr.BMoThLexer)2 BMoThParser (de.bmoth.antlr.BMoThParser)2 CharStream (org.antlr.v4.runtime.CharStream)2 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)1 DetailAST (com.puppycrawl.tools.checkstyle.api.DetailAST)1 FileContents (com.puppycrawl.tools.checkstyle.api.FileContents)1 FileText (com.puppycrawl.tools.checkstyle.api.FileText)1 VisitorException (de.bmoth.parser.ErrorListener.VisitorException)1 java.io (java.io)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Paths (java.nio.file.Paths)1 java.util (java.util)1 Logger (java.util.logging.Logger)1