| 1 | .if \n(xx .bp |
| 2 | .if !\n(xx \{\ |
| 3 | .so tmac.p \} |
| 4 | .if n 'ND |
| 5 | .nr H1 2 |
| 6 | .NH |
| 7 | Error diagnostics |
| 8 | .PP |
| 9 | This section of the |
| 10 | .UM |
| 11 | discusses the error diagnostics of the programs |
| 12 | .PI |
| 13 | and |
| 14 | .X . |
| 15 | .I Pix |
| 16 | is a simple but useful program which invokes |
| 17 | .PI |
| 18 | and |
| 19 | .X |
| 20 | to do all the real processing. |
| 21 | See its manual section |
| 22 | .IX |
| 23 | (6) |
| 24 | and section 5.2 below for more details. |
| 25 | .NH 2 |
| 26 | Translator syntax errors |
| 27 | .PP |
| 28 | A few comments on the general nature of the syntax errors usually |
| 29 | made by Pascal programmers |
| 30 | and the recovery mechanisms of the current translator may help in using |
| 31 | the system. |
| 32 | .SH |
| 33 | Illegal characters |
| 34 | .PP |
| 35 | Characters such as `$', `!', and `@' are not part of the language Pascal. |
| 36 | If they are found in the source program, |
| 37 | and are not part of a constant string, a constant character, or a comment, |
| 38 | they are considered to be |
| 39 | `illegal characters'. |
| 40 | This can happen if you leave off an opening string quote `\(aa'. |
| 41 | Note that the character `"', although used in English to quote strings, |
| 42 | is not used to quote strings in Pascal. |
| 43 | Most non-printing characters in your input are also illegal except |
| 44 | in character constants and character strings. |
| 45 | Except for the tab and form feed characters, |
| 46 | which are used to ease formatting of the program, |
| 47 | non-printing characters in the input file print as the character `?' |
| 48 | so that they will show in your listing. |
| 49 | .SH |
| 50 | String errors |
| 51 | .PP |
| 52 | There is no character string of length 0 in Pascal. |
| 53 | Consequently the input `\(aa\(aa' is not acceptable. |
| 54 | Similarly, encountering an end-of-line after an opening string quote `\(aa' |
| 55 | without encountering the matching closing quote yields the diagnostic |
| 56 | ``Unmatched \(aa for string''. |
| 57 | It is permissible to use the character `#' |
| 58 | instead of `\'' |
| 59 | to delimit character and constant strings for portability reasons. |
| 60 | For this reason, a spuriously placed `#' sometimes causes the diagnostic |
| 61 | about unbalanced quotes. |
| 62 | Similarly, a `#' in column one is used when preparing programs which are to |
| 63 | be kept in multiple files. |
| 64 | See section 5.9 for details. |
| 65 | .SH |
| 66 | Comments in a comment, non-terminated comments |
| 67 | .PP |
| 68 | As we saw above, these errors are usually caused by leaving off a comment |
| 69 | delimiter. |
| 70 | You can convert parts of your program to comments |
| 71 | without generating this diagnostic |
| 72 | since there are two different kinds of comments \- those delimited by |
| 73 | `{' and `}', and those delimited by `(*' and `*)'. |
| 74 | Thus consider: |
| 75 | .LS |
| 76 | { This is a comment enclosing a piece of program |
| 77 | a := functioncall; (* comment within comment *) |
| 78 | procedurecall; |
| 79 | lhs := rhs; (* another comment *) |
| 80 | } |
| 81 | .LE |
| 82 | .PP |
| 83 | By using one kind of comment exclusively in your program you can use |
| 84 | the other delimiters when you need to |
| 85 | ``comment out'' |
| 86 | parts of your program\*(dg. |
| 87 | .FS |
| 88 | \*(dgIf you wish to transport your program, |
| 89 | especially to the 6000-3.4 implementation, |
| 90 | you should use the character sequence `(*' to delimit comments. |
| 91 | For transportation over the |
| 92 | .I rcslink |
| 93 | to Pascal 6000-3.4, the character `#' should be used to delimit characters |
| 94 | and constant strings. |
| 95 | .FE |
| 96 | In this way you will also allow the translator to help by detecting |
| 97 | statements accidentally placed within comments. |
| 98 | .PP |
| 99 | If a comment does not terminate before the end of the input file, |
| 100 | the translator will point to the beginning of the comment, |
| 101 | indicating that the comment is not terminated. |
| 102 | In this case processing will terminate immediately. |
| 103 | See the discussion of ``QUIT'' below. |
| 104 | .SH |
| 105 | Digits in numbers |
| 106 | .PP |
| 107 | This part of the language is a minor nuisance. |
| 108 | Pascal requires digits in real numbers both before and after the decimal |
| 109 | point. |
| 110 | Thus the following statements, which look quite reasonable to |
| 111 | .SM |
| 112 | FORTRAN |
| 113 | .NL |
| 114 | users, generate diagnostics in Pascal: |
| 115 | .LS |
| 116 | .so digitsout |
| 117 | .LE |
| 118 | These same constructs are also illegal as input to the Pascal interpreter |
| 119 | .I px . |
| 120 | .SH |
| 121 | Replacements, insertions, and deletions |
| 122 | .PP |
| 123 | When a syntax error is encountered in the input text, |
| 124 | the parser invokes an error recovery procedure. |
| 125 | This procedure examines the input text immediately after the point |
| 126 | of error and considers a set of simple corrections to see whether they |
| 127 | will allow the analysis to continue. |
| 128 | These corrections involve replacing an input token with a different |
| 129 | token, |
| 130 | inserting a token, |
| 131 | or replacing an input token with a different token. |
| 132 | Most of these changes will not cause fatal syntax errors. |
| 133 | The exception is the insertion of or replacement with a symbol |
| 134 | such as an identifier or a number; |
| 135 | in this case the recovery makes no attempt to determine |
| 136 | .I which |
| 137 | identifier or |
| 138 | .I what |
| 139 | number should be inserted, |
| 140 | hence these are considered fatal syntax errors. |
| 141 | .PP |
| 142 | Consider the following example. |
| 143 | .LS |
| 144 | % \*bpix -l synerr.p\fR |
| 145 | .tr -- |
| 146 | .so synerrout |
| 147 | % |
| 148 | .LE |
| 149 | The only surprise here may be that Pascal does not have an exponentiation |
| 150 | operator, hence the complaint about `**'. |
| 151 | This error illustrates that, if you assume that the language has a feature |
| 152 | which it does not, the translator diagnostic may not indicate this, |
| 153 | as the translator is unlikely to recognize the construct you supply. |
| 154 | .SH |
| 155 | Undefined or improper identifiers |
| 156 | .PP |
| 157 | If an identifier is encountered in the input but is undefined, |
| 158 | the error recovery will replace it with an identifier of the |
| 159 | appropriate class. |
| 160 | Further references to this identifier will be summarized at the |
| 161 | end of the containing |
| 162 | .B procedure |
| 163 | or |
| 164 | .B function |
| 165 | or at the end of the |
| 166 | .B program |
| 167 | if the reference occurred in the main program. |
| 168 | Similarly, |
| 169 | if an identifier is used in an inappropriate way, |
| 170 | e.g. if a |
| 171 | .B type |
| 172 | identifier is used in an assignment statement, |
| 173 | or if a simple variable |
| 174 | is used where a |
| 175 | .B record |
| 176 | variable is required, |
| 177 | a diagnostic will be produced and an identifier of the appropriate |
| 178 | type inserted. |
| 179 | Further incorrect references to this identifier will be flagged only |
| 180 | if they involve incorrect use in a different way, |
| 181 | with all incorrect uses being summarized in the same way as undefined |
| 182 | variable uses are. |
| 183 | .SH |
| 184 | Expected symbols, malformed constructs |
| 185 | .PP |
| 186 | If none of the above mentioned corrections appear reasonable, the |
| 187 | error recovery will examine the input |
| 188 | to the left of the point of error to see if there is only one symbol |
| 189 | which can follow this input. |
| 190 | If this is the case, the recovery will print a diagnostic which |
| 191 | indicates that the given symbol was `Expected'. |
| 192 | .PP |
| 193 | In cases where none of these corrections resolve the problems |
| 194 | in the input, |
| 195 | the recovery may issue a diagnostic that indicates that the |
| 196 | input is ``malformed''. |
| 197 | If necessary, the translator may then skip forward in the input to |
| 198 | a place where analysis can continue. |
| 199 | This process may cause some errors in the text to be missed. |
| 200 | .PP |
| 201 | Consider the following example: |
| 202 | .LS |
| 203 | % \*bpix -l synerr2.p\fR |
| 204 | .so synerr2out |
| 205 | % |
| 206 | .LE |
| 207 | Here we misspelled |
| 208 | .I input |
| 209 | and gave a |
| 210 | .SM FORTRAN |
| 211 | style variable declaration |
| 212 | which the translator diagnosed as a `Malformed declaration'. |
| 213 | When, on line 6, we used `(' and `)' for subscripting |
| 214 | (as in |
| 215 | .SM FORTRAN ) |
| 216 | rather than the `[' and `]' which are used in Pascal, |
| 217 | the translator noted that |
| 218 | .I a |
| 219 | was not defined as a |
| 220 | .B procedure . |
| 221 | This occurred because |
| 222 | .B procedure |
| 223 | and |
| 224 | .B function |
| 225 | argument lists are delimited by parentheses in Pascal. |
| 226 | As it is not permissible to assign to procedure calls the translator |
| 227 | diagnosed a malformed statement at the point of assignment. |
| 228 | .SH |
| 229 | Expected and unexpected end-of-file, ``QUIT'' |
| 230 | .PP |
| 231 | If the translator finds a complete program, but there is more non-comment text |
| 232 | in the input file, then it will indicate that an end-of-file was expected. |
| 233 | This situation may occur after a bracketing error, or if too many |
| 234 | .B end s |
| 235 | are present in the input. |
| 236 | The message may appear |
| 237 | after the recovery says that it |
| 238 | ``Expected \`.\'\|'' |
| 239 | since `.' is the symbol that terminates a program. |
| 240 | .PP |
| 241 | If severe errors in the input prohibit further processing |
| 242 | the translator may produce a diagnostic followed by ``QUIT''. |
| 243 | One example of this was given above \- |
| 244 | a non-terminated comment; |
| 245 | another example is a line which is longer than 160 |
| 246 | characters. |
| 247 | Consider also the following example. |
| 248 | .LS |
| 249 | % \*bpix -l mism.p\fR |
| 250 | .so mismout |
| 251 | % |
| 252 | .LE |
| 253 | .NH 2 |
| 254 | Translator semantic errors |
| 255 | .PP |
| 256 | The extremely large number of semantic diagnostic messages which the translator |
| 257 | produces make it unreasonable to discuss each message or group of messages |
| 258 | in detail. |
| 259 | The messages are, however, very informative. |
| 260 | We will here explain the typical formats and the terminology used in the error |
| 261 | messages so that you will be able to make sense out of them. |
| 262 | In any case in which a diagnostic is not completely comprehensible you can |
| 263 | refer to the |
| 264 | .I "User Manual" |
| 265 | by Jensen and Wirth for examples. |
| 266 | .SH |
| 267 | Format of the error diagnostics |
| 268 | .PP |
| 269 | As we saw in the example program above, the error diagnostics from |
| 270 | the Pascal translator include the number of a line in the text of the program |
| 271 | as well as the text of the error message. |
| 272 | While this number is most often the line where the error occurred, it |
| 273 | is occasionally the number of a line containing a bracketing keyword |
| 274 | like |
| 275 | .B end |
| 276 | or |
| 277 | .B until . |
| 278 | In this case, the diagnostic may refer to the previous statement. |
| 279 | This occurs because of the method the translator uses for sampling line |
| 280 | numbers. |
| 281 | The absence of a trailing `;' in the previous statement causes the line |
| 282 | number corresponding to the |
| 283 | .B end |
| 284 | or |
| 285 | .B until . |
| 286 | to become associated with the statement. |
| 287 | As Pascal is a free-format language, the line number associations |
| 288 | can only be approximate and may seem arbitrary to some users. |
| 289 | This is the only notable exception, however, to reasonable associations. |
| 290 | .SH |
| 291 | Incompatible types |
| 292 | .PP |
| 293 | Since Pascal is a strongly typed language, many semantic errors manifest |
| 294 | themselves as type errors. |
| 295 | These are called `type clashes' by the translator. |
| 296 | The types allowed for various operators in the language are summarized on page |
| 297 | 108 of the |
| 298 | Jensen-Wirth |
| 299 | .I "User Manual" . |
| 300 | It is important to know that the Pascal translator, in its diagnostics, |
| 301 | distinguishes between the following type `classes': |
| 302 | .br |
| 303 | .ne 8 |
| 304 | .TS |
| 305 | center; |
| 306 | lew(10) le le le le. |
| 307 | array Boolean char file integer |
| 308 | pointer real record scalar string |
| 309 | .TE |
| 310 | These words are plugged into a great number of error messages. |
| 311 | Thus, if you tried to assign an |
| 312 | .I integer |
| 313 | value to a |
| 314 | .I char |
| 315 | variable you would receive a diagnostic like the following: |
| 316 | .LS |
| 317 | .so clashout |
| 318 | .LE |
| 319 | In this case, one error produced a two line error message. |
| 320 | If the same error occurs more than once, the same explanatory |
| 321 | diagnostic will be given each time. |
| 322 | .SH |
| 323 | Scalar |
| 324 | .PP |
| 325 | The only class whose meaning is not self-explanatory is |
| 326 | `scalar'. |
| 327 | Scalar has a precise meaning in the |
| 328 | Jensen-Wirth |
| 329 | .I "User Manual" |
| 330 | where, in fact, it refers to |
| 331 | .I char , |
| 332 | .I integer , |
| 333 | .I real , |
| 334 | and |
| 335 | .I Boolean |
| 336 | types as well as the enumerated types. |
| 337 | For the purposes of the Pascal translator, |
| 338 | scalar |
| 339 | in an error message refers to a user-defined, enumerated |
| 340 | type, such as |
| 341 | .I ops |
| 342 | in the example above or |
| 343 | .I color |
| 344 | in |
| 345 | .LS |
| 346 | \*btype\fP color = (red, green, blue) |
| 347 | .LE |
| 348 | For integers, the more explicit denotation |
| 349 | .I integer |
| 350 | is used. |
| 351 | Although it would be correct, in the context of the |
| 352 | .I "User Manual" |
| 353 | to refer to an integer variable as a |
| 354 | .I scalar |
| 355 | variable |
| 356 | .PI |
| 357 | prefers the more specific identification. |
| 358 | .SH |
| 359 | Function and procedure type errors |
| 360 | .PP |
| 361 | For built-in procedures and functions, two kinds of errors occur. |
| 362 | If the routines are called with the wrong number of arguments a message similar to: |
| 363 | .LS |
| 364 | .so sinout1 |
| 365 | .LE |
| 366 | is given. |
| 367 | If the type of the argument is wrong, a message like |
| 368 | .LS |
| 369 | .so sinout2 |
| 370 | .LE |
| 371 | is produced. |
| 372 | A few functions and procedures implemented in Pascal 6000-3.4 are |
| 373 | diagnosed as unimplemented in |
| 374 | Berkeley |
| 375 | Pascal, notably those related to |
| 376 | .B segmented |
| 377 | files. |
| 378 | .SH |
| 379 | Can't read and write scalars, etc. |
| 380 | .PP |
| 381 | The messages which state that scalar (user-defined) types |
| 382 | cannot be written to and from files are often mysterious. |
| 383 | It is in fact the case that if you define |
| 384 | .LS |
| 385 | \*btype\fP color = (red, green, blue) |
| 386 | .LE |
| 387 | the translator does not associate these constants with the strings |
| 388 | `red', `green', and `blue' in any way. |
| 389 | If you wish such an association to be made, you will have to write a routine |
| 390 | to make it. |
| 391 | Note, in particular, that you can only read characters, integers and real |
| 392 | numbers from text files. |
| 393 | You cannot read strings or Booleans. |
| 394 | It is possible to make a |
| 395 | .LS |
| 396 | \*bfile of\fP color |
| 397 | .LE |
| 398 | but the representation is binary rather than string. |
| 399 | .SH |
| 400 | Expression diagnostics |
| 401 | .PP |
| 402 | The diagnostics for semantically ill-formed expressions are very explicit. |
| 403 | Consider this sample translation: |
| 404 | .LS |
| 405 | % \*bpi -l expr.p\fP |
| 406 | .so exprout |
| 407 | % |
| 408 | .LE |
| 409 | This example is admittedly far-fetched, but illustrates that the error |
| 410 | messages are sufficiently clear to allow easy determination of the |
| 411 | problem in the expressions. |
| 412 | .SH |
| 413 | Type equivalence |
| 414 | .PP |
| 415 | Several diagnostics produced by the Pascal translator complain about |
| 416 | `non-equivalent types'. |
| 417 | In general, |
| 418 | Berkeley |
| 419 | Pascal considers variables to have the same type only if they were |
| 420 | declared with the same constructed type or with the same type identifier. |
| 421 | Thus, the variables |
| 422 | .I x |
| 423 | and |
| 424 | .I y |
| 425 | declared as |
| 426 | .LS |
| 427 | \*bvar\fP |
| 428 | x: ^ integer; |
| 429 | y: ^ integer; |
| 430 | .LE |
| 431 | do not have the same type. |
| 432 | The assignment |
| 433 | .LS |
| 434 | x := y |
| 435 | .LE |
| 436 | thus produces the diagnostics: |
| 437 | .LS |
| 438 | .so typequout |
| 439 | .LE |
| 440 | Thus it is always necessary to declare a type such as |
| 441 | .LS |
| 442 | \*btype\fP intptr = ^ integer; |
| 443 | .LE |
| 444 | and use it to declare |
| 445 | .LS |
| 446 | \*bvar\fP x: intptr; y: intptr; |
| 447 | .LE |
| 448 | Note that if we had initially declared |
| 449 | .LS |
| 450 | \*bvar\fP x, y: ^ integer; |
| 451 | .LE |
| 452 | then the assignment statement would have worked. |
| 453 | The statement |
| 454 | .LS |
| 455 | x^ := y^ |
| 456 | .LE |
| 457 | is allowed in either case. |
| 458 | Since the parameter to a |
| 459 | .B procedure |
| 460 | or |
| 461 | .B function |
| 462 | must be declared with a |
| 463 | type identifier rather than a constructed type, |
| 464 | it is always necessary, in practice, |
| 465 | to declare any type which will be used in this way. |
| 466 | .SH |
| 467 | Unreachable statements |
| 468 | .PP |
| 469 | Berkeley |
| 470 | Pascal flags unreachable statements. |
| 471 | Such statements usually correspond to errors in the program logic. |
| 472 | Note that a statement is considered to be reachable |
| 473 | if there is a potential path of control, |
| 474 | even if it can never be taken. |
| 475 | Thus, no diagnostic is produced for the statement: |
| 476 | .LS |
| 477 | \*bif\fP false \*bthen\fP |
| 478 | writeln('impossible!') |
| 479 | .LE |
| 480 | .SH |
| 481 | Goto's into structured statements |
| 482 | .PP |
| 483 | The translator detects and complains about |
| 484 | .B goto |
| 485 | statements which transfer control into structured statements (\c |
| 486 | .B for , |
| 487 | .B while , |
| 488 | etc.) |
| 489 | It does not allow such jumps, nor does it allow branching from the |
| 490 | .B then |
| 491 | part of an |
| 492 | .B if |
| 493 | statement into the |
| 494 | .B else |
| 495 | part. |
| 496 | Such checks are made only within the body of a single procedure or |
| 497 | function. |
| 498 | .SH |
| 499 | Unused variables, never set variables |
| 500 | .PP |
| 501 | Although |
| 502 | Berkeley |
| 503 | Pascal always clears variables to 0 at |
| 504 | .B procedure |
| 505 | and |
| 506 | .B function |
| 507 | entry, it is |
| 508 | .B not |
| 509 | good programming practice to rely on this initialization. |
| 510 | To discourage this practice, and to help detect errors in program logic, |
| 511 | .PI |
| 512 | flags as a `w' warning error: |
| 513 | .IP |
| 514 | .RS |
| 515 | .HP 1) |
| 516 | Use of a variable which is never assigned a value. |
| 517 | .IP 2) |
| 518 | A variable which is declared but never used, distinguishing |
| 519 | between those variables for which values are computed but which are never |
| 520 | used, and those completely unused. |
| 521 | .RE |
| 522 | .LP |
| 523 | In fact, these diagnostics are applied to all declared items. |
| 524 | Thus a |
| 525 | .B constant |
| 526 | or a |
| 527 | .B procedure |
| 528 | which is declared but never used is flagged. |
| 529 | The |
| 530 | .B w |
| 531 | option of |
| 532 | .PI |
| 533 | may be used to suppress these warnings; |
| 534 | see sections 5.1 and 5.2. |
| 535 | .NH 2 |
| 536 | Translator panics, i/o errors |
| 537 | .SH |
| 538 | Panics |
| 539 | .PP |
| 540 | One class of error which rarely occurs, but which causes termination |
| 541 | of all processing when it does is a panic. |
| 542 | A panic indicates a translator-detected internal inconsistency. |
| 543 | A typical panic message is: |
| 544 | .LS |
| 545 | snark (rvalue) line=110 yyline=109 |
| 546 | Snark in pi |
| 547 | .LE |
| 548 | If you receive such a message, the translation will be quickly and perhaps |
| 549 | ungracefully terminated. |
| 550 | You should contact a teaching assistant or a member of the system staff, |
| 551 | after saving a copy of your program for later inspection. |
| 552 | If you were making changes to an existing program when the problem |
| 553 | occurred, you may |
| 554 | be able to work around the problem by ascertaining which change caused the |
| 555 | .I snark |
| 556 | and making a different change or correcting an error in the program. |
| 557 | You should report the problem in any case. |
| 558 | Pascal system bugs cannot be fixed unless they are reported. |
| 559 | .SH |
| 560 | Out of memory |
| 561 | .PP |
| 562 | The only other error which will abort translation when no errors are |
| 563 | detected is running out of memory. |
| 564 | All tables in the translator, with the exception of the parse stack, |
| 565 | are dynamically allocated, and can grow to take up the full available |
| 566 | process space of 64000 bytes. |
| 567 | Generally, the size of the largest translatable program is directly related to |
| 568 | .B procedure |
| 569 | and |
| 570 | .B function |
| 571 | size. |
| 572 | A number of non-trivial Pascal programs, including |
| 573 | some with more than 2000 lines and 2500 statements |
| 574 | have been translated and interpreted using |
| 575 | Berkeley |
| 576 | Pascal. |
| 577 | Notable among these are the Pascal-S |
| 578 | interpreter, |
| 579 | a large set of programs for automated generation of |
| 580 | code generators, |
| 581 | and a general context-free parsing program which has been used to |
| 582 | parse sentences with a grammar for a superset of English. |
| 583 | .PP |
| 584 | If you receive an out of space message from the translator |
| 585 | during translation of a large |
| 586 | .B procedure |
| 587 | or |
| 588 | .B function |
| 589 | or one containing a large number of string constants |
| 590 | you may yet be able |
| 591 | to translate your program if you break this one |
| 592 | .B procedure |
| 593 | or |
| 594 | .B function |
| 595 | into several routines. |
| 596 | .SH |
| 597 | I/O errors |
| 598 | .PP |
| 599 | Other errors which you may encounter when running |
| 600 | .PI |
| 601 | relate to input-output. |
| 602 | If |
| 603 | .PI |
| 604 | cannot open the file you specify, |
| 605 | or if the file is empty, |
| 606 | you will be so informed. |
| 607 | If your disk space quota\*(dg is exceeded while |
| 608 | .PI |
| 609 | is creating the file |
| 610 | .I obj , |
| 611 | or if the system runs out of disk space you will be notified; |
| 612 | in this case you should remove unneeded files. |
| 613 | .FS |
| 614 | \*(dgDisk quotas are also a modification at Berkeley |
| 615 | and may not exist at your installation. |
| 616 | .FE |
| 617 | .NH 2 |
| 618 | Run-time errors |
| 619 | .PP |
| 620 | We saw, in our second example, a run-time error. |
| 621 | We here give the general description of run-time errors. |
| 622 | The more unusual interpreter error messages are explained |
| 623 | briefly in the manual section for |
| 624 | .I px |
| 625 | (6). |
| 626 | .SH |
| 627 | Start-up errors |
| 628 | .PP |
| 629 | These errors occur when the object file to be executed is not available |
| 630 | or appropriate. |
| 631 | Typical errors here are caused by the specified object file not existing, |
| 632 | not being a Pascal object, or being inaccessible to the user. |
| 633 | .SH |
| 634 | Program execution errors |
| 635 | .PP |
| 636 | These errors occur when the program interacts with the Pascal runtime |
| 637 | environment in an inappropriate way. |
| 638 | Typical errors are values or subscripts out of range, |
| 639 | bad arguments to built-in functions, |
| 640 | exceeding the statement limit because of an infinite loop, |
| 641 | or running out of memory\*(dd. |
| 642 | .FS |
| 643 | \*(ddThe checks for running out of memory are not foolproof and there |
| 644 | is a chance that the interpreter will fault, producing a core image |
| 645 | when it runs out of memory. |
| 646 | This situation occurs very rarely. |
| 647 | .FE |
| 648 | The interpreter will produce a backtrace after the error occurs, |
| 649 | showing all the active routine calls, |
| 650 | unless the |
| 651 | .B p |
| 652 | option was disabled when the program was translated. |
| 653 | Unfortunately, no variable values are given and no way of extracting them |
| 654 | is available. |
| 655 | .PP |
| 656 | As an example of such an error, assume that we have accidentally |
| 657 | declared the constant |
| 658 | .I n1 |
| 659 | to be 6, instead of 7 |
| 660 | on line 2 of the program primes as given in section 2.6 above. |
| 661 | If we run this program we get the following response. |
| 662 | .LS |
| 663 | % \*bpix primes.p\fP |
| 664 | .so primeout3 |
| 665 | % |
| 666 | .LE |
| 667 | .PP |
| 668 | Here the interpreter indicates that the program terminated |
| 669 | abnormally due to a subscript out of range near line 14, |
| 670 | which is eight lines into the body of the program primes. |
| 671 | .SH |
| 672 | Interrupts |
| 673 | .PP |
| 674 | If the program is interrupted while executing |
| 675 | and the |
| 676 | .B p |
| 677 | option was not specified, |
| 678 | then a backtrace will be printed.\*(dg |
| 679 | .FS |
| 680 | \*(dgOccasionally, the Pascal system will be in an inconsistent |
| 681 | state when this occurs, |
| 682 | e.g. when an interrupt terminates a |
| 683 | .B procedure |
| 684 | or |
| 685 | .B function |
| 686 | entry or exit. |
| 687 | In this case, the backtrace will only contain the current line. |
| 688 | A reverse call order list of procedures will not be given. |
| 689 | .FE |
| 690 | The file |
| 691 | .I pmon.out |
| 692 | of profile information will be written if the program was translated |
| 693 | with the |
| 694 | .B z |
| 695 | option enabled to |
| 696 | .PI |
| 697 | or |
| 698 | .IX . |
| 699 | .SH |
| 700 | I/O interaction errors |
| 701 | .PP |
| 702 | The final class of interpreter errors results from inappropriate |
| 703 | interactions with files, including the user's terminal. |
| 704 | Included here are bad formats for integer and real numbers (such as |
| 705 | no digits after the decimal point) when reading. |
| 706 | .SH |
| 707 | Panics |
| 708 | .PP |
| 709 | A small number of panics are possible with |
| 710 | .I px . |
| 711 | These should be reported to a teaching assistant or to the system |
| 712 | staff if they occur. |