Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

Commit a170389

Browse files
Added function patterning.
1 parent caffa65 commit a170389

File tree

1 file changed

+101
-32
lines changed

1 file changed

+101
-32
lines changed

syntaxes/pine.tmLanguage.json

+101-32
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
"include": "#constants"
1414
},
1515
{
16-
"include": "#functionParam"
16+
"include": "#functionCall"
1717
},
1818
{
19-
"include": "#declarations"
19+
"include": "#functions"
2020
},
2121
{
22-
"include": "#functions"
22+
"include": "#variables"
2323
},
2424
{
2525
"include": "#operators"
@@ -91,8 +91,16 @@
9191
]
9292
},
9393
"number": {
94-
"name": "constant.numeric.decimal.pine",
95-
"match": "\\b(?:\\d+(?:\\.\\d+)?)\\b"
94+
"patterns": [
95+
{
96+
"name": "constant.numeric.decimal.pine",
97+
"match": "\\b(?:\\d+(?:\\.\\d+)?)\\b"
98+
},
99+
{
100+
"name": "constant.numeric.integer.pine",
101+
"match": "\\b\\d+\\b"
102+
}
103+
]
96104
},
97105
"literals": {
98106
"patterns": [
@@ -127,8 +135,8 @@
127135
}
128136
},
129137
"paramSeparator": {
130-
"name": "punctuation.separator.parameter",
131-
"match": "\\s*,\\s*"
138+
"name": "punctuation.separator.parameter.pine",
139+
"match": ","
132140
},
133141
"functionParam": {
134142
"patterns": [
@@ -154,13 +162,13 @@
154162
},
155163
"patterns": [
156164
{
157-
"include": "#string"
165+
"include": "#literals"
158166
},
159167
{
160-
"include": "#boolean"
168+
"include": "constants"
161169
},
162170
{
163-
"include": "#number"
171+
"include": "#paramSeparator"
164172
}
165173
],
166174
"end": "(?=\\s*(?:$|,|\\)))"
@@ -185,7 +193,30 @@
185193
}
186194
]
187195
},
188-
"declarations": {
196+
"functionParams": {
197+
"name": "meta.parameters.pine",
198+
"begin": "\\(",
199+
"beginCaptures": {
200+
"0": {
201+
"name": "punctuation.definition.parameters.begin.pine"
202+
}
203+
},
204+
"end": "\\)",
205+
"endCaptures": {
206+
"0": {
207+
"name": "punctuation.definition.parameters.end.pine"
208+
}
209+
},
210+
"patterns": [
211+
{
212+
"include": "#functionParam"
213+
},
214+
{
215+
"include": "#paramSeparator"
216+
}
217+
]
218+
},
219+
"variables": {
189220
"patterns": [
190221
{
191222
"name": "meta.var.expr.pine",
@@ -281,10 +312,66 @@
281312
}
282313
]
283314
},
315+
"functionCall": {
316+
"patterns": [
317+
{
318+
"name": "meta.function-call.pine",
319+
"begin": "(?<=(?:^|=)\\s*|\\w+\\.)(\\w+)(?=\\()",
320+
"beginCaptures": {
321+
"1": { "name": "entity.name.function" }
322+
},
323+
"end": "(?<=\\))\\s*$",
324+
"patterns": [
325+
{
326+
"include": "#literals"
327+
},
328+
{
329+
"include": "#constants"
330+
},
331+
{
332+
"include": "#functionCall"
333+
},
334+
{
335+
"include": "#paramSeparator"
336+
},
337+
{
338+
"match": "(?<=\\s+|\\(\\s*|,\\s*)(\\w+)(?=\\s*=)",
339+
"captures": {
340+
"1" : {
341+
"name":"entity.name.variable.parameter"
342+
}
343+
}
344+
},
345+
{
346+
"name": "variable.other.readwrite.pine",
347+
"match": "\\w+"
348+
}
349+
]
350+
}
351+
]
352+
},
284353
"functions": {
285354
"patterns": [
286355
{
287-
"match": "\\b(abs|acos|alertcondition|alma|asin|atan|atr|avg|bar(color|since)|bb|bbw|bgcolor|bool|cci|ceil|change|cmo|cog|color|color\\.new|correlation|cos|cross|crossover|crossunder|cum|dayofmonth|dayofweek|dev|dmi|ema|exp|falling|fill|financial|fixnan|floor|heikinashi|highest|highestbars|hline|hma|hour|iff|input|int|kagi|kc|kcw|label|line|linebreak|linreg|log|log10|lowest|lowestbars|macd|max|max_bars_back|mfi|min|minute|mom|month|na|nz|offset|percentile_linear_interpolation|percentile_nearest_rank|pivothigh|pivotlow|plot|plotarrow|plotbar|plotcandle|plotchar|plotshape|pointfigure|pow|quandl|renko|rising|rma|roc|round|rsi|sar|second|security|sign|sin|sma|sqrt|stdev|stoch|str\\.replace_all|strategy|string|study|sum|supertrend|swma|tan|tickerid|time|timestamp|tostring|tr|tsi|valuewhen|variance|vwma|weekofyear|wma|wpr|year)(?=\\()",
356+
"name": "meta.definition.function.pine",
357+
"begin": "^((export)\\s+)?(\\w+)(?=\\()",
358+
"beginCaptures": {
359+
"2": { "name": "keyword.control.export.pine" },
360+
"3": { "name": "entity.name.function" }
361+
},
362+
"end": "(?<=\\))\\s*=>",
363+
"patterns": [
364+
{
365+
"include": "#functionParams"
366+
}
367+
]
368+
}
369+
]
370+
},
371+
"functionsX": {
372+
"patterns": [
373+
{
374+
"match": "\\b(abs|acos|alma|asin|atan|atr|avg|bar(color|since)|bb|bbw|bgcolor|bool|cci|ceil|change|cmo|cog|color|color\\.new|correlation|cos|cross|crossover|crossunder|cum|dayofmonth|dayofweek|dev|dmi|ema|exp|falling|fill|financial|fixnan|floor|heikinashi|highest|highestbars|hline|hma|hour|iff|input|int|kagi|kc|kcw|label|line|linebreak|linreg|log|log10|lowest|lowestbars|macd|max|max_bars_back|mfi|min|minute|mom|month|na|nz|offset|percentile_linear_interpolation|percentile_nearest_rank|pivothigh|pivotlow|plot|plotarrow|plotbar|plotcandle|plotchar|plotshape|pointfigure|pow|quandl|renko|rising|rma|roc|round|rsi|sar|second|security|sign|sin|sma|sqrt|stdev|stoch|str\\.replace_all|strategy|string|study|sum|supertrend|swma|tan|tickerid|time|timestamp|tostring|tr|tsi|valuewhen|variance|vwma|weekofyear|wma|wpr|year)(?=\\()",
288375
"captures": {
289376
"1": {
290377
"name": "support.function.pine"
@@ -330,26 +417,11 @@
330417
"name": "support.function.pine"
331418
}
332419
}
333-
},
334-
{
335-
"match": "([a-zA-Z_][a-zA-Z0-9_]*)\\(.*\\)\\s(=>)\\s",
336-
"captures": {
337-
"1": {
338-
"name": "support.function.pine"
339-
},
340-
"2": {
341-
"name": "keyword.operator.assignment.pine"
342-
}
343-
}
344420
}
345421
]
346422
},
347423
"constants": {
348424
"patterns": [
349-
{
350-
"match": "\\b(true|false)\\b",
351-
"name": "constant.language.pine"
352-
},
353425
{
354426
"match": "\\b(accdist|bar_index|close|dayofmonth|dayofweek|high|hl2|hlc3|hour|iii|low|minute|month|na|nvi|obv|ohlc4|open|pvi|pvt|second|time|time_close|timenow|tr|volume|vwap|wad|weekofyear|wvad|year)\\b",
355427
"name": "constant.language.pine"
@@ -476,12 +548,9 @@
476548
},
477549
{
478550
"match": "#[a-fA-F0-9]{6}",
479-
"name": "contstant.support.pine"
480-
},
481-
{
482-
"match": "\\b([0-9]+)\\b",
483-
"name": "constant.numeric.pine"
551+
"name": "constant.support.pine"
484552
}
553+
485554
]
486555
},
487556
"operators": {

0 commit comments

Comments
 (0)