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