Search in sources :

Example 1 with IntegerList

use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by antlr.

the class BaseGoTest method getTokenTypesViaATN.

public IntegerList getTokenTypesViaATN(String input, LexerATNSimulator lexerATN) {
    ANTLRInputStream in = new ANTLRInputStream(input);
    IntegerList tokenTypes = new IntegerList();
    int ttype;
    do {
        ttype = lexerATN.match(in, Lexer.DEFAULT_MODE);
        tokenTypes.add(ttype);
    } while (ttype != Token.EOF);
    return tokenTypes;
}
Also used : IntegerList(org.antlr.v4.runtime.misc.IntegerList) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream)

Example 2 with IntegerList

use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by antlr.

the class BaseCppTest method getTokenTypesViaATN.

public IntegerList getTokenTypesViaATN(String input, LexerATNSimulator lexerATN) {
    ANTLRInputStream in = new ANTLRInputStream(input);
    IntegerList tokenTypes = new IntegerList();
    int ttype;
    do {
        ttype = lexerATN.match(in, Lexer.DEFAULT_MODE);
        tokenTypes.add(ttype);
    } while (ttype != Token.EOF);
    return tokenTypes;
}
Also used : IntegerList(org.antlr.v4.runtime.misc.IntegerList) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream)

Example 3 with IntegerList

use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by antlr.

the class BaseJavaTest method getTokenTypesViaATN.

public IntegerList getTokenTypesViaATN(String input, LexerATNSimulator lexerATN) {
    ANTLRInputStream in = new ANTLRInputStream(input);
    IntegerList tokenTypes = new IntegerList();
    int ttype;
    do {
        ttype = lexerATN.match(in, Lexer.DEFAULT_MODE);
        tokenTypes.add(ttype);
    } while (ttype != Token.EOF);
    return tokenTypes;
}
Also used : IntegerList(org.antlr.v4.runtime.misc.IntegerList) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream)

Example 4 with IntegerList

use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by antlr.

the class BaseJavaTest method getTypesFromString.

//	public void minimizeDFA(DFA dfa) {
//		DFAMinimizer dmin = new DFAMinimizer(dfa);
//		dfa.minimized = dmin.minimize();
//	}
IntegerList getTypesFromString(Grammar g, String expecting) {
    IntegerList expectingTokenTypes = new IntegerList();
    if (expecting != null && !expecting.trim().isEmpty()) {
        for (String tname : expecting.replace(" ", "").split(",")) {
            int ttype = g.getTokenType(tname);
            expectingTokenTypes.add(ttype);
        }
    }
    return expectingTokenTypes;
}
Also used : IntegerList(org.antlr.v4.runtime.misc.IntegerList) STGroupString(org.stringtemplate.v4.STGroupString)

Example 5 with IntegerList

use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by antlr.

the class BaseNodeTest method getTypesFromString.

IntegerList getTypesFromString(Grammar g, String expecting) {
    IntegerList expectingTokenTypes = new IntegerList();
    if (expecting != null && !expecting.trim().isEmpty()) {
        for (String tname : expecting.replace(" ", "").split(",")) {
            int ttype = g.getTokenType(tname);
            expectingTokenTypes.add(ttype);
        }
    }
    return expectingTokenTypes;
}
Also used : IntegerList(org.antlr.v4.runtime.misc.IntegerList) STGroupString(org.stringtemplate.v4.STGroupString) BaseRuntimeTest.antlrOnString(org.antlr.v4.test.runtime.BaseRuntimeTest.antlrOnString)

Aggregations

IntegerList (org.antlr.v4.runtime.misc.IntegerList)42 Test (org.junit.Test)12 STGroupString (org.stringtemplate.v4.STGroupString)7 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)6 ATN (org.antlr.v4.runtime.atn.ATN)6 LexerATNSimulator (org.antlr.v4.runtime.atn.LexerATNSimulator)6 ArrayList (java.util.ArrayList)5 TokenStream (org.antlr.v4.runtime.TokenStream)5 DFA (org.antlr.v4.runtime.dfa.DFA)5 IntervalSet (org.antlr.v4.runtime.misc.IntervalSet)5 BaseRuntimeTest.antlrOnString (org.antlr.v4.test.runtime.BaseRuntimeTest.antlrOnString)5 ParserATNFactory (org.antlr.v4.automata.ParserATNFactory)4 DOTGenerator (org.antlr.v4.tool.DOTGenerator)4 Rule (org.antlr.v4.tool.Rule)4 HashMap (java.util.HashMap)3 ATNState (org.antlr.v4.runtime.atn.ATNState)3 BlockStartState (org.antlr.v4.runtime.atn.BlockStartState)3 MockIntTokenStream (org.antlr.v4.test.runtime.MockIntTokenStream)3 RuntimeTestUtils.getTokenTypesViaATN (org.antlr.v4.test.runtime.RuntimeTestUtils.getTokenTypesViaATN)3 BufferedWriter (java.io.BufferedWriter)2