public virtual string GetTokenDisplayName( int ttype )
{
string tokenName = null;
int index = 0;
// inside any target's char range and is lexer grammar?
if ( this.type == GrammarType.Lexer &&
ttype >= Label.MIN_CHAR_VALUE && ttype <= Label.MAX_CHAR_VALUE )
{
return GetANTLRCharLiteralForChar( ttype );
}
// faux label?
else if ( ttype < 0 )
{
tokenName = (string)composite.TypeToTokenList[Label.NUM_FAUX_LABELS + ttype];
}
else
{
// compute index in typeToTokenList for ttype
index = ttype - 1; // normalize to 0..n-1
index += Label.NUM_FAUX_LABELS; // jump over faux tokens
if ( index < composite.TypeToTokenList.Count )
{
tokenName = (string)composite.TypeToTokenList[index];
if ( tokenName != null &&
tokenName.StartsWith( AUTO_GENERATED_TOKEN_NAME_PREFIX ) )
{
tokenName = composite.TypeToStringLiteralList[ttype];
}
}
else
{
tokenName = ttype.ToString(); // String.valueOf( ttype );
}
}
//[email protected]("getTokenDisplayName ttype="+ttype+", index="+index+", name="+tokenName);
return tokenName;
}