If the preprocessor runs into an error while processing your .mod file, it will issue an error. Due to the way that a parser works, sometimes these errors can be misleading. Here, we aim to demystify these error messages.
The preprocessor issues error messages of the form:
ERROR: <<file.mod>>: line A, col B: <<error message>>
ERROR: <<file.mod>>: line A, cols B-C: <<error message>>
ERROR: <<file.mod>>: line A, col B - line C, col D: <<error message>>
The first two errors occur on a single line, with error two spanning multiple columns. Error three spans multiple rows.
Often, the line and column numbers are precise, leading you directly to the offending syntax. Infrequently however, because of the way the parser works, this is not the case. The most common example of misleading line and column numbers (and error message for that matter) is the case of a missing semicolon, as seen in the following example:
varexo a, b parameters c, ...;
In this case, the parser doesn’t know a semicolon is missing at the
end of the
varexo command until it begins parsing the second
line and bumps into the
parameters command. This is because we
allow commands to span multiple lines and, hence, the parser cannot
know that the second line will not have a semicolon on it until it
gets there. Once the parser begins parsing the second line, it
realizes that it has encountered a keyword,
it did not expect. Hence, it throws an error of the form:
<<file.mod>>: line 2, cols 0-9: syntax error, unexpected
PARAMETERS. In this case, you would simply place a semicolon at the
end of line one and the parser would continue processing.
It is also helpful to keep in mind that any piece of code that does not violate
Dynare syntax, but at the same time is not recognized by the parser, is interpreted
as native Matlab code. This code will be directly passed to the
driver.m-file then helps with debugging. Such problems most often
occur when defined variable or parameter names have been misspelled so that Dynare’s
parser is unable to recognize them.