Skip to content

Commit f083fcd

Browse files
committed
Merge branch 'altela-v5'
Close gerardroche#8 * altela-v5: Update tests Added Built-in variables added time added timeframe added xloc & yloc added table added text added ta added splits added position added other properties in session added label added math added label.style added last_bar added line.style added hline.style added shape added other properties in strategy added other properties in syminfo added order added @Version Added Built-in Variables added hl2, hlc3, hlcc4 added adjustment .dividends .none /splits addedd alert .freq_all .freq_once_per_bar .freq_once_per_bar_close addedd dayofweek .monday to .sunday addedd bar_index added scale .left .none .right added barmerge.gaps & barmerge.lookahead added barstate.is addedd box added display added earnings .actual .estimate .standardized addedd extend .both .left .none .right addedd location .abovebar .belowbar ... .absolute added hline.style added format added dividends .gross .net Fixed several scopes move bool to constant.language.pine move int to constant.numeric.integer.pine move float to constant.numeric.float.pine added var & varip to variable.other.pine added string with string.pine fixed keyword.operator.arithmetic.pine by adding \ so symbols are colored added series, simple, switch & move import export to keyword.control.import.pine Added language operator added var & varip fixed tikerid to tickerid add conditional & loops block addedd while loop added series, simple,switch Added operator greater than or equal to >= added for & for...in addedd import & export Also moving if, else to a new scope (keyword.control.conditional.pine) Add Operator Modulo assignment %= Multiplication assignment *= Addition assignment += Subsraction assignment -=
2 parents ffe7ae7 + 05d1df7 commit f083fcd

File tree

2 files changed

+138
-41
lines changed

2 files changed

+138
-41
lines changed

Pine.sublime-syntax

Lines changed: 117 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,53 @@ contexts:
1313
- match: //.*
1414
scope: comment.pine
1515

16-
#constants
16+
#constant:
17+
- match: \b(bool|true|false)\b
18+
scope: constant.language.pine
19+
20+
- match: \b(timenow|year|month|weekofyear|dayofmonth|hour|minute|second|interval|isdaily|isdwm|isintraday|ismonthly|isweekly)\b
21+
scope: constant.language.pine
22+
23+
- match: \b(time)\_(close|tradingday)\b
24+
scope: constant.language.pine
1725

18-
- match: \b(true|false)\b
26+
- match: \b(timeframe)\.(isdaily|isdwm|isintraday|isminutes|ismonthly|isseconds|isweekly|multiplier|period)\b
1927
scope: constant.language.pine
2028

21-
- match: \b(bool|float|integer|string)\b
29+
- match: \b(open|high|low|close|hl2|hlc3|hlcc4|volume|na|period|tickerid|source|symbol)\b
2230
scope: constant.language.pine
2331

24-
- match: \b(time|timenow|year|month|weekofyear|dayofmonth|dayofweek|hour|minute|second|interval|isdaily|isdwm|isintraday|ismonthly|isweekly)\b
32+
- match: \b(xloc.bar)\.(index|time)\b
2533
scope: constant.language.pine
2634

27-
- match: \b(open|high|low|close|volume|na|period|tikerid|source|symbol)\b
35+
- match: \b(yloc)\.(abovebar|belowbar|price)\b
2836
scope: constant.language.pine
2937

3038
- match: \b(accdist|area|areabr|hl(2|c3)|ohlc4)\b
3139
scope: constant.language.pine
3240

33-
- match: \badjustment\.(dividends|none|splits)\b
41+
- match: \b(table.all)\b
42+
scope: constant.language.pine
43+
44+
- match: \b(text)\.(align|wrap)\_(bottom|center|left|right|top|auto|none)\b
45+
scope: constant.language.pine
46+
47+
- match: \b(ta)\.(accdist|iii|nvi|obv|pvi|pvt|tr|vwap|wad|wvad)\b
48+
scope: constant.language.pine
49+
50+
- match: \b(adjustment)\.(dividends|none|splits)\b
51+
scope: constant.language.pine
52+
53+
- match: \b(splits)\.(denominator|numerator)\b
54+
scope: constant.language.pine
55+
56+
- match: \b(position)\.(bottom|middle|top)\_(center|left|right)\b
3457
scope: constant.language.pine
3558

