Blog/Models/SyntaxToken.cs 1.2 K · 35 lines · raw · history
| 1 | namespace Blog.Models; |
| 2 | |
| 3 | /// <summary> |
| 4 | /// What a run of characters is, as far as a grayscale highlighter cares. |
| 5 | /// </summary> |
| 6 | /// <remarks> |
| 7 | /// Deliberately short. With no colour to spend, a line of code can carry about three distinctions |
| 8 | /// before they stop being distinctions: what the language says (<see cref="Keyword"/>), what the |
| 9 | /// program says (<see cref="String"/> and <see cref="Number"/>), and what the author says |
| 10 | /// (<see cref="Comment"/>). Everything else is <see cref="Text"/>. |
| 11 | /// </remarks> |
| 12 | public enum SyntaxKind |
| 13 | { |
| 14 | /// <summary>Identifiers, operators, whitespace — anything with no treatment of its own.</summary> |
| 15 | Text, |
| 16 | |
| 17 | Comment, |
| 18 | |
| 19 | /// <summary>A string, character or template literal, quotes included.</summary> |
| 20 | String, |
| 21 | |
| 22 | Number, |
| 23 | |
| 24 | /// <summary>A word the language reserves, and in markup the tag brackets around a name.</summary> |
| 25 | Keyword, |
| 26 | |
| 27 | /// <summary> |
| 28 | /// The line that isn't code: a preprocessor directive, a shell variable, a doctype, a |
| 29 | /// markdown heading, a JSON key. |
| 30 | /// </summary> |
| 31 | Meta |
| 32 | } |
| 33 | |
| 34 | /// <summary>One run of characters from a line, and what it is.</summary> |
| 35 | public sealed record SyntaxToken(SyntaxKind Kind, string Text); |