Skip to content

Commit 94d1392

Browse files
committed
Update Fluent language specification
1 parent e4493f1 commit 94d1392

File tree

2 files changed

+192
-22
lines changed

2 files changed

+192
-22
lines changed

language-configuration.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"comments": {
33
// symbol used for single line comment. Remove this entry if your language does not support line comments
4-
"lineComment": "//",
5-
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
6-
"blockComment": [ "/*", "*/" ]
4+
"lineComment": "#",
75
},
86
// symbols used as brackets
97
"brackets": [
@@ -16,15 +14,13 @@
1614
["{", "}"],
1715
["[", "]"],
1816
["(", ")"],
19-
["\"", "\""],
2017
["'", "'"]
2118
],
2219
// symbols that can be used to surround a selection
2320
"surroundingPairs": [
2421
["{", "}"],
2522
["[", "]"],
2623
["(", ")"],
27-
["\"", "\""],
2824
["'", "'"]
2925
]
3026
}

syntaxes/ftl.tmLanguage.json

Lines changed: 191 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,206 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3-
"name": "Fluent",
3+
"name": "ftl",
4+
"scopeName": "source.ftl",
45
"patterns": [
56
{
6-
"include": "#keywords"
7+
"include": "#comment"
78
},
89
{
9-
"include": "#strings"
10+
"include": "#message"
11+
},
12+
{
13+
"include": "#wrong-line"
1014
}
1115
],
1216
"repository": {
13-
"keywords": {
14-
"patterns": [{
15-
"name": "keyword.control.ftl",
16-
"match": "\\b(if|while|for|return)\\b"
17-
}]
18-
},
19-
"strings": {
20-
"name": "string.quoted.double.ftl",
21-
"begin": "\"",
22-
"end": "\"",
17+
"comment": {
18+
"name": "comment.fluent",
19+
"match": "^##?#?\\s.*$"
20+
},
21+
"message": {
22+
"begin": "^(-?[a-zA-Z][a-zA-Z0-9_-]*\\s*=\\s*)",
23+
"end": "^(?=\\S)",
24+
"beginCaptures": {
25+
"1": {
26+
"name": "support.class.message-identifier.fluent"
27+
}
28+
},
29+
"contentName": "string.fluent",
30+
"patterns": [
31+
{
32+
"include": "#attributes"
33+
},
34+
{
35+
"include": "#placeable"
36+
}
37+
]
38+
},
39+
"attributes": {
40+
"begin": "\\s*(\\.[a-zA-Z][a-zA-Z0-9_-]*\\s*=\\s*)",
41+
"end": "^(?=\\s*[^\\.])",
42+
"beginCaptures": {
43+
"1": {
44+
"name": "support.class.attribute-begin.fluent"
45+
}
46+
},
47+
"patterns": [
48+
{
49+
"include": "#placeable"
50+
}
51+
]
52+
},
53+
"placeable": {
54+
"begin": "({)",
55+
"end": "(})",
56+
"beginCaptures": {
57+
"1": {
58+
"name": "keyword.placeable.begin.fluent"
59+
}
60+
},
61+
"endCaptures": {
62+
"1": {
63+
"name": "keyword.placeable.end.fluent"
64+
}
65+
},
66+
"contentName": "variable.other.placeable.content.fluent",
2367
"patterns": [
2468
{
25-
"name": "constant.character.escape.ftl",
26-
"match": "\\\\."
69+
"include": "#placeable-string"
70+
},
71+
{
72+
"include": "#placeable-function"
73+
},
74+
{
75+
"include": "#placeable-reference-or-number"
76+
},
77+
{
78+
"include": "#selector"
79+
},
80+
{
81+
"include": "#invalid-placeable-wrong-placeable-missing-end"
82+
},
83+
{
84+
"include": "#invalid-placeable-string-missing-end-quote"
85+
},
86+
{
87+
"include": "#invalid-placeable-wrong-function-name"
2788
}
2889
]
90+
},
91+
"placeable-reference-or-number": {
92+
"name": "variable.other.placeable.reference-or-number.fluent",
93+
"match": "((-|\\$)[a-zA-Z0-9_-]+|[a-zA-Z][a-zA-Z0-9_-]*|[0-9]+)"
94+
},
95+
"placeable-function": {
96+
"begin": "([A-Z][A-Z0-9_-]*\\()",
97+
"end": "(\\))",
98+
"beginCaptures": {
99+
"1": {
100+
"name": "support.function.placeable-function.call.begin.fluent"
101+
}
102+
},
103+
"endCaptures": {
104+
"1": {
105+
"name": "support.function.placeable-function.call.end.fluent"
106+
}
107+
},
108+
"contentName": "string.placeable-function.fluent",
109+
"patterns": [
110+
{
111+
"include": "#function-comma"
112+
},
113+
{
114+
"include": "#function-positional-argument"
115+
},
116+
{
117+
"include": "#function-named-argument"
118+
}
119+
]
120+
},
121+
"function-comma": {
122+
"name": "support.function.function-comma.fluent",
123+
"match": ","
124+
},
125+
"function-positional-argument": {
126+
"name": "variable.other.function.positional-argument.fluent",
127+
"match": "\\$[a-zA-Z0-9_-]+"
128+
},
129+
"function-named-argument": {
130+
"begin": "([a-zA-Z0-9]+:)\\s*([\"a-zA-Z0-9]+)",
131+
"end": "(?=\\)|,|\\s)",
132+
"beginCaptures": {
133+
"1": {
134+
"name": "support.function.named-argument.name.fluent"
135+
},
136+
"2": {
137+
"name": "variable.other.named-argument.value.fluent"
138+
}
139+
},
140+
"name": "variable.other.named-argument.fluent"
141+
},
142+
"placeable-string": {
143+
"begin": "(\")(?=[^\\n]*\")",
144+
"end": "(\")",
145+
"beginCaptures": {
146+
"1": {
147+
"name": "variable.other.placeable-string-begin.fluent"
148+
}
149+
},
150+
"endCaptures": {
151+
"1": {
152+
"name": "variable.other.placeable-string-end.fluent"
153+
}
154+
},
155+
"contentName": "string.placeable-string-content.fluent"
156+
},
157+
"selector": {
158+
"begin": "(->)",
159+
"end": "^(?=\\s*})",
160+
"beginCaptures": {
161+
"1": {
162+
"name": "support.function.selector.begin.fluent"
163+
}
164+
},
165+
"contentName": "string.selector.content.fluent",
166+
"patterns": [
167+
{
168+
"include": "#selector-item"
169+
}
170+
]
171+
},
172+
"selector-item": {
173+
"begin": "(\\s*\\*?\\[)([a-zA-Z0-9_-]+)(\\]\\s*)",
174+
"end": "^(?=\\s|})",
175+
"beginCaptures": {
176+
"1": {
177+
"name": "support.function.selector-item.begin.fluent"
178+
},
179+
"2": {
180+
"name": "variable.other.selector-item.begin.fluent"
181+
},
182+
"3": {
183+
"name": "support.function.selector-item.begin.fluent"
184+
}
185+
},
186+
"contentName": "string.selector-item.content.fluent",
187+
"patterns": [
188+
{
189+
"include": "#placeable"
190+
}
191+
]
192+
},
193+
"wrong-line": {
194+
"match": ".*",
195+
"name": "invalid.illegal.wrong-line.fluent"
196+
},
197+
"invalid-placeable-wrong-placeable-missing-end": {
198+
"name": "invalid.illegal.wrong-placeable-missing-end.fluent",
199+
"match": "([^}A-Z]*$|[^-][^>]$)\\b"
200+
},
201+
"invalid-placeable-string-missing-end-quote": {
202+
"name": "invalid.illegal.wrong-placeable-missing-end-quote.fluent",
203+
"match": "\"[^\"]+$"
29204
}
30-
},
31-
"scopeName": "source.ftl"
205+
}
32206
}

0 commit comments

Comments
 (0)