public static TokenType ToTokenType(this HSPTokenType tokentype) { switch (tokentype) { case HSPTokenType.Char: case HSPTokenType.String: return(TokenType.String); case HSPTokenType.Comment: return(TokenType.Comment); case HSPTokenType.Flag: case HSPTokenType.Numeric: return(TokenType.Literal); // Literal? case HSPTokenType.Idenfitier: return(TokenType.Identifier); case HSPTokenType.Keyword: case HSPTokenType.Macro: case HSPTokenType.Preprocessor: return(TokenType.Keyword); case HSPTokenType.Operator: return(TokenType.Operator); case HSPTokenType.Sepatator: return(TokenType.Delimiter); default: return(TokenType.Unknown); } }
public Token(string text, int startIndex, HSPTokenType type) { Text = text; StartIndex = startIndex; Length = Text.Length; Type = type; }
public static TokenColor ToColor(this HSPTokenType tokentype) { switch (tokentype) { case HSPTokenType.Char: case HSPTokenType.String: return(TokenColor.String); case HSPTokenType.Comment: return(TokenColor.Comment); case HSPTokenType.Numeric: case HSPTokenType.Macro: case HSPTokenType.Flag: return(TokenColor.Number); // Literal? case HSPTokenType.Idenfitier: return(TokenColor.Identifier); case HSPTokenType.Keyword: case HSPTokenType.Preprocessor: return(TokenColor.Keyword); default: return(TokenColor.Text); } }