From 0c79b239b63d26a6dc15675746d9c8a4096e8701 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 25 Dec 2012 16:56:31 +0400 Subject: [PATCH] fix c and stylus highlighters --- build | 2 +- lib/ace/mode/_test/tokens_c_cpp.json | 158 +++++++++++++++++++++- lib/ace/mode/_test/tokens_objectivec.json | 12 +- lib/ace/mode/_test/tokens_stylus.json | 17 +-- lib/ace/mode/c_cpp_highlight_rules.js | 4 +- lib/ace/mode/stylus_highlight_rules.js | 19 ++- 6 files changed, 178 insertions(+), 34 deletions(-) diff --git a/build b/build index 9f433321..97bae1d1 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 9f433321a8cca9270753842c2517bd3588354dfe +Subproject commit 97bae1d132effbeca5eef8aaef2a2a1fa836b181 diff --git a/lib/ace/mode/_test/tokens_c_cpp.json b/lib/ace/mode/_test/tokens_c_cpp.json index 93b0d29b..c7612814 100644 --- a/lib/ace/mode/_test/tokens_c_cpp.json +++ b/lib/ace/mode/_test/tokens_c_cpp.json @@ -13,10 +13,94 @@ "state": "start", "data": [ [ "keyword", "#include" ], - [ "text", " " ], - [ "constant", "" ] + [ "constant.other", " " ] ] }, + { + "state": "start", + "data": [] + }, + { + "state": "directive", + "data": [ + [ "keyword", "#include" ], + [ "constant.other.multiline", " \\" ] + ] + }, + { + "state": "start", + "data": [ + [ "constant.other", " " ] + ] + }, + { + "state": "start", + "data": [] + }, + { + "state": "directive", + "data": [ + [ "keyword", "#include" ], + [ "constant.other.multiline", " \\" ] + ] + }, + { + "state": "directive", + "data": [ + [ "constant.other.multiline", " \\" ] + ] + }, + { + "state": "start", + "data": [ + [ "constant.other", " " ] + ] + }, + { + "state": "start", + "data": [] + }, + { + "state": "directive", + "data": [ + [ "keyword", "#include" ], + [ "constant.other.multiline", " \\" ] + ] + }, + { + "state": "directive", + "data": [ + [ "constant.other.multiline", " \\" ] + ] + }, + { + "state": "start", + "data": [ + [ "constant.other", " \"iostream\"" ] + ] + }, + { + "state": "start", + "data": [] + }, + { + "state": "start", + "data": [ + [ "keyword", "#include" ], + [ "constant.other", " " ] + ] + }, + { + "state": "start", + "data": [ + [ "keyword", "#include" ], + [ "constant.other", " \"boost/asio/io_service.hpp\"" ] + ] + }, + { + "state": "start", + "data": [] + }, { "state": "start", "data": [ @@ -105,6 +189,32 @@ [ "punctuation.operator", ";" ] ] }, + { + "state": "start", + "data": [ + [ "text", " " ], + [ "keyword", "#if" ], + [ "constant.other", " VERBOSE >= 2" ] + ] + }, + { + "state": "start", + "data": [ + [ "text", " " ], + [ "identifier", "prints" ], + [ "paren.lparen", "(" ], + [ "string", "\"trace message\"" ], + [ "paren.rparen", ")" ], + [ "punctuation.operator", ";" ] + ] + }, + { + "state": "start", + "data": [ + [ "text", " " ], + [ "keyword", "#endif" ] + ] + }, { "state": "start", "data": [ @@ -120,5 +230,49 @@ "data": [ [ "paren.rparen", "}" ] ] + }, + { + "state": "start", + "data": [] + }, + { + "state": "start", + "data": [ + [ "comment", "/*" ], + [ "comment", " Print an error message and get out */" ] + ] + }, + { + "state": "directive", + "data": [ + [ "keyword", "#define" ], + [ "constant.other.multiline", " ABORT \\" ] + ] + }, + { + "state": "directive", + "data": [ + [ "constant.other.multiline", " do { \\" ] + ] + }, + { + "state": "directive", + "data": [ + [ "constant.other.multiline", " print( \"Abort\\n\" ); \\" ] + ] + }, + { + "state": "directive", + "data": [ + [ "constant.other.multiline", " exit(8); \\" ] + ] + }, + { + "state": "start", + "data": [ + [ "constant.other", "} while (0) " ], + [ "comment", "/*" ], + [ "comment", " Note: No semicolon */" ] + ] } ] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_objectivec.json b/lib/ace/mode/_test/tokens_objectivec.json index 107cdf63..aafd5868 100644 --- a/lib/ace/mode/_test/tokens_objectivec.json +++ b/lib/ace/mode/_test/tokens_objectivec.json @@ -618,8 +618,7 @@ "state": "start", "data": [ [ "keyword", "#import" ], - [ "text", " " ], - [ "constant", "" ] + [ "constant.other", " " ] ] }, { @@ -991,19 +990,14 @@ "state": "start", "data": [ [ "keyword", "#ifndef" ], - [ "text", " " ], - [ "constant.language.objc", "Nil" ] + [ "constant.other", " Nil" ] ] }, { "state": "start", "data": [ [ "keyword", "#define" ], - [ "text", " " ], - [ "constant.language.objc", "Nil" ], - [ "text", " " ], - [ "identifier", "__DARWIN_NULL" ], - [ "text", " " ], + [ "constant.other", " Nil __DARWIN_NULL " ], [ "comment", "/*" ], [ "comment", " id of Nil class */" ] ] diff --git a/lib/ace/mode/_test/tokens_stylus.json b/lib/ace/mode/_test/tokens_stylus.json index d2816fad..d7d6cd94 100644 --- a/lib/ace/mode/_test/tokens_stylus.json +++ b/lib/ace/mode/_test/tokens_stylus.json @@ -207,8 +207,8 @@ [ "constant.numeric", "1" ], [ "keyword", "px" ], [ "text", " " ], - [ "keyword", "s" ], - [ "text", "olid grayLighter" ] + [ "support.constant", "solid" ], + [ "text", " grayLighter" ] ] }, { @@ -295,8 +295,7 @@ [ "text", " " ], [ "support.type", "display" ], [ "text", ": " ], - [ "keyword", "in" ], - [ "support.constant", "line" ] + [ "support.constant", "inline" ] ] }, { @@ -323,8 +322,7 @@ [ "text", " " ], [ "support.type", "display" ], [ "text", " " ], - [ "keyword", "in" ], - [ "support.constant", "line" ] + [ "support.constant", "inline" ] ] }, { @@ -356,8 +354,7 @@ [ "text", " " ], [ "support.type", "display" ], [ "text", " " ], - [ "keyword", "in" ], - [ "support.constant", "line" ] + [ "support.constant", "inline" ] ] }, { @@ -410,7 +407,7 @@ { "state": "start", "data": [ - [ "text", " " ], + [ "text", " " ], [ "keyword.control.stylus", "!important" ] ] }, @@ -421,7 +418,7 @@ { "state": "start", "data": [ - [ "text", " " ], + [ "text", " " ], [ "keyword.control.stylus", "unless" ] ] } diff --git a/lib/ace/mode/c_cpp_highlight_rules.js b/lib/ace/mode/c_cpp_highlight_rules.js index 5be688f5..2eda251b 100644 --- a/lib/ace/mode/c_cpp_highlight_rules.js +++ b/lib/ace/mode/c_cpp_highlight_rules.js @@ -85,11 +85,11 @@ var c_cppHighlightRules = function() { regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" }, { token : "keyword", // pre-compiler directives - regex : "(?:#include|#import|#pragma|#line|#define|#undef|#if|#ifdef|#else|#elif|#ifndef)", + regex : "(?:#include|#import|#pragma|#line|#define|#undef|#if|#ifdef|#else|#elif|#ifndef)\\b", next : "directive" }, { token : "keyword", // special case pre-compiler directive - regex : "(?:#endif)" + regex : "(?:#endif)\\b" }, { token : "support.function.C99.c", regex : cFunctions diff --git a/lib/ace/mode/stylus_highlight_rules.js b/lib/ace/mode/stylus_highlight_rules.js index 6c012df5..affa06ca 100644 --- a/lib/ace/mode/stylus_highlight_rules.js +++ b/lib/ace/mode/stylus_highlight_rules.js @@ -21,8 +21,7 @@ var StylusHighlightRules = function() { "support.constant.fonts": CssHighlightRules.supportConstantFonts }, "text", true); - this.$rules = - { + this.$rules = { "start": [ { token : "comment", @@ -82,16 +81,16 @@ var StylusHighlightRules = function() { "regex": "-webkit-|-moz\\-|-ms-|-o-" }, { - "token": ["keyword.control.stylus"], - "regex": "(?:\\b|\\s)(!important|for|in|return|true|false|null|if|else|unless|return)(?:\\b)" + "token": "keyword.control.stylus", + "regex": "(?:!important|for|in|return|true|false|null|if|else|unless|return)\\b" }, { - "token": ["keyword.operator.stylus"], - "regex": "((?:!|~|\\+|-|(?:\\*)?\\*|\\/|%|(?:\\.)\\.\\.|<|>|(?:=|:|\\?|\\+|-|\\*|\\/|%|<|>)?=|!=))" + "token": "keyword.operator.stylus", + "regex": "!|~|\\+|-|(?:\\*)?\\*|\\/|%|(?:\\.)\\.\\.|<|>|(?:=|:|\\?|\\+|-|\\*|\\/|%|<|>)?=|!=" }, { - "token": ["keyword.operator.stylus"], - "regex": "(?:\\b)(in|is(?:nt)?|not)(?:\\b)" + "token": "keyword.operator.stylus", + "regex": "(?:in|is(?:nt)?|not)\\b" }, { token : "string", @@ -107,8 +106,8 @@ var StylusHighlightRules = function() { regex : CssHighlightRules.numRe }, { - token : ["keyword"], - regex : "(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)" + token : "keyword", + regex : "(?:ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)\\b" }, { token : keywordMapper,