1/*
2A file for testing Stan syntax highlighting.
3
4It is not a real model and will not compile
5*/
6# also a comment
7// also a comment
8functions {
9  void f1(void a, real b) {
10    return 1 / a;
11  }
12  real f2(int a, vector b, real c) {
13    return a + b + c;
14  }
15}
16data {
17  // valid name
18  int abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_abc;
19  // all types should be highlighted
20  int a3;
21  real foo[2];
22  vector[3] bar;
23  row_vector[3] baz;
24  matrix[3,3] qux;
25  simplex[3] quux;
26  ordered[3] corge;
27  positive_ordered[3] wibble;
28  corr_matrix[3] grault;
29  cov_matrix[3] garply;
30  cholesky_factor_cov[3] waldo;
31  cholesky_factor_corr[3] waldo2;
32
33  real<lower=-1,upper=1> foo1;
34  real<lower=0> foo2;
35  real<upper=0> foo3;
36}
37transformed data {
38  real xyzzy;
39  int thud;
40  row_vector grault2;
41  matrix qux2;
42
43  // all floating point literals should be recognized
44  // all operators should be recognized
45  // paren should be recognized;
46  xyzzy <- 1234.5687 + .123 - (2.7e3 / 2E-5 * 135e-5);
47  // integer literal
48  thud <- -12309865;
49  // ./ and .* should be recognized as operators
50  grault2 <- grault .* garply ./ garply;
51  // ' and \ should be recognized as operators
52  qux2 <- qux' \ bar;
53
54}
55parameters {
56  real fred;
57  real plugh;
58}
59transformed parameters {
60}
61model {
62  // ~, <- are operators,
63  // T may be be recognized
64  // normal is a function
65  fred ~ normal(0, 1) T(-0.5, 0.5);
66  real tmp;
67  // C++ reserved
68  real public;
69
70  // control structures
71  for (i in 1:10) {
72    tmp <- tmp + 0.1;
73  }
74  tmp <- 0.0;
75  while (tmp < 5.0) {
76    tmp <- tmp + 1;
77  }
78  if (tmp > 0.0) {
79    print(tmp);
80  } else {
81    print(tmp);
82  }
83
84  // operators
85  tmp || tmp;
86  tmp && tmp;
87  tmp == tmp;
88  tmp != tmp;
89  tmp < tmp;
90  tmp <= tmp;
91  tmp > tmp;
92  tmp >= tmp;
93  tmp + tmp;
94  tmp - tmp;
95  tmp * tmp;
96  tmp / tmp;
97  tmp .* tmp;
98  tmp ./ tmp;
99  tmp ^ tmp;
100  ! tmp;
101  - tmp;
102  + tmp;
103  tmp ';
104
105  // lp__ should be highlighted
106  // normal_log as a function
107  lp__ <- lp__ + normal_log(plugh, 0, 1);
108  increment_log_prob(normal_log(plugh, 0, 1));
109
110  // print statement and string literal
111  print("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_~@#$%^&*`'-+={}[].,;: ");
112  print("Hello, world!");
113  print("");
114
115  // reject statement
116  reject("I just don't like it");
117
118}
119generated quantities {
120  real bar1;
121  bar1 <- foo + 1;
122}
123