diff options
author | June McEnroe <june@causal.agency> | 2019-02-07 03:33:56 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-02-07 03:33:56 -0500 |
commit | 236b75da9993417c3d86a10ab47497c484c29b13 (patch) | |
tree | 0423aedc08983015062cb6d92493d2c6a9ec611e | |
parent | Add Todo class and parent syntax constraint (diff) | |
download | src-236b75da9993417c3d86a10ab47497c484c29b13.tar.gz src-236b75da9993417c3d86a10ab47497c484c29b13.zip |
Add Escape class to hi
-rw-r--r-- | bin/hi.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/bin/hi.c b/bin/hi.c index 42db61a0..2a5a235d 100644 --- a/bin/hi.c +++ b/bin/hi.c @@ -32,6 +32,7 @@ enum Class { Keyword, Macro, String, + Escape, Comment, Todo, ClassCount, @@ -54,12 +55,17 @@ static const struct Syntax CSyntax[] = { { Keyword, .subexp = 2, .pattern = CKB"(case|default)"CKB }, { Macro, .pattern = "^#.*" }, { String, .pattern = "^#include (<.*>)", .subexp = 1 }, - { String, .pattern = "[LUu]?'([^']|\\\\')*'", }, - { String, .pattern = "([LUu]|u8)?\"([^\"]|\\\\\")*\"", }, - { Comment, .pattern = "//.*", }, + { String, .pattern = "[LUu]?'([^']|\\\\')*'" }, + { String, .pattern = "([LUu]|u8)?\"([^\"]|\\\\\")*\"" }, + { Escape, .parent = String, .pattern = "\\\\['\"?\\abfnrtv]" }, + { Escape, .parent = String, .pattern = "\\\\[0-7]{1,3}" }, + { Escape, .parent = String, .pattern = "\\\\x[0-9A-Fa-f]+" }, + { Escape, .parent = String, .pattern = "\\\\u[0-9A-Fa-f]{4}" }, + { Escape, .parent = String, .pattern = "\\\\U[0-9A-Fa-f]{8}" }, + { Comment, .pattern = "//.*" }, { Comment, .pattern = "/\\*", .pattend = "\\*/" }, { Comment, .pattern = "^#if 0", .pattend = "^#endif" }, - { Todo, .pattern = "FIXME|TODO|XXX", .parent = Comment }, + { Todo, .parent = Comment, .pattern = "FIXME|TODO|XXX" }, }; static const struct Language { @@ -132,6 +138,7 @@ static const enum SGR Style[ClassCount][2] = { [Keyword] = { Reset, White }, [Macro] = { Reset, Green }, [String] = { Reset, Cyan }, + [Escape] = { Reset, Default }, [Comment] = { Reset, Blue }, [Todo] = { Bold, Blue }, }; @@ -200,6 +207,7 @@ static void htmlDocumentHeader(const char *path) { ".hi.Keyword { color: dimgray; }\n" ".hi.Macro { color: green; }\n" ".hi.String { color: teal; }\n" + ".hi.Escape { color: black; }\n" ".hi.Comment { color: navy; }\n" ".hi.Todo { color: navy; font-weight: bold }\n" "</style>\n" |