36-
- match: \b(monday|tuesday|wednesday|thursday|friday|saturday|sunday|dayofweek)\b
59+
- match: \b(alert)\.(freq_all|freq_once_per_bar|freq_once_per_bar_close)\b
60+
scope: constant.language.pine
61+
62+
- match: \b(dayofweek|dayofweek.(monday|tuesday|wednesday|thursday|friday|saturday|sunday))\b
3763
scope: constant.language.pine
3864

3965
- match: \b(line|stepline|histogram|cross[^\(]|area|columns|circles)\b
@@ -42,37 +68,90 @@ contexts:
4268
- match: \b(solid|dotted|dashed)\b
4369
scope: constant.language.pine
4470

45-
- match: \b(session|session.(extended|regular))\b
71+
- match: \b(bar_index)\b
72+
scope: constant.language.pine
73+
74+
- match: \b(session|session.(extended|regular|ismarket|ispostmarket|ispremarket))\b
75+
scope: constant.language.pine
76+
77+
- match: \b(scale).(left|none|right)\b
78+
scope: constant.language.pine
79+
80+
- match: \b(barmerge)\.(gaps_(off|on)|lookahead_(off|on))\b
81+
scope: constant.language.pine
82+
83+
- match: \b(barstate)\.is(confirmed|first|history|last|new|realtime|islastconfirmedhistory)\b
84+
scope: constant.language.pine
85+
86+
- match: \b(box)\.(all)\b
87+
scope: constant.language.pine
88+
89+
- match: \b(currency)\.(AUD|CAD|CHF|EUR|GBP|HKD|JPY|NOK|NONE|NZD|RUB|SEK|SGD|TRY|USD|ZAR)\b
4690
scope: constant.language.pine
4791

48-
- match: \bscale.(left|none|right)\b
92+
- match: \b(display)\.(all|none)\b
4993
scope: constant.language.pine
5094

51-
- match: \bbarmerge\.(gaps_(off|on)|lookahead_(off|on))\b
95+
- match: \b(label)\.(all)\b
5296
scope: constant.language.pine
5397

54-
- match: \bbarstate\.is(confirmed|first|history|last|new|realtime)\b
98+
- match: \b(math)\.(e|phi|pi|rphi)\b
5599
scope: constant.language.pine
56100

57-
- match: \bcurrency\.(AUD|CAD|CHF|EUR|GBP|HKD|JPY|NOK|NONE|NZD|RUB|SEK|SGD|TRY|USD|ZAR)\b
101+
- match: \b(label.style)\_(arrowdown|arrowup|circle|cross|diamond|flag|label_center|label_down|label_left|label_lower_left|label_lower_right|label_upper_left|label_upper_right|none|square|triangledown|triangleup|xcross)\b
58102
scope: constant.language.pine
59103

60-
- match: \blocation\.(abovebar|belowbar|top|bottom|absolute)\b
104+
- match: \b(last_bar)\.(index|time)\b
105+
scope: constant.language.pine
106+
107+
- match: \b(earnings)\.(actual|estimate|standardized)\b
108+
scope: constant.language.pine
109+
110+
- match: \b(extend)\.(both|left|none|right)\b
111+
112+
- match: \b(location)\.(abovebar|belowbar|top|bottom|absolute)\b
113+
scope: constant.language.pine
114+
115+
- match: \b(line.all)\b
116+
scope: constant.language.pine
117+
118+
- match: \b(linefill.all)\b
119+
scope: constant.language.pine
120+
121+
- match: \b(line.style)\_(arrow_both|arrow_left|arrow_right|dashed|dotted|solid)\b
122+
scope: constant.language.pine
123+
124+
- match: \b(hline.style)\_(dashed|dotted|solid)\b
125+
scope: constant.language.pine
126+
127+
- match: \b(format)\.(inherit|mintick|percent|price|volume)\b
61128
scope: constant.language.pine
62129

63130
- match: \bshape\.(x(cross)?|(triangle|arrow|label)(up|down)|flag|circle|square|diamond)\b
64131
scope: constant.language.pine
65132

133+
- match: \bshape\.(arrowdown|arrowup|circle|cross|diamond|flag|labeldown|labelup|square|triangledown|triangleup)\b
134+
scope: constant.language.pine
135+
66136
- match: \bsize\.(auto|huge|large|normal|small|tiny)\b
67137
scope: constant.language.pine
68138

69-
- match: \bstrategy\.(cash|closedtrades|commission\.(cash_per_contract|cash_per_order|percent)|direction\.(all|long|short)|equity|eventrades|fixed|grossloss|grossprofit|initial_capital|long|losstrades|max_contracts_held_all|max_contracts_held_long|max_contracts_held_short|max_drawdown|netprofit|oca\.(cancel|none|reduce)|openprofit|opentrades|percent_of_equity|position_avg_price|position_entry_name|position_size|short|wintrades)\b
139+
- match: \b(plot.style)\_(area|areabr|circles|columns|cross|histogram|line|linebr|stepline|stepline_diamond)\b
140+
scope: constant.language.pine
141+
142+
- match: \bstrategy\.(cash|closedtrades|commission\.(cash_per_contract|cash_per_order|percent)|direction\.(all|long|short)|equity|eventrades|fixed|grossloss|grossprofit|initial_capital|long|losstrades|max_contracts_held_all|max_contracts_held_long|max_contracts_held_short|max_drawdown|netprofit|oca\.(cancel|none|reduce)|openprofit|opentrades|percent_of_equity|position_avg_price|position_entry_name|position_size|short|wintrades)(account_currency)\b
143+
scope: constant.language.pine
144+
145+
- match: \bsyminfo\.(basecurrency|currency|description|mintick|pointvalue|prefix|root|session|ticker|tickerid|timezone|type)\b
70146
scope: constant.language.pine
71147

72-
- match: \bsyminfo\.(mintick|pointvalue|prefix|root|session|timezone)\b
148+
- match: \b(color)\.(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow)\b
73149
scope: constant.language.pine
74150

75-
- match: \b(aqua|black|silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|orange)\b
151+
- match: \b(dividends)\.(gross|net)\b
152+
scope: constant.language.pine
153+
154+
- match: \b(order)\.(ascending|descending)\b
76155
scope: constant.language.pine
77156

78157
- match: '#[a-fA-F0-9]{6}'
@@ -81,25 +160,43 @@ contexts:
81160
- match: '\b([0-9]+)\b'
82161
scope: constant.numeric.pine
83162

84-
# strings
163+
- match: \b(int)\b
164+
scope: constant.numeric.integer.pine
165+
166+
- match: \b(float)\b
167+
scope: constant.numeric.float.pine
85168

169+
# var
170+
- match: \b(var|varip)\b
171+
scope: variable.other.pine
172+
173+
# strings
86174
- match: ''''
87175
push: single-quoted-string
88176
- match: '"'
89177
push: double-quoted-string
178+
- match: \b(string)\b
179+
scope: string.pine
90180

91181
# operators
92182

93-
- match: (\-|\+|\*|/|%)
183+
- match: (\-|\+|\*|\/|\%|\*=|\+=|\-=|\/=)
94184
scope: keyword.operator.arithmetic.pine
95-
- match: (==|!=|<=|>=|<|>|\:=)
185+
- match: (==|!=|<=|=>|>=|<|>|\:=|%=)
96186
scope: keyword.operator.comparison.pine
97187
- match: (\?|\:)
98188
scope: keyword.operator.ternary.pine
99189
- match: \b(and|or|not)\b
100190
scope: keyword.operator.logical.pine
101191
- match: "="
102192
scope: keyword.operator.assignment.pine
193+
194+
# control
195+
- match: \b(//@version=5|export|import|series|simple|switch|)\b
196+
scope: keyword.control.import.pine
197+
198+
- match: (|if|else|for|for...in|while)
199+
scope: keyword.control.conditional.pine
103200

104201
# functions
105202

@@ -110,7 +207,7 @@ contexts:
110207
- match: '{{identifier_regex}}\s*(?=:?\=)'
111208
scope: variable.parameter.pine
112209

113-
- match: ('({{identifier_regex}})\(.*\)\s(=>)\s'|if|else)
210+
- match: ('({{identifier_regex}})\(.*\)\s(=>)\s')
114211
captures:
115212
1: entity.name.function
116213
2: keyword.operator.assignment.pine

syntax_test.pine

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,27 +110,27 @@ is_day_equal_to(day) => dayofweek == day and close ? 1 : 0
110110
// ^ keyword.operator
111111
// ^ constant.numeric
112112

113-
is_mon = is_day_equal_to(monday)
113+
is_mon = is_day_equal_to(dayofweek.monday)
114114
// ^ variable
115115
// ^ keyword.operator.assignment
116-
// ^^^^^^ constant.language
117-
is_tue = is_day_equal_to(tuesday)
118-
// ^^^^^^^ constant.language
119-
is_wed = is_day_equal_to(wednesday)
120116
// ^^^^^^^^^ constant.language
121-
is_thu = is_day_equal_to(thursday)
122-
// ^^^^^^^^ constant.language
123-
is_fri = is_day_equal_to(friday)
124-
// ^^^^^^ constant.language
125-
is_sat = is_day_equal_to(saturday)
126-
// ^^^^^^^^ constant.language
127-
is_sun = is_day_equal_to(sunday)
128-
// ^^^^^^ constant.language
129-
130-
plotchar(display_mon, char="M", color=white, location=location.bottom)
117+
is_tue = is_day_equal_to(dayofweek.tuesday)
118+
// ^^^^^^^^^ constant.language
119+
is_wed = is_day_equal_to(dayofweek.wednesday)
120+
// ^^^^^^^^^ constant.language
121+
is_thu = is_day_equal_to(dayofweek.thursday)
122+
// ^^^^^^^^^ constant.language
123+
is_fri = is_day_equal_to(dayofweek.friday)
124+
// ^^^^^^^^^ constant.language
125+
is_sat = is_day_equal_to(dayofweek.saturday)
126+
// ^^^^^^^^^ constant.language
127+
is_sun = is_day_equal_to(dayofweek.sunday)
128+
// ^^^^^^^^^ constant.language
129+
130+
plotchar(display_mon, char="M", color=color.white, location=location.bottom)
131131
// ^ support.function
132-
// ^^^^^ constant.language
133-
// ^^^^^^^^^^^^^^^ constant.language
132+
// ^^^^^^^^^^^ constant.language
133+
// ^^^^^^^^^^^^^^^ constant.language
134134

135135
m_kijun_sen = security(tickerid, "1M", avg(lowest(26), highest(26)))
136136
// ^^^^^^^^ support.function
@@ -154,7 +154,7 @@ fastMA = ema(close, fast)
154154
slowMA = ema(close, slow)
155155
macd = fastMA - slowMA
156156
signal = sma(macd, 9)
157-
plot(macd, color=blue)
158-
// ^^^^ constant.language
159-
plot(signal, color=orange)
160-
// ^^^^^^ constant.language
157+
plot(macd, color=color.blue)
158+
// ^^^^^^^^^^ constant.language
159+
plot(signal, color=color.orange)
160+
// ^^^^^^^^^^^^ constant.language

0 commit comments

Comments
 (0)