/** Get a meaningful name for a token type useful during code generation.
* Literals without associated names are converted to the string equivalent
* of their integer values. Used to generate x==ID and x==34 type comparisons
* etc... Essentially we are looking for the most obvious way to refer
* to a token type in the generated code.
*/
public virtual string GetTokenTypeAsTargetLabel(Grammar g, int ttype)
{
string name = g.GetTokenName(ttype);
// If name is not valid, return the token type instead
if (Grammar.INVALID_TOKEN_NAME.Equals(name))
{
return ttype.ToString();
}
return name;
}