parent
9d634eee7b
commit
4012c32a55
4 changed files with 76 additions and 27 deletions
|
|
@ -82,9 +82,6 @@ var JavaScriptHighlightRules = function() {
|
|||
token : "comment", // multi line comment
|
||||
regex : "\\/\\*",
|
||||
next : "comment"
|
||||
}, {
|
||||
token : "string.regexp",
|
||||
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
|
||||
}, {
|
||||
token : "string", // single line
|
||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
||||
|
|
@ -126,13 +123,19 @@ var JavaScriptHighlightRules = function() {
|
|||
regex : identifierRe
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
|
||||
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)",
|
||||
next : "regex_allowed"
|
||||
}, {
|
||||
token : "lparen",
|
||||
regex : "[[({]"
|
||||
regex : "[[({]",
|
||||
next : "regex_allowed"
|
||||
}, {
|
||||
token : "rparen",
|
||||
regex : "[\\])}]"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "\\/=?",
|
||||
next : "regex_allowed"
|
||||
}, {
|
||||
token: "comment",
|
||||
regex: "^#!.*$"
|
||||
|
|
@ -141,6 +144,26 @@ var JavaScriptHighlightRules = function() {
|
|||
regex : "\\s+"
|
||||
}
|
||||
],
|
||||
// regular expressions are only allowed after certain tokens. This
|
||||
// makes sure we don't mix up regexps with the divison operator
|
||||
"regex_allowed": [
|
||||
{
|
||||
token: "string.regexp",
|
||||
regex: "\\/(?:(?:\\[(?:\\\\]|[^\\]])+\\])"
|
||||
+ "|(?:\\\\/|[^\\]/]))*"
|
||||
+ "[/]\\w*",
|
||||
next: "start"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}, {
|
||||
// immediately return to the start mode without mathcing
|
||||
// anything
|
||||
token: "empty",
|
||||
regex: "",
|
||||
next: "start"
|
||||
}
|
||||
],
|
||||
"comment" : [
|
||||
{
|
||||
token : "comment", // closing comment
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue