Skip to content

Commit 9157643

Browse files
authored
Merge pull request #1585 from stan-dev/jacobian-reserved-parser
Add jacobian to special parser reserved error messaging
2 parents 1842854 + 0f76d54 commit 9157643

6 files changed

Lines changed: 263 additions & 228 deletions

File tree

src/frontend/parser.messages

Lines changed: 227 additions & 227 deletions
Large diffs are not rendered by default.

src/frontend/parser.mly

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ reserved_word:
258258
| REJECT { "reject", $loc, false }
259259
| FATAL_ERROR { "fatal_error", $loc, false }
260260
| TARGET { "target", $loc, false }
261+
| JACOBIAN { "jacobian", $loc, false }
261262
| PROFILE { "profile", $loc, false }
262263
| TUPLE { "tuple", $loc, true }
263264
| OFFSET { "offset", $loc, false }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
data {
2+
real jacobian;
3+
}
4+
model {
5+
}

test/integration/bad/reserved/stanc.expected

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,18 @@ Syntax error in 'int.stan', line 2, column 7 to column 10, parsing error:
212212
-------------------------------------------------
213213

214214
Ill-formed identifier. Expected a new identifier but found reserved keyword "int".
215+
[exit 1]
216+
$ ../../../../../install/default/bin/stanc jacobian.stan
217+
Syntax error in 'jacobian.stan', line 2, column 7 to column 15, parsing error:
218+
-------------------------------------------------
219+
1: data {
220+
2: real jacobian;
221+
^
222+
3: }
223+
4: model {
224+
-------------------------------------------------
225+
226+
Ill-formed identifier. Expected a new identifier but found reserved keyword "jacobian".
215227
[exit 1]
216228
$ ../../../../../install/default/bin/stanc matrix.stan
217229
Syntax error in 'matrix.stan', line 2, column 7 to column 13, parsing error:
@@ -401,6 +413,18 @@ Syntax error in 'sum_to_zero_vector.stan', line 2, column 7 to column 25, parsin
401413
-------------------------------------------------
402414

403415
Ill-formed identifier. Expected a new identifier but found reserved keyword "sum_to_zero_vector".
416+
[exit 1]
417+
$ ../../../../../install/default/bin/stanc target.stan
418+
Syntax error in 'target.stan', line 2, column 7 to column 13, parsing error:
419+
-------------------------------------------------
420+
1: data {
421+
2: real target;
422+
^
423+
3: }
424+
4: model {
425+
-------------------------------------------------
426+
427+
Ill-formed identifier. Expected a new identifier but found reserved keyword "target".
404428
[exit 1]
405429
$ ../../../../../install/default/bin/stanc then.stan
406430
Semantic error in 'then.stan', line 2, column 7 to column 11:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
data {
2+
real target;
3+
}
4+
model {
5+
}

test/integration/cli-args/debug-flags.t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,5 +470,5 @@ Flags not used elsewhere in the tests
470470

471471
Ill-formed program. Expected "functions {", "transformed data {", "parameters {",
472472
"transformed parameters {", "model {", or "generated quantities {".
473-
(Parse error state 410)
473+
(Parse error state 411)
474474
[1]

0 commit comments

Comments
 (0)