source: node_modules/refractor/lang/stan.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 2.6 KB
Line 
1'use strict'
2
3module.exports = stan
4stan.displayName = 'stan'
5stan.aliases = []
6function stan(Prism) {
7 ;(function (Prism) {
8 // https://mc-stan.org/docs/2_28/reference-manual/bnf-grammars.html
9 var higherOrderFunctions =
10 /\b(?:algebra_solver|algebra_solver_newton|integrate_1d|integrate_ode|integrate_ode_bdf|integrate_ode_rk45|map_rect|ode_(?:adams|bdf|ckrk|rk45)(?:_tol)?|ode_adjoint_tol_ctl|reduce_sum|reduce_sum_static)\b/
11 Prism.languages.stan = {
12 comment: /\/\/.*|\/\*[\s\S]*?\*\/|#(?!include).*/,
13 string: {
14 // String literals can contain spaces and any printable ASCII characters except for " and \
15 // https://mc-stan.org/docs/2_24/reference-manual/print-statements-section.html#string-literals
16 pattern: /"[\x20\x21\x23-\x5B\x5D-\x7E]*"/,
17 greedy: true
18 },
19 directive: {
20 pattern: /^([ \t]*)#include\b.*/m,
21 lookbehind: true,
22 alias: 'property'
23 },
24 'function-arg': {
25 pattern: RegExp(
26 '(' +
27 higherOrderFunctions.source +
28 /\s*\(\s*/.source +
29 ')' +
30 /[a-zA-Z]\w*/.source
31 ),
32 lookbehind: true,
33 alias: 'function'
34 },
35 constraint: {
36 pattern: /(\b(?:int|matrix|real|row_vector|vector)\s*)<[^<>]*>/,
37 lookbehind: true,
38 inside: {
39 expression: {
40 pattern: /(=\s*)\S(?:\S|\s+(?!\s))*?(?=\s*(?:>$|,\s*\w+\s*=))/,
41 lookbehind: true,
42 inside: null // see below
43 },
44 property: /\b[a-z]\w*(?=\s*=)/i,
45 operator: /=/,
46 punctuation: /^<|>$|,/
47 }
48 },
49 keyword: [
50 {
51 pattern:
52 /\bdata(?=\s*\{)|\b(?:functions|generated|model|parameters|quantities|transformed)\b/,
53 alias: 'program-block'
54 },
55 /\b(?:array|break|cholesky_factor_corr|cholesky_factor_cov|complex|continue|corr_matrix|cov_matrix|data|else|for|if|in|increment_log_prob|int|matrix|ordered|positive_ordered|print|real|reject|return|row_vector|simplex|target|unit_vector|vector|void|while)\b/, // these are functions that are known to take another function as their first argument.
56 higherOrderFunctions
57 ],
58 function: /\b[a-z]\w*(?=\s*\()/i,
59 number:
60 /(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:E[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,
61 boolean: /\b(?:false|true)\b/,
62 operator: /<-|\.[*/]=?|\|\|?|&&|[!=<>+\-*/]=?|['^%~?:]/,
63 punctuation: /[()\[\]{},;]/
64 }
65 Prism.languages.stan.constraint.inside.expression.inside =
66 Prism.languages.stan
67 })(Prism)
68}
Note: See TracBrowser for help on using the repository browser.