Example usage for org.antlr.v4.runtime.misc IntervalSet toList

List of usage examples for org.antlr.v4.runtime.misc IntervalSet toList

Introduction

In this page you can find the example usage for org.antlr.v4.runtime.misc IntervalSet toList.

Prototype

@Override
    public List<Integer> toList() 

Source Link

Usage

From source file:cx2x.translator.language.base.ClawLanguage.java

License:BSD License

/**
 * Get a readable list of token found in an IntervalSet.
 *
 * @param set    Set of tokens to be found.
 * @param parser Current parser instance.
 * @return List of human readable tokens.
 *///from  w  w  w.  ja  v a 2  s.  c  o m
private static List<String> getTokens(IntervalSet set, ClawParser parser) {
    List<String> tokens = new ArrayList<>();
    for (int tokenId : set.toList()) {
        if (parser.getVocabulary().getLiteralName(tokenId) == null) {
            tokens.add(parser.getVocabulary().getDisplayName(tokenId));
        } else {
            tokens.add(parser.getVocabulary().getLiteralName(tokenId));
        }
    }
    return tokens;
}