| 1 |
define(["../../_base"], function(dh){ |
| 2 |
|
| 3 |
var dhc = dh.constants; |
| 4 |
dh.languages.javascript = { |
| 5 |
defaultMode: { |
| 6 |
lexems: ["\\b[a-zA-Z]+"], |
| 7 |
keywords: { |
| 8 |
"keyword": { |
| 9 |
"for": 1, "in": 1, "while": 1, "do": 1, "break": 1, "return": 1, |
| 10 |
"continue": 1, "if": 1, "else": 1, "throw": 1, "try": 1, |
| 11 |
"catch": 1, "var": 1, "with": 1, "const": 1, "label": 1, |
| 12 |
"function": 1, "new": 1, "typeof": 1, "instanceof": 1 |
| 13 |
}, |
| 14 |
"keyword constant": { |
| 15 |
"true": 1, "false": 1, "null": 1, "NaN": 1, "Infinity": 1, "undefined": 1 |
| 16 |
}, |
| 17 |
"name builtin": { |
| 18 |
"Array": 1, "Boolean": 1, "Date": 1, "Error": 1, "Function": 1, "Math": 1, |
| 19 |
"netscape": 1, "Number": 1, "Object": 1, "Packages": 1, "RegExp": 1, |
| 20 |
"String": 1, "sun": 1, "decodeURI": 1, "decodeURIComponent": 1, |
| 21 |
"encodeURI": 1, "encodeURIComponent": 1, "eval": 1, |
| 22 |
"isFinite": 1, "isNaN": 1, "parseFloat": 1, "parseInt": 1, "document": 1, |
| 23 |
"window": 1 |
| 24 |
}, |
| 25 |
"name builtin pseudo": { |
| 26 |
"this": 1 |
| 27 |
} |
| 28 |
}, |
| 29 |
contains: [ |
| 30 |
"comment single", "comment multiline", |
| 31 |
"number integer", "number oct", "number hex", "number float", |
| 32 |
"string single", "string double", "string regex", |
| 33 |
"operator", |
| 34 |
"punctuation", |
| 35 |
|
| 36 |
"_function" |
| 37 |
] |
| 38 |
}, |
| 39 |
modes: [ |
| 40 |
|
| 41 |
{ |
| 42 |
className: "comment single", |
| 43 |
begin: "//", end: "$", |
| 44 |
relevance: 0 |
| 45 |
}, |
| 46 |
{ |
| 47 |
className: "comment multiline", |
| 48 |
begin: "/\\*", end: "\\*/" |
| 49 |
}, |
| 50 |
|
| 51 |
|
| 52 |
{ |
| 53 |
className: "number integer", |
| 54 |
begin: "0|([1-9][0-9]*)", end: "^", |
| 55 |
relevance: 0 |
| 56 |
}, |
| 57 |
{ |
| 58 |
className: "number oct", |
| 59 |
begin: "0[0-9]+", end: "^", |
| 60 |
relevance: 0 |
| 61 |
}, |
| 62 |
{ |
| 63 |
className: "number hex", |
| 64 |
begin: "0x[0-9a-fA-F]+", end: "^", |
| 65 |
relevance: 0 |
| 66 |
}, |
| 67 |
{ |
| 68 |
className: "number float", |
| 69 |
begin: "([1-9][0-9]*\\.[0-9]*([eE][\\+-]?[0-9]+)?)|(\\.[0-9]+([eE][\\+-]?[0-9]+)?)|([0-9]+[eE][\\+-]?[0-9]+)", end: "^", |
| 70 |
relevance: 0 |
| 71 |
}, |
| 72 |
|
| 73 |
|
| 74 |
{ |
| 75 |
className: "string single", |
| 76 |
begin: "'", end: "'", |
| 77 |
illegal: "\\n", |
| 78 |
contains: ["string escape"], |
| 79 |
relevance: 0 |
| 80 |
}, |
| 81 |
{ |
| 82 |
className: "string double", |
| 83 |
begin: '"', |
| 84 |
end: '"', |
| 85 |
illegal: "\\n", |
| 86 |
contains: ["string escape"], |
| 87 |
relevance: 0 |
| 88 |
}, |
| 89 |
{ |
| 90 |
className: "string escape", |
| 91 |
begin: "\\\\.", end: "^", |
| 92 |
relevance: 0 |
| 93 |
}, |
| 94 |
{ |
| 95 |
className: "string regex", |
| 96 |
begin: "/.*?[^\\\\/]/[gim]*", end: "^" |
| 97 |
}, |
| 98 |
|
| 99 |
|
| 100 |
{ |
| 101 |
className: "operator", |
| 102 |
begin: "\\|\\||&&|\\+\\+|--|-=|\\+=|/=|\\*=|==|[-\\+\\*/=\\?:~\\^]", end: "^", |
| 103 |
relevance: 0 |
| 104 |
}, |
| 105 |
|
| 106 |
|
| 107 |
{ |
| 108 |
className: "punctuation", |
| 109 |
begin: "[{}\\(\\)\\[\\]\\.;]", end: "^", |
| 110 |
relevance: 0 |
| 111 |
}, |
| 112 |
|
| 113 |
|
| 114 |
{ |
| 115 |
className: "_function", |
| 116 |
begin: "function\\b", end: "{", |
| 117 |
lexems: [dhc.UNDERSCORE_IDENT_RE], |
| 118 |
keywords: { |
| 119 |
keyword: { |
| 120 |
"function": 1 |
| 121 |
} |
| 122 |
}, |
| 123 |
contains: ["name function", "_params"], |
| 124 |
relevance: 5 |
| 125 |
}, |
| 126 |
{ |
| 127 |
className: "name function", |
| 128 |
begin: dhc.UNDERSCORE_IDENT_RE, end: '^' |
| 129 |
}, |
| 130 |
{ |
| 131 |
className: "_params", |
| 132 |
begin: "\\(", end: "\\)", |
| 133 |
contains: ["comment single", "comment multiline"] |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
] |
| 144 |
}; |
| 145 |
|
| 146 |
return dh.languages.javascript; |
| 147 |
}); |