diff options
author | Nivesh Rajbhandari | 2012-02-20 11:14:44 -0800 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-02-20 11:14:44 -0800 |
commit | abf78e2d7a97d295ce5a1c425fd359d47379137e (patch) | |
tree | d08c91bd2aef31e6325e0b499b2ffc390018bec6 /imports/codemirror/mode | |
parent | e80a79bff57fecf3aa9b869d8ed2de5fd815287c (diff) | |
parent | e23708721a71ca4c71365f5f8e8ac7d6113926db (diff) | |
download | ninja-abf78e2d7a97d295ce5a1c425fd359d47379137e.tar.gz |
Merge branch 'refs/heads/ninja-internal' into ToolFixes
Diffstat (limited to 'imports/codemirror/mode')
79 files changed, 11414 insertions, 0 deletions
diff --git a/imports/codemirror/mode/clike/clike.js b/imports/codemirror/mode/clike/clike.js new file mode 100755 index 00000000..69877efd --- /dev/null +++ b/imports/codemirror/mode/clike/clike.js | |||
@@ -0,0 +1,249 @@ | |||
1 | CodeMirror.defineMode("clike", function(config, parserConfig) { | ||
2 | var indentUnit = config.indentUnit, | ||
3 | keywords = parserConfig.keywords || {}, | ||
4 | blockKeywords = parserConfig.blockKeywords || {}, | ||
5 | atoms = parserConfig.atoms || {}, | ||
6 | hooks = parserConfig.hooks || {}, | ||
7 | multiLineStrings = parserConfig.multiLineStrings; | ||
8 | var isOperatorChar = /[+\-*&%=<>!?|\/]/; | ||
9 | |||
10 | var curPunc; | ||
11 | |||
12 | function tokenBase(stream, state) { | ||
13 | var ch = stream.next(); | ||
14 | if (hooks[ch]) { | ||
15 | var result = hooks[ch](stream, state); | ||
16 | if (result !== false) return result; | ||
17 | } | ||
18 | if (ch == '"' || ch == "'") { | ||
19 | state.tokenize = tokenString(ch); | ||
20 | return state.tokenize(stream, state); | ||
21 | } | ||
22 | if (/[\[\]{}\(\),;\:\.]/.test(ch)) { | ||
23 | curPunc = ch; | ||
24 | return null | ||
25 | } | ||
26 | if (/\d/.test(ch)) { | ||
27 | stream.eatWhile(/[\w\.]/); | ||
28 | return "number"; | ||
29 | } | ||
30 | if (ch == "/") { | ||
31 | if (stream.eat("*")) { | ||
32 | state.tokenize = tokenComment; | ||
33 | return tokenComment(stream, state); | ||
34 | } | ||
35 | if (stream.eat("/")) { | ||
36 | stream.skipToEnd(); | ||
37 | return "comment"; | ||
38 | } | ||
39 | } | ||
40 | if (isOperatorChar.test(ch)) { | ||
41 | stream.eatWhile(isOperatorChar); | ||
42 | return "operator"; | ||
43 | } | ||
44 | stream.eatWhile(/[\w\$_]/); | ||
45 | var cur = stream.current(); | ||
46 | if (keywords.propertyIsEnumerable(cur)) { | ||
47 | if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement"; | ||
48 | return "keyword"; | ||
49 | } | ||
50 | if (atoms.propertyIsEnumerable(cur)) return "atom"; | ||
51 | return "word"; | ||
52 | } | ||
53 | |||
54 | function tokenString(quote) { | ||
55 | return function(stream, state) { | ||
56 | var escaped = false, next, end = false; | ||
57 | while ((next = stream.next()) != null) { | ||
58 | if (next == quote && !escaped) {end = true; break;} | ||
59 | escaped = !escaped && next == "\\"; | ||
60 | } | ||
61 | if (end || !(escaped || multiLineStrings)) | ||
62 | state.tokenize = tokenBase; | ||
63 | return "string"; | ||
64 | }; | ||
65 | } | ||
66 | |||
67 | function tokenComment(stream, state) { | ||
68 | var maybeEnd = false, ch; | ||
69 | while (ch = stream.next()) { | ||
70 | if (ch == "/" && maybeEnd) { | ||
71 | state.tokenize = tokenBase; | ||
72 | break; | ||
73 | } | ||
74 | maybeEnd = (ch == "*"); | ||
75 | } | ||
76 | return "comment"; | ||
77 | } | ||
78 | |||
79 | function Context(indented, column, type, align, prev) { | ||
80 | this.indented = indented; | ||
81 | this.column = column; | ||
82 | this.type = type; | ||
83 | this.align = align; | ||
84 | this.prev = prev; | ||
85 | } | ||
86 | function pushContext(state, col, type) { | ||
87 | return state.context = new Context(state.indented, col, type, null, state.context); | ||
88 | } | ||
89 | function popContext(state) { | ||