-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathStan.YAML-tmLanguage
161 lines (135 loc) · 6.91 KB
/
Stan.YAML-tmLanguage
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
152
153
154
155
156
157
158
159
160
161
# [PackageDev] target_format: plist, ext: tmLanguage
name: Stan
scopeName: source.stan
fileTypes: [stan]
uuid: c96512e4-9455-4f67-91cd-82038a26ec1a
patterns:
- include: '#double-slash'
- include: '#pound-sign'
- include: '#block-comment'
- contentName: meta.block.major.stan
begin: ^\s*(data|transformed data|parameters|transformed parameters|model|generated
quantities|functions)\s*{
beginCaptures:
'1': {name: keyword.control.block-names.stan}
end: '}'
patterns:
- include: '#double-slash'
- include: '#pound-sign'
- include: '#block-comment'
- include: '#string'
- include: '#type'
- include: '#range'
- include: '#control-flow'
- include: '#cpp-conflict'
- include: '#continuous-distributions'
- include: '#discrete-distributions'
- include: '#spec-vals'
- include: '#math-fns'
- include: '#other-fns'
- include: '#lp'
- include: '#double-underscore'
- include: '#vars'
- include: '#real-a'
- include: '#real-b'
- include: '#real-c'
- include: '#integer'
- include: '#block'
- name: invalid.illegal.top-level
match: '[^\s]+(\s*[^\s]+)?'
repository:
block:
contentName: meta.block.minor.stan
begin: '{'
end: '}'
patterns:
- include: '#double-slash'
- include: '#pound-sign'
- include: '#block-comment'
- include: '#string'
- include: '#type'
- include: '#range'
- include: '#control-flow'
- include: '#cpp-conflict'
- include: '#continuous-distributions'
- include: '#discrete-distributions'
- include: '#spec-vals'
- include: '#math-fns'
- include: '#other-fns'
- include: '#lp'
- include: '#double-underscore'
- include: '#vars'
- include: '#real-a'
- include: '#real-b'
- include: '#real-c'
- include: '#integer'
- include: '#block'
block-comment:
name: comment.block.slashes
begin: /\*
end: \*/
continuous-distributions:
name: support.function.distribution.pdf.stan
match: \b((normal|exp_mod_normal|skew_normal|student_t|cauchy|double_exponential|logistic|gumbel|lognormal|chi_square|inv_chi_square|scaled_inv_chi_square|exponential|gamma|inv_gamma|weibull|frechet|rayleigh|pareto|pareto_type_2|beta|uniform)(_lpdf|_cdf|_lcdf|_lccdf|_rng)?|(von_mises|multi_normal|multi_normal_cholesky|multi_student_t|dirichlet|lkj_corr|lkj_corr_cholesky|wishart|inv_wishart)(_lpdf|_rng)?|(wiener|multi_normal_prec|multi_gp|multi_gp_cholesky|gaussian_dlm_obs)(_lpdf)?)\b
control-flow:
name: keyword.control.stan
match: \b(for|in|while|repeat|until|if|then|else|return)\b
cpp-conflict:
comment: reserved words in C++ that are invalid in Stan
name: invalid.illegal.cpp-conflict.stan
match: \b(alignas|alignof|and|and_eq|asm|auto|bitand|bitor|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|false|float|friend|goto|if|inline|long|mutable|namespace|new|noexcept|not|not_eq|nullptr|operator|or|or_eq|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|true|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while|xor|xor_eq)\b
discrete-distributions:
name: support.function.distribution.pdf.stan
match: \b((bernoulli|binomial|beta_binomial|neg_binomial|neg_binomial_2|poisson)(_lpmf|_cdf|_lcdf|_lccdf|_rng)?|(bernoulli_logit|binomial_logit|hypergeometric|categorical|categorical_logit|ordered_logistic|neg_binomial_2_log|poisson_log|multinomial)(_lpmf|_rng)?)\b
double-slash:
name: comment.line.double-slash.stan
match: //.*$
double-underscore:
name: invalid.illegal.variable.double-underscore.stan
match: \b[a-zA-Z][a-zA-Z0-9_]*__\b
integer:
name: constant.numeric.integer.stan
match: -?(0|[1-9]\d*)
lp:
name: variable.language.logprob.stan
match: \b(target|get_lp)\b
math-fns:
name: support.function.math.stan
match: \b(abs|int_step|min|max|pi|e|sqrt2|step|is_inf|is_nan|fabs|fdim|fmin|fmax|fmod|floor|ceil|round|trunc|sqrt|cbrt|square|exp|exp2|log|log2|log10|pow|inv|inv_sqrt|inv_square|hypot|cos|sin|tan|acos|asin|atan|atan2|cosh|sinh|tanh|acosh|asinh|atanh|logit|inv_logit|inv_cloglog|erf|erfc|Phi|inv_Phi|Phi_approx|binary_log_loss|owens_t|inc_beta|lbeta|tgamma|lgamma|digamma|trigamma|lmgamma|gamma_p|gamma_q|binomial_coefficient_log|choose|bessel_first_kind|bessel_second_kind|modified_bessel_first_kind|modified_bessel_second_kind|falling_factorial|lchoose|log_falling_factorial|rising_factorial|log_rising_factorial|expm1|fma|multiply_log|lmultiply|log1p|log1m|log1p_exp|log1m_exp|log_dif_exp|log_mix|log_sum_exp|log_inv_logit|log1m_inv_logit|sum|prod|mean|variance|sd|distance|squared_distance|dims|num_elements|size|rep_array|sort_asc|sort_desc|sort_indices_asc|sort_indices_desc|rank|rows|cols|dot_product|columns_dot_product|rows_dot_product|dot_self|columns_dot_self|rows_dot_self|tcrossprod|crossprod|quad_form|quad_form_diag|quad_form_sym|trace_quad_form|trace_gen_quad_form|multiply_lower_tri_self_transpose|diag_pre_multiply|diag_post_multiply|rep_vector|rep_row_vector|rep_matrix|diagonal|diag_matrix|block|sub_col|sub_row|head|tail|segment|append_col|append_row|softmax|log_softmax|cumulative_sum|cov_exp_quad|mdivide_left_tri_low|mdivide_right_tri_low|mdivide_left_spd|mdivide_right_spd|matrix_exp|trace|determinant|log_determinant|inverse|inverse_spd|eigenvalues_sym|eigenvectors_sym|qr_Q|qr_R|cholesky_decompose|singular_values|csr_extract_w|csr_extract_v|csr_extract_u|csr_to_dense_matrix|csr_matrix_times_vector|to_matrix|to_vector|to_row_vector|to_array_2d|to_array_1d|algebra_solver|integrate_ode_rk45|integrate_ode|integrate_ode_bdf|)\b
other-fns:
name: support.function.other.stan
match: \bprint\b
pound-sign:
name: comment.line.number-sign.stan
match: '#.*$'
range:
name: keyword.other.range.stan
match: \b(lower|upper)\b
real-a:
comment: have a point with numbers after, maybe an exponent
name: constant.numeric.real.stan
match: -?(0|[1-9]\d*)?\.\d+([eE]-?(0|[1-9]\d*))?
real-b:
comment: have a point with numbers before, maybe an exponent
name: constant.numeric.real.stan
match: -?(0|[1-9]\d*)\.\d*([eE]-?(0|[1-9]\d*))?
real-c:
comment: no point, have an exponent
name: constant.numeric.real.stan
match: -?(0|[1-9]\d*)[eE]-?(0|[1-9]\d*)
spec-vals:
name: support.function.special-value.stan
match: \bnot_a_number|positive_infinity|negative_infinity|machine_precision\b
string:
name: string.quoted.double.stan
begin: '"'
end: '"'
patterns:
- name: invalid.illegal.quoted.bad-char.stan
match: (\p{^ASCII}|\p{Cntrl}|\\)+
type:
name: storage.type.stan
match: \b(int|real|vector|simplex|unit_vector|ordered|positive_ordered|row_vector|matrix|cholesky_factor_corr|cholesky_factor_cov|corr_matrix|cov_matrix)\b
vars:
name: variable.other.stan
match: \b[a-zA-Z][a-zA-Z0-9_]*\b