Skip to content

Commit b7af7d9

Browse files
committed
update language syntax specs
1 parent a6a7b95 commit b7af7d9

7 files changed

Lines changed: 257 additions & 140 deletions

File tree

language/hlb-ace.js

Lines changed: 137 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -3,121 +3,141 @@
33
* here : http://ace.c9.io/tool/mode_creator.html
44
*/
55

6-
define(function(require, exports, module) {
7-
"use strict";
8-
var oop = require("../lib/oop");
9-
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
10-
/* --------------------- START ----------------------------- */
11-
var HlbHighlightRules = function() {
12-
this.$rules = {
13-
"start" : [
14-
{
15-
"token" : "comment",
16-
"regex" : "(#.*)"
17-
},
18-
{
19-
"token" : "constant",
20-
"regex" : "((\\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\\b)|(\\b(0|[1-9][0-9]*)\\b)|(\\b(true|false)\\b))"
21-
},
22-
{
23-
"token" : "punctuation",
24-
"regex" : "(\")",
25-
"push" : "common__1"
26-
},
27-
{
28-
"token" : "entity.name.type",
29-
"regex" : "(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\boption\\b)"
30-
},
31-
{
32-
"token" : ["keyword", "punctuation"],
33-
"regex" : "(\\b[a-zA-Z_][a-zA-Z0-9]*\\b)(\\()",
34-
"push" : "params"
35-
},
36-
{
37-
"token" : "invalid",
38-
"regex" : "(\\))"
39-
},
40-
{
41-
"token" : "punctuation",
42-
"regex" : "(\\{)",
43-
"push" : "block"
44-
},
45-
{
46-
"token" : "invalid",
47-
"regex" : "(\\})"
48-
},
49-
{
50-
defaultToken : "text",
51-
}
52-
],
53-
"block" : [
54-
{
55-
"token" : "punctuation",
56-
"regex" : "(\\})",
57-
"next" : "pop"
58-
},
59-
{
60-
"token" : "comment",
61-
"regex" : "(#.*)"
62-
},
63-
{
64-
"token" : "constant",
65-
"regex" : "((\\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\\b)|(\\b(0|[1-9][0-9]*)\\b)|(\\b(true|false)\\b))"
66-
},
67-
{
68-
"token" : "punctuation",
69-
"regex" : "(\")",
70-
"push" : "common__1"
71-
},
72-
{
73-
"token" : "variable.language",
74-
"regex" : "(\\b(with|as|variadic)\\b)"
75-
},
76-
{
77-
"token" : ["entity.name.type", "text", "punctuation"],
78-
"regex" : "(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\boption\\b)([\\t ]+)(\\{)",
79-
"push" : "block"
80-
},
81-
{
82-
"token" : "variable",
83-
"regex" : "(\\b((?!(scratch|image|resolve|http|checksum|chmod|filename|git|keepGitDir|local|includePatterns|excludePatterns|followPaths|generate|frontendInput|shell|run|readonlyRootfs|env|dir|user|network|security|host|ssh|secret|mount|target|localPath|uid|gid|mode|readonly|tmpfs|sourcePath|cache|mkdir|createParents|chown|createdTime|mkfile|rm|allowNotFound|allowWildcards|copy|followSymlinks|contentsOnly|unpack|createDestPath)\\b)[a-zA-Z_][a-zA-Z0-9]*\\b))"
84-
},
85-
{
86-
defaultToken : "text",
87-
}
88-
],
89-
"common__1" : [
90-
{
91-
"token" : "punctuation",
92-
"regex" : "(\")",
93-
"next" : "pop"
94-
},
95-
{
96-
defaultToken : "string",
97-
}
98-
],
99-
"params" : [
100-
{
101-
"token" : "punctuation",
102-
"regex" : "(\\))",
103-
"next" : "pop"
104-
},
105-
{
106-
"token" : "entity.name.type",
107-
"regex" : "(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\boption\\b)"
108-
},
109-
{
110-
"token" : "variable",
111-
"regex" : "(\\b[a-zA-Z_][a-zA-Z0-9]*\\b)"
112-
},
113-
{
114-
defaultToken : "text",
115-
}
116-
]
117-
};
118-
this.normalizeRules();
119-
};
120-
/* ------------------------ END ------------------------------ */
121-
oop.inherits(HlbHighlightRules, TextHighlightRules);
122-
exports.HlbHighlightRules = HlbHighlightRules;
6+
define(function (require, exports, module) {
7+
"use strict";
8+
var oop = require("../lib/oop");
9+
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
10+
/* --------------------- START ----------------------------- */
11+
var HlbHighlightRules = function () {
12+
this.$rules = {
13+
"start": [
14+
{
15+
"token": "comment",
16+
"regex": "(#.*)"
17+
},
18+
{
19+
"token": "constant",
20+
"regex": "((\\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\\b)|(\\b(0|[1-9][0-9]*)\\b)|(\\b(true|false)\\b))"
21+
},
22+
{
23+
"token": "punctuation",
24+
"regex": "(\")",
25+
"push": "common__1"
26+
},
27+
{
28+
"token": ["punctuation", "constant"],
29+
"regex": "(<<[-~]?)([A-Z]+)",
30+
"push": "common__2"
31+
},
32+
{
33+
"token": "entity.name.type",
34+
"regex": "(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\bgroup\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)"
35+
},
36+
{
37+
"token": ["keyword", "punctuation"],
38+
"regex": "(\\b[a-zA-Z_][a-zA-Z0-9]*\\b)(\\()",
39+
"push": "params"
40+
},
41+
{
42+
"token": "invalid",
43+
"regex": "(\\))"
44+
},
45+
{
46+
"token": "punctuation",
47+
"regex": "(\\{)",
48+
"push": "block"
49+
},
50+
{
51+
"token": "invalid",
52+
"regex": "(\\})"
53+
},
54+
{
55+
defaultToken: "text",
56+
}
57+
],
58+
"block": [
59+
{
60+
"token": "punctuation",
61+
"regex": "(\\})",
62+
"next": "pop"
63+
},
64+
{
65+
"token": "comment",
66+
"regex": "(#.*)"
67+
},
68+
{
69+
"token": "constant",
70+
"regex": "((\\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\\b)|(\\b(0|[1-9][0-9]*)\\b)|(\\b(true|false)\\b))"
71+
},
72+
{
73+
"token": "punctuation",
74+
"regex": "(\")",
75+
"push": "common__1"
76+
},
77+
{
78+
"token": ["punctuation", "constant"],
79+
"regex": "(<<[-~]?)([A-Z]+)",
80+
"push": "common__2"
81+
},
82+
{
83+
"token": "variable.language",
84+
"regex": "(\\b(with|as|variadic)\\b)"
85+
},
86+
{
87+
"token": ["entity.name.type", "punctuation"],
88+
"regex": "(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\bgroup\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)(?:[\\t ]+)(\\{)",
89+
"push": "block"
90+
},
91+
{
92+
"token": "variable",
93+
"regex": "(\\b((?!(allowEmptyWildcard|allowNotFound|allowWildcard|cache|checksum|chmod|chown|contentsOnly|copy|createDestPath|createParents|createdTime|dir|dockerLoad|dockerPush|download|downloadDockerTarball|downloadOCITarball|downloadTarball|env|excludePatterns|filename|followPaths|followSymlinks|format|forward|frontend|gid|git|host|http|id|ignoreCache|image|includePatterns|input|insecure|keepGitDir|local|localEnv|localPaths|locked|mkdir|mkfile|mode|mount|network|node|opt|parallel|private|readonly|readonlyRootfs|resolve|rm|run|sandbox|scratch|secret|security|shared|sourcePath|ssh|target|tmpfs|uid|unix|unpack|unset|user|value)\\b)[a-zA-Z_][a-zA-Z0-9]*\\b))"
94+
},
95+
{
96+
defaultToken: "text",
97+
}
98+
],
99+
"common__1": [
100+
{
101+
"token": "punctuation",
102+
"regex": "(\")",
103+
"next": "pop"
104+
},
105+
{
106+
defaultToken: "string",
107+
}
108+
],
109+
"common__2": [
110+
{
111+
"token": "constant",
112+
"regex": "(\\2)",
113+
"next": "pop"
114+
},
115+
{
116+
defaultToken: "string",
117+
}
118+
],
119+
"params": [
120+
{
121+
"token": "punctuation",
122+
"regex": "(\\))",
123+
"next": "pop"
124+
},
125+
{
126+
"token": "entity.name.type",
127+
"regex": "(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\bgroup\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)"
128+
},
129+
{
130+
"token": "variable",
131+
"regex": "(\\b[a-zA-Z_][a-zA-Z0-9]*\\b)"
132+
},
133+
{
134+
defaultToken: "text",
135+
}
136+
]
137+
};
138+
this.normalizeRules();
139+
};
140+
/* ------------------------ END ------------------------------ */
141+
oop.inherits(HlbHighlightRules, TextHighlightRules);
142+
exports.HlbHighlightRules = HlbHighlightRules;
123143
});

language/hlb-atom.coffee

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
'include' : '#common'
1717
}
1818
{
19-
'match' : '(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)'
19+
'match' : '(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\bgroup\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)'
2020
'name' : 'entity.name.type.hlb'
2121
}
2222
{
@@ -80,7 +80,7 @@
8080
'name' : 'variable.language.hlb'
8181
}
8282
{
83-
'begin' : '(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)(?:[\\t\\x{0020}]+)(\\{)'
83+
'begin' : '(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\bgroup\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)(?:[\\t\\x{0020}]+)(\\{)'
8484
'beginCaptures' : {
8585
'1' : {
8686
'name' : 'entity.name.type.hlb'
@@ -102,7 +102,7 @@
102102
}
103103
}
104104
{
105-
'match' : '(\\b((?!(allowEmptyWildcard|allowNotFound|allowWildcard|cache|checksum|chmod|chown|contentsOnly|copy|createDestPath|createParents|createdTime|dir|dockerLoad|dockerPush|download|downloadDockerTarball|downloadOCITarball|downloadTarball|env|excludePatterns|filename|followPaths|followSymlinks|format|forward|frontend|gid|git|host|http|id|ignoreCache|image|includePatterns|input|insecure|keepGitDir|local|localPaths|locked|mkdir|mkfile|mode|mount|network|node|opt|private|readonly|readonlyRootfs|resolve|rm|run|sandbox|scratch|secret|security|shared|sourcePath|ssh|target|tmpfs|uid|unix|unpack|unset|user|value)\\b)[a-zA-Z_][a-zA-Z0-9]*\\b))'
105+
'match' : '(\\b((?!(allowEmptyWildcard|allowNotFound|allowWildcard|cache|checksum|chmod|chown|contentsOnly|copy|createDestPath|createParents|createdTime|dir|dockerLoad|dockerPush|download|downloadDockerTarball|downloadOCITarball|downloadTarball|env|excludePatterns|filename|followPaths|followSymlinks|format|forward|frontend|gid|git|host|http|id|ignoreCache|image|includePatterns|input|insecure|keepGitDir|local|localEnv|localPaths|locked|mkdir|mkfile|mode|mount|network|node|opt|parallel|private|readonly|readonlyRootfs|resolve|rm|run|sandbox|scratch|secret|security|shared|sourcePath|ssh|target|tmpfs|uid|unix|unpack|unset|user|value)\\b)[a-zA-Z_][a-zA-Z0-9]*\\b))'
106106
'name' : 'variable.hlb'
107107
}
108108
]
@@ -132,16 +132,38 @@
132132
}
133133
}
134134
}
135+
{
136+
'begin' : '(<<[-\\x{007e}]?)([A-Z]+)'
137+
'beginCaptures' : {
138+
'1' : {
139+
'name' : 'punctuation.hlb'
140+
}
141+
'2' : {
142+
'name' : 'constant.hlb'
143+
}
144+
}
145+
'contentName' : 'string.hlb'
146+
'end' : '(\\2)'
147+
'endCaptures' : {
148+
'1' : {
149+
'name' : 'constant.hlb'
150+
}
151+
}
152+
}
135153
]
136154
}
137155
'common__1' : {
138156
'patterns' : [
139157
]
140158
}
159+
'common__2' : {
160+
'patterns' : [
161+
]
162+
}
141163
'params' : {
142164
'patterns' : [
143165
{
144-
'match' : '(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)'
166+
'match' : '(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\bgroup\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)'
145167
'name' : 'entity.name.type.hlb'
146168
}
147169
{

language/hlb-pygments.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class HlbLexer(RegexLexer):
1616
(u'(#.*)', bygroups(Comment.Single)),
1717
(u'((\\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\\b)|(\\b(0|[1-9][0-9]*)\\b)|(\\b(true|false)\\b))', bygroups(Name.Constant)),
1818
(u'(\")', bygroups(Punctuation), 'common__1'),
19-
(u'(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)', bygroups(Keyword.Type)),
19+
(u'(<<[-~]?)([A-Z]+)', bygroups(Punctuation, Name.Constant), 'common__2'),
20+
(u'(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\bgroup\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)', bygroups(Keyword.Type)),
2021
(u'(\\b[a-zA-Z_][a-zA-Z0-9]*\\b)(\\()', bygroups(Keyword, Punctuation), 'params'),
2122
(u'(\\))', bygroups(Generic.Error)),
2223
(u'(\\{)', bygroups(Punctuation), 'block'),
@@ -28,18 +29,23 @@ class HlbLexer(RegexLexer):
2829
(u'(#.*)', bygroups(Comment.Single)),
2930
(u'((\\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\\b)|(\\b(0|[1-9][0-9]*)\\b)|(\\b(true|false)\\b))', bygroups(Name.Constant)),
3031
(u'(\")', bygroups(Punctuation), 'common__1'),
32+
(u'(<<[-~]?)([A-Z]+)', bygroups(Punctuation, Name.Constant), 'common__2'),
3133
(u'(\\b(with|as|variadic)\\b)', bygroups(Name.Builtin)),
32-
(u'(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)(?:[\\t ]+)(\\{)', bygroups(Keyword.Type, Punctuation), 'block'),
33-
(u'(\\b((?!(allowEmptyWildcard|allowNotFound|allowWildcard|cache|checksum|chmod|chown|contentsOnly|copy|createDestPath|createParents|createdTime|dir|dockerLoad|dockerPush|download|downloadDockerTarball|downloadOCITarball|downloadTarball|env|excludePatterns|filename|followPaths|followSymlinks|format|forward|frontend|gid|git|host|http|id|ignoreCache|image|includePatterns|input|insecure|keepGitDir|local|localPaths|locked|mkdir|mkfile|mode|mount|network|node|opt|private|readonly|readonlyRootfs|resolve|rm|run|sandbox|scratch|secret|security|shared|sourcePath|ssh|target|tmpfs|uid|unix|unpack|unset|user|value)\\b)[a-zA-Z_][a-zA-Z0-9]*\\b))', bygroups(Name.Variable)),
34+
(u'(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\bgroup\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)(?:[\\t ]+)(\\{)', bygroups(Keyword.Type, Punctuation), 'block'),
35+
(u'(\\b((?!(allowEmptyWildcard|allowNotFound|allowWildcard|cache|checksum|chmod|chown|contentsOnly|copy|createDestPath|createParents|createdTime|dir|dockerLoad|dockerPush|download|downloadDockerTarball|downloadOCITarball|downloadTarball|env|excludePatterns|filename|followPaths|followSymlinks|format|forward|frontend|gid|git|host|http|id|ignoreCache|image|includePatterns|input|insecure|keepGitDir|local|localEnv|localPaths|locked|mkdir|mkfile|mode|mount|network|node|opt|parallel|private|readonly|readonlyRootfs|resolve|rm|run|sandbox|scratch|secret|security|shared|sourcePath|ssh|target|tmpfs|uid|unix|unpack|unset|user|value)\\b)[a-zA-Z_][a-zA-Z0-9]*\\b))', bygroups(Name.Variable)),
3436
('(\n|\r|\r\n)', String),
3537
('.', String),
3638
],
3739
'common__1' : [
3840
('(\n|\r|\r\n)', String),
3941
('.', String),
4042
],
43+
'common__2' : [
44+
('(\n|\r|\r\n)', String),
45+
('.', String),
46+
],
4147
'params' : [
42-
(u'(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)', bygroups(Keyword.Type)),
48+
(u'(\\bstring\\b|\\bint\\b|\\bbool\\b|\\bfs\\b|\\bgroup\\b|\\boption(?!::)\\b|\\boption::(?:copy|frontend|git|http|image|local|mkdir|mkfile|mount|rm|run|secret|ssh)\\b)', bygroups(Keyword.Type)),
4349
(u'(\\b[a-zA-Z_][a-zA-Z0-9]*\\b)', bygroups(Name.Variable)),
4450
('(\n|\r|\r\n)', String),
4551
('.', String),

0 commit comments

Comments
 (0)