summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-02-07 03:33:56 -0500
committerJune McEnroe <june@causal.agency>2019-02-07 03:33:56 -0500
commit236b75da9993417c3d86a10ab47497c484c29b13 (patch)
tree0423aedc08983015062cb6d92493d2c6a9ec611e
parentAdd Todo class and parent syntax constraint (diff)
downloadsrc-236b75da9993417c3d86a10ab47497c484c29b13.tar.gz
src-236b75da9993417c3d86a10ab47497c484c29b13.zip
Add Escape class to hi
-rw-r--r--bin/hi.c16
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"
03Release 0.5.10.Herbert Xu 2018-04-19eval: Variable assignments on functions are no longer persistentHerbert Xu 2018-04-19parser: Fix parameter expansion inside inner double quotesHerbert Xu 2018-04-19parser: Fix parsing of ${}Herbert Xu 2018-04-19man: correct typos, iff -> ifMartijn Dekker 2018-04-19expand: Do not quote backslashes in unquoted parameter expansionHerbert Xu 2018-04-19shell: Add subdir-objects to AM_INIT_AUTOMAKEJason Bowen 2018-04-19eval: Restore input files in evalcommandHerbert Xu 2018-04-19eval: Reap zombies after built-in commands and functionsHerbert Xu 2018-04-19redir: Fix typo in noclobber codeHerbert Xu 2018-04-19expand: Fix glibc glob(3) supportHerbert Xu 2018-04-02expand: Fix buffer overflow in expandmetaHerbert Xu 2018-04-02builtin: Move echo space/nl handling into print_escape_strHerbert Xu 2018-04-02builtin: Fix echo performance regressionHerbert Xu 2018-04-02expand: Fix ghost fields with unquoted $@/$*Herbert Xu 2018-04-02parser: Allow newlines within parameter substitutionHerbert Xu 2018-04-02expand: Fix bugs with words connected to the right of $@Herbert Xu 2018-03-25Revert "[BUILTIN] Remove unnecessary restoration of format string in printf"Herbert Xu 2018-03-22parser: Fix backquote support in here-document EOF markHerbert Xu