forked from axemonk/Spreadsheet-Formula
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibreOffice Calc Formula.sublime-syntax
More file actions
151 lines (141 loc) · 4.79 KB
/
LibreOffice Calc Formula.sublime-syntax
File metadata and controls
151 lines (141 loc) · 4.79 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
%YAML 1.2
---
name: LibreOffice Calc Formula
scope: source.sheet.libre
version: 2
extends: Packages/Excel formula/Spreadsheet Formula (Basic).sublime-syntax
file_extensions:
- localc.txt
contexts:
function-builtins-extra:
- meta_append: true
- match: \b({{function_builtins_libre}})(\()
captures:
1: meta.function-call.libre support.function.libre
2: meta.function-call.arguments.libre punctuation.section.arguments.begin.libre
push: function-call-body
sheet-reference:
- match: \$(?={{sheet}}\.)
scope: punctuation.definition.annotation.begin.libre
push: sheet-reference-body-dollar
- match: (?={{sheet}}!)
push: sheet-reference-body
sheet-reference-body-dollar:
- meta_scope: meta.reference.sheet.libre
- match: \.
scope: punctuation.separator.sequence.libre
pop: 1
- include: sheet-reference-quoted
- match: '{{sheet}}'
scope: entity.name.struct.sheet.libre
- include: immediately-pop
sheet-reference-body:
- meta_scope: meta.reference.sheet.libre
- match: '!'
scope: punctuation.separator.sequence.libre
pop: 1
- include: sheet-reference-quoted
- match: '{{sheet}}'
scope: entity.name.struct.sheet.libre
- include: immediately-pop
sheet-reference-quoted:
- match: \'
scope: punctuation.definition.annotation.begin.libre
push:
- meta_content_scope: entity.name.struct.sheet.libre
- match: \'\'
scope: constant.character.escape.libre
- match: \'(?=[!\.])
scope: punctuation.definition.annotation.end.libre
pop: 1
cell-or-range-reference:
- meta_append: true
- match: ({{rc}})(:)({{rc}})
scope: meta.reference.range.cell.libre
captures:
1: storage.type.libre
2: punctuation.separator.sequence.libre
3: storage.type.libre
push: after-reference
- match: ({{rc}})
scope: meta.reference.range.cell.libre
captures:
1: storage.type.libre
2: punctuation.separator.sequence.libre
3: storage.type.libre
push: after-reference
variables:
function_builtins_libre: |-
\b(?xi:
AGGREGATE | AMORDEGRC | AREAS |
B | BAHTTEXT | BESSELI | BESSELJ | BESSELK | BESSELY |
CEILING.XCL | CHISQDIST | CHISQINV | COLOR | CONVERT_OOO | CUMIPMT_ADD | CUMPRINC_ADD | CURRENT |
DAYSINMONTH | DAYSINYEAR | DDE |
EASTERSUNDAY | EFFECT_ADD | ERRORTYPE | EUROCONVERT |
FILTERXML | FLOOR.XCL | FORECAST.ETS.ADD | FORECAST.ETS.MULT | FORECAST.ETS.PI.ADD | FORECAST.ETS.PI.MULT | FORECAST.ETS.SEASONALITY | FORECAST.ETS.STAT.ADD | FORECAST.ETS.STAT.MULT | FORMULA | FOURIER |
GCD_EXCEL2003 |
INFO | ISEVEN_ADD | ISLEAPYEAR | ISODD_ADD |
JIS |
LCM_EXCEL2003 |
MULTIPLE.OPERATIONS | MONTHS |
NETWORKDAYS_EXCEL2003 | NOMINAL_ADD | NUMBERVALUE |
ODDFPRICE | ODDFYIELD | ODDLPRICE | ODDLYIELD | OPT_BARRIER | OPT_PROB_HIT | OPT_PROB_INMONEY | OPT_TOUCH |
RAND.NV | RANDBETWEEN.NV | RAWSUBTRACT | REGEX | ROT13 | ROUNDSIG |
SHEET | SHEETS | SKEWP | STYLE |
TODAY |
WEBSERVICE | WEEKNUM_EXCEL2003 | WEEKS | WEEKSINYEAR |
YEARS
)\b
# NOTE: Negative lookahead prevents this pattern from chaining matches like in '@name' (i.e., only a single '@' is a valid name).
# TODO: Is there a better way to do this?
name: |-
(?x:
[_.?@`\\]
(?![\w?$]+[\w.$]*) |
[\w?$]+
[\w.$]*
)
# LibreOffice does not have LAMBDA() and cannot define functions in LET().
# These rules stem from testing in LO's VBA analog: LibreOffice Basic
function: (?i:[a-z]\w*)
# LibreOffice does not support tables
table: (?!.)
# TODO: Is there a cleaner more compact (and probably more efficient) way to
#(dupe) do this? `'` are only legal in excel sheet names when padded on
# either end with a legal character matched by [^:*/?\[\]\\],
# and said `'` must come in pairs.
# TODO: Update with LibreOffice alternate-format sheet references in addition.
sheet_delimited: |-
(?x:
(?:'[^:*/?\[\]\\]+('')*[^:*/?\[\]\\]+')|
(?:'[^:*/?\[\]\\]+')|
(?:\$'[^:*/?\[\]\\]+('')*[^:*/?\[\]\\]+')
)
sheet_normal: |-
(?x:
(?:[\w&&[^0-9]]\w*)|
(?:\$[^\.:*/?\[\]\\]+)
)
sheet: (?:{{sheet_delimited}}|{{sheet_normal}})
# RC row/column offset format
r_: |-
(?xi:
R
(?:
\[[-\+]?[1-9][0-9]{0,6}\] |
[1-9][0-9]{0,6}
)
(?:
(?={{c_}})
| (?=C?(?!{{name}}))
)
)
c_: (?i:C(?:\[[-\+]?[1-9][0-9]{0,4}\]|[1-9][0-9]{0,4})(?!{{name}}))
rc: |-
(?xi:
{{r_}}{{c_}}|
{{r_}}C|
{{r_}}|
R{{c_}}|
{{c_}}
)