diff --git a/highlighter.d b/highlighter.d index 03286f7..324712d 100644 --- a/highlighter.d +++ b/highlighter.d @@ -37,30 +37,20 @@ html { background-color: #fff; color: #222; } foreach (Token t; tokens) { - switch (t.type) - { - case TokenType.KEYWORDS_BEGIN: .. case TokenType.KEYWORDS_END: - writeSpan("kwrd", t.value); - break; - case TokenType.TYPES_BEGIN: .. case TokenType.TYPES_END: + if (t.type > TokenType.TYPES_BEGIN && t.type < TokenType.TYPES_END) writeSpan("type", t.value); - break; - case TokenType.Comment: + else if (t.type > TokenType.KEYWORDS_BEGIN && t.type < TokenType.KEYWORDS_END) + writeSpan("kwrd", t.value); + else if (t.type == TokenType.Comment) writeSpan("com", t.value); - break; - case TokenType.STRINGS_BEGIN: .. case TokenType.STRINGS_END: + else if (t.type > TokenType.STRINGS_BEGIN && t.type < TokenType.STRINGS_END) writeSpan("str", t.value); - break; - case TokenType.NUMBERS_BEGIN: .. case TokenType.NUMBERS_END: + else if (t.type > TokenType.NUMBERS_BEGIN && t.type < TokenType.NUMBERS_END) writeSpan("num", t.value); - break; - case TokenType.OPERATORS_BEGIN: .. case TokenType.OPERATORS_END: + else if (t.type > TokenType.OPERATORS_BEGIN && t.type < TokenType.OPERATORS_END) writeSpan("op", t.value); - break; - default: + else stdout.write(t.value.replace("<", "<")); - break; - } } stdout.writeln("\n"); } diff --git a/std/d/lexer.d b/std/d/lexer.d index 88f5249..7174dbb 100644 --- a/std/d/lexer.d +++ b/std/d/lexer.d @@ -539,42 +539,39 @@ enum TokenType: uint XorEquals, /// ^= OPERATORS_END, /// - // Types - TYPES_BEGIN, /// - Bool, /// bool - Byte, /// byte - Cdouble, /// cdouble - Cent, /// cent - Cfloat, /// cfloat - Char, /// char - Creal, /// creal - Dchar, /// dchar - Double, /// double - DString, /// dstring - Float, /// float - Function, /// function - Idouble, /// idouble - Ifloat, /// ifloat - Int, /// int - Ireal, /// ireal - Long, /// long - Real, /// real - Short, /// short - String, /// string - Ubyte, /// ubyte - Ucent, /// ucent - Uint, /// uint - Ulong, /// ulong - Ushort, /// ushort - Void, /// void - Wchar, /// wchar - WString, /// wstring - TYPES_END, /// - Template, /// template - - // Keywords + // Keywords KEYWORDS_BEGIN, /// + TYPES_BEGIN, /// + Bool, /// bool + Byte, /// byte + Cdouble, /// cdouble + Cent, /// cent + Cfloat, /// cfloat + Char, /// char + Creal, /// creal + Dchar, /// dchar + Double, /// double + DString, /// dstring + Float, /// float + Function, /// function + Idouble, /// idouble + Ifloat, /// ifloat + Int, /// int + Ireal, /// ireal + Long, /// long + Real, /// real + Short, /// short + String, /// string + Ubyte, /// ubyte + Ucent, /// ucent + Uint, /// uint + Ulong, /// ulong + Ushort, /// ushort + Void, /// void + Wchar, /// wchar + WString, /// wstring + TYPES_END, /// ATTRIBUTES_BEGIN, /// Align, /// align Deprecated, /// deprecated @@ -643,6 +640,7 @@ enum TokenType: uint Struct, /// struct Super, /// super Switch, /// switch + Template, /// template This, /// this Throw, /// throw True, /// true