5
if (typeof exports == "object" && typeof module == "object")
6
mod(require("../../lib/codemirror"));
7
else if (typeof define == "function" && define.amd)
8
define(["../../lib/codemirror"], mod);
11
})(function(CodeMirror) {
14
CodeMirror.defineMode("gas", function(_config, parserConfig) {
26
var lineCommentStartSymbol = "";
36
".altmacro" : "builtin",
39
".balign" : "builtin",
40
".balignw" : "builtin",
41
".balignl" : "builtin",
42
".bundle_align_mode" : "builtin",
43
".bundle_lock" : "builtin",
44
".bundle_unlock" : "builtin",
46
".cfi_startproc" : "builtin",
52
".double" : "builtin",
55
".elseif" : "builtin",
58
".endfunc" : "builtin",
66
".extern" : "builtin",
72
".global" : "builtin",
73
".gnu_attribute" : "builtin",
74
".hidden" : "builtin",
78
".incbin" : "builtin",
79
".include" : "builtin",
81
".internal" : "builtin",
85
".lflags" : "builtin",
87
".linkonce" : "builtin",
91
".loc_mark_labels" : "builtin",
96
".noaltmacro" : "builtin",
97
".nolist" : "builtin",
99
".offset" : "builtin",
101
".p2align" : "builtin",
102
".popsection" : "builtin",
103
".previous" : "builtin",
104
".print" : "builtin",
105
".protected" : "builtin",
106
".psize" : "builtin",
107
".purgem" : "builtin",
108
".pushsection" : "builtin",
110
".reloc" : "builtin",
112
".sbttl" : "builtin",
114
".section" : "builtin",
116
".short" : "builtin",
117
".single" : "builtin",
120
".sleb128" : "builtin",
121
".space" : "builtin",
123
".string" : "builtin",
124
".struct" : "builtin",
125
".subsection" : "builtin",
126
".symver" : "builtin",
129
".title" : "builtin",
131
".uleb128" : "builtin",
133
".version" : "builtin",
134
".vtable_entry" : "builtin",
135
".vtable_inherit" : "builtin",
136
".warning" : "builtin",
138
".weakref" : "builtin",
144
function x86(_parserConfig) {
145
lineCommentStartSymbol = "#";
147
registers.al = "variable";
148
registers.ah = "variable";
149
registers.ax = "variable";
150
registers.eax = "variable-2";
151
registers.rax = "variable-3";
153
registers.bl = "variable";
154
registers.bh = "variable";
155
registers.bx = "variable";
156
registers.ebx = "variable-2";
157
registers.rbx = "variable-3";
159
registers.cl = "variable";
160
registers.ch = "variable";
161
registers.cx = "variable";
162
registers.ecx = "variable-2";
163
registers.rcx = "variable-3";
165
registers.dl = "variable";
166
registers.dh = "variable";
167
registers.dx = "variable";
168
registers.edx = "variable-2";
169
registers.rdx = "variable-3";
171
registers.si = "variable";
172
registers.esi = "variable-2";
173
registers.rsi = "variable-3";
175
registers.di = "variable";
176
registers.edi = "variable-2";
177
registers.rdi = "variable-3";
179
registers.sp = "variable";
180
registers.esp = "variable-2";
181
registers.rsp = "variable-3";
183
registers.bp = "variable";
184
registers.ebp = "variable-2";
185
registers.rbp = "variable-3";
187
registers.ip = "variable";
188
registers.eip = "variable-2";
189
registers.rip = "variable-3";
191
registers.cs = "keyword";
192
registers.ds = "keyword";
193
registers.ss = "keyword";
194
registers.es = "keyword";
195
registers.fs = "keyword";
196
registers.gs = "keyword";
199
function armv6(_parserConfig) {
203
lineCommentStartSymbol = "@";
204
directives.syntax = "builtin";
206
registers.r0 = "variable";
207
registers.r1 = "variable";
208
registers.r2 = "variable";
209
registers.r3 = "variable";
210
registers.r4 = "variable";
211
registers.r5 = "variable";
212
registers.r6 = "variable";
213
registers.r7 = "variable";
214
registers.r8 = "variable";
215
registers.r9 = "variable";
216
registers.r10 = "variable";
217
registers.r11 = "variable";
218
registers.r12 = "variable";
220
registers.sp = "variable-2";
221
registers.lr = "variable-2";
222
registers.pc = "variable-2";
223
registers.r13 = registers.sp;
224
registers.r14 = registers.lr;
225
registers.r15 = registers.pc;
227
custom.push(function(ch, stream) {
229
stream.eatWhile(/\w/);
235
var arch = (parserConfig.architecture || "x86").toLowerCase();
236
if (arch === "x86") {
238
} else if (arch === "arm" || arch === "armv6") {
242
function nextUntilUnescaped(stream, end) {
243
var escaped = false, next;
244
while ((next = stream.next()) != null) {
245
if (next === end && !escaped) {
248
escaped = !escaped && next === "\\";
253
function clikeComment(stream, state) {
254
var maybeEnd = false, ch;
255
while ((ch = stream.next()) != null) {
256
if (ch === "/" && maybeEnd) {
257
state.tokenize = null;
260
maybeEnd = (ch === "*");
266
startState: function() {
272
token: function(stream, state) {
273
if (state.tokenize) {
274
return state.tokenize(stream, state);
277
if (stream.eatSpace()) {
281
var style, cur, ch = stream.next();
284
if (stream.eat("*")) {
285
state.tokenize = clikeComment;
286
return clikeComment(stream, state);
290
if (ch === lineCommentStartSymbol) {
296
nextUntilUnescaped(stream, '"');
301
stream.eatWhile(/\w/);
302
cur = stream.current().toLowerCase();
303
style = directives[cur];
304
return style || null;
308
stream.eatWhile(/\w/);
321
if (ch === "0" && stream.eat("x")) {
322
stream.eatWhile(/[0-9a-fA-F]/);
325
stream.eatWhile(/\d/);
330
stream.eatWhile(/\w/);
331
if (stream.eat(":")) {
334
cur = stream.current().toLowerCase();
335
style = registers[cur];
336
return style || null;
339
for (var i = 0; i < custom.length; i++) {
340
style = custom[i](ch, stream, state);
347
lineComment: lineCommentStartSymbol,
348
blockCommentStart: "/*",
349
blockCommentEnd: "*/"