Java Code Examples for org.antlr.runtime.Token#MIN_TOKEN_TYPE

The following examples show how to use org.antlr.runtime.Token#MIN_TOKEN_TYPE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TokenTypeToStringMapper.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void initIds(Map<Integer, String> tokenDefMap) {
	mappedValues = new String[tokenDefMap.size()];
	for (Entry<Integer, String> entry : tokenDefMap.entrySet()) {
		if (entry.getKey() >= Token.MIN_TOKEN_TYPE)
			mappedValues[entry.getKey() - Token.MIN_TOKEN_TYPE] = calculateId(entry.getValue(), entry.getKey());
	}
}
 
Example 2
Source File: XtextTokenStream.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Object get(int index) {
	Token tok = (Token) super.get(index);
	// adjust only tokens in the 'future', as we wont change the channel of previously parsed
	// tokens
	int current = p;
	if (firstMarker != -1)
		current = firstMarker;
	if (hiddenTokens != null && tok.getType() >= Token.MIN_TOKEN_TYPE && index >= current)
		tok.setChannel(hiddenTokens.get(tok.getType()) ? Token.HIDDEN_CHANNEL : Token.DEFAULT_CHANNEL);
	return tok;
}
 
Example 3
Source File: BaseInternalContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Map<Integer, String> getTokenDefMap() {
	String[] names = getTokenNames();
	Map<Integer, String> result = Maps.newHashMapWithExpectedSize(names.length - Token.MIN_TOKEN_TYPE);
	for (int i = Token.MIN_TOKEN_TYPE; i < names.length; i++) {
		result.put(i, getValueForTokenName(names[i]));
	}
	return result;
}
 
Example 4
Source File: TokenTypeToStringMapper.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected void initIds(Map<Integer, String> tokenDefMap) {
	mappedValues = new String[tokenDefMap.size()];
	for (Map.Entry<Integer, String> entry : tokenDefMap.entrySet()) {
		if (entry.getKey() >= Token.MIN_TOKEN_TYPE) {
			mappedValues[entry.getKey() - Token.MIN_TOKEN_TYPE] = calculateId(entry.getValue(), entry.getKey());
		}
	}
}
 
Example 5
Source File: TokenTypeToStringMapper.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected String getMappedValue(int tokenType) {
	if (tokenType == Token.INVALID_TOKEN_TYPE) {
		return HighlightingStyles.INVALID_TOKEN_ID;
	} else {
		return mappedValues[tokenType - Token.MIN_TOKEN_TYPE];
	}
}
 
Example 6
Source File: TokenTypeToStringMapper.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected String getMappedValue(int tokenType) {
	if (tokenType == Token.INVALID_TOKEN_TYPE)
		return HighlightingStyles.INVALID_TOKEN_ID;
	return mappedValues[tokenType-Token.MIN_TOKEN_TYPE];
}