From 85d172efa49fe98c322d7e2a715c0d33bbe86fbc Mon Sep 17 00:00:00 2001 From: Liu Hao Date: Thu, 7 Dec 2017 17:13:25 +0800 Subject: [PATCH 2/9] syntax/c.nanorc: Highlighting of preprocessor directives are moved after everything but comments, so an entire directive is always colored, as preprocessor directives do not follow the other syntactical rules. Signed-off-by: Liu Hao --- syntax/c.nanorc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/syntax/c.nanorc b/syntax/c.nanorc index c6de55c6..bbe06876 100644 --- a/syntax/c.nanorc +++ b/syntax/c.nanorc @@ -15,7 +15,6 @@ color green "\<(class|namespace|template|public|protected|private|typename|this| color brightyellow "\<(for|if|while|do|else|case|default|switch)\>" color brightyellow "\<(try|throw|catch|operator|new|delete|(static|dynamic|const|reinterpret)_cast|static_assert|_Static_assert)\>" color magenta "\<(goto|continue|break|return)\>" -color brightcyan "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)" color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'" color brightgreen "\<(_Pragma|__has_include|_Generic)\>" @@ -29,6 +28,10 @@ color brightyellow ""([^"]|\\")*"" "<[^[:blank:]=]*>" # and sometimes colours things that shouldn't be coloured. ###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*"" +# Preprocessor directives. +color brightcyan "^[[:space:]]*#[[:space:]]*((define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)([[:space:]]+(.*[^\\])?)?)?$" +color brightcyan start="^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)([[:space:]]+.*)?\\$" end="^(.*[^\\])?$" + # Comments. color brightblue "//.*" color brightblue start="/\*" end="\*/" -- 2.15.0