This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
argfile_mode.js
55 lines (49 loc) · 1.74 KB
/
argfile_mode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// A quick hack to support argument files. Not complete,
// but it's better'n nuthin'
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50, regexp: true */
/*global define, brackets, $ */
define(function (require, exports, module) {
"use strict";
function argfileMode(config, parserConfig) {
// This defines a simple mode for robotframework
// argument files
var mode = {
startState: function () {
return {
is_namevalue: false
};
},
token: function (stream, state) {
if (stream.match(/^#.*$/)) {
state.is_namevalue = false;
return "comment";
}
if (stream.match(/^-v|M|--variable|--metadata(?==|\s+)/)) {
state.is_namevalue = true;
stream.eatSpace();
return "meta";
}
if (stream.match(/^-[a-zA-Z]|--\w+/)) {
state.is_namevalue = false;
stream.eatSpace();
return "meta";
}
if (state.is_namevalue && stream.match(/\w+(?=:)/)) {
return "variable";
}
if (state.is_namevalue && stream.match(/[:=]/)) {
return "operator";
}
if (state.is_namevalue) {
stream.skipToEnd();
state.is_namevalue = false;
return "string";
}
stream.skipToEnd();
return null;
}
};
return mode;
}
exports.argfileMode = argfileMode;
});