diff options
author | Valerio Virgillito | 2012-02-15 16:09:47 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-15 16:09:47 -0800 |
commit | d366c0bd1af6471511217ed574083e15059519b5 (patch) | |
tree | c8c9f9af761457e3c5f4c6774fb0fbba851df0c4 /imports/codemirror/mode | |
parent | 997ce3fb65f27b3d6f331f63b5dc22d3c7fb8f1e (diff) | |
parent | b85bfb54aaca3ccca3c1ef09115de925cd67f4e9 (diff) | |
download | ninja-d366c0bd1af6471511217ed574083e15059519b5.tar.gz |
Merge branch 'refs/heads/integration'
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) { | ||
90 | var t = state.context.type; | ||