home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / share / doc / ps1 / 04.pascal / puman5.n < prev    next >
Encoding:
Text File  |  1991-04-17  |  22.0 KB  |  941 lines

  1. .\" Copyright (c) 1980 The Regents of the University of California.
  2. .\" All rights reserved.
  3. .\"
  4. .\" Redistribution and use in source and binary forms, with or without
  5. .\" modification, are permitted provided that the following conditions
  6. .\" are met:
  7. .\" 1. Redistributions of source code must retain the above copyright
  8. .\"    notice, this list of conditions and the following disclaimer.
  9. .\" 2. Redistributions in binary form must reproduce the above copyright
  10. .\"    notice, this list of conditions and the following disclaimer in the
  11. .\"    documentation and/or other materials provided with the distribution.
  12. .\" 3. All advertising materials mentioning features or use of this software
  13. .\"    must display the following acknowledgement:
  14. .\"    This product includes software developed by the University of
  15. .\"    California, Berkeley and its contributors.
  16. .\" 4. Neither the name of the University nor the names of its contributors
  17. .\"    may be used to endorse or promote products derived from this software
  18. .\"    without specific prior written permission.
  19. .\"
  20. .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  21. .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  24. .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25. .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26. .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27. .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28. .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29. .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. .\" SUCH DAMAGE.
  31. .\"
  32. .\"    @(#)puman5.n    6.3 (Berkeley) 4/17/91
  33. .\"
  34. .if !\n(xx \{\
  35. .so tmac.p \}
  36. .ND
  37. .nr H1 4
  38. .NH
  39. Details on the components of the system
  40. .NH 2
  41. Options
  42. .PP
  43. The programs
  44. .PI ,
  45. .PC ,
  46. and
  47. .XP
  48. take a number of options.\*(dg
  49. .FS
  50. \*(dgAs
  51. .IX
  52. uses
  53. .PI
  54. to translate Pascal programs,
  55. it takes the options of
  56. .PI
  57. also.
  58. We refer to them here, however, as
  59. .PI
  60. options.
  61. .FE
  62. There is a standard
  63. .UX
  64. convention for passing options to programs on the command line,
  65. and this convention is followed by the
  66. .UP
  67. system programs.
  68. As we saw in the examples above,
  69. option related arguments consisted of the character `\-' followed
  70. by a single character option name.
  71. .PP
  72. Except for the
  73. .B b
  74. option
  75. which takes a single digit value,
  76. each option may be set on (enabled)
  77. or off (disabled.)
  78. When an on/off valued option appears on the command line of
  79. .PI
  80. or
  81. .PX
  82. it inverts the default setting of that option.
  83. Thus
  84. .LS
  85. % \*bpi -l foo.p\fR
  86. .LE
  87. enables the listing option
  88. .B l ,
  89. since it defaults off, while
  90. .LS
  91. % \*bpi -t foo.p\fR
  92. .LE
  93. disables the run time tests option
  94. .B t ,
  95. since it defaults on.
  96. .PP
  97. In additon to inverting the default settings of
  98. .PI
  99. options on the command line, it is also possible to control the
  100. .PI
  101. options 
  102. within the body of the program by using comments of a special
  103. form illustrated by
  104. .LS
  105. {$l-}
  106. .LE
  107. .PP
  108. Here we see that the opening comment delimiter (which could also be a `(*')
  109. is immediately followed by the character `$'.
  110. After this `$', which signals the start of the option list,
  111. we can place a sequence of letters and option controls, separated by `,'
  112. characters\*(dd.
  113. .FS
  114. \*(ddThis format was chosen because it is used by Pascal 6000-3.4.
  115. In general the options common to both implementations are controlled
  116. in the same way so that comment control in options is mostly
  117. portable.
  118. It is recommended, however, that only one control be put per comment for
  119. maximum portability, as the Pascal 6000-3.4
  120. implementation will ignore controls
  121. after the first one which it does not recognize.
  122. .FE
  123. The most basic actions for options are to set them, thus
  124. .LS
  125. {$l+ Enable listing}
  126. .LE
  127. or to clear them
  128. .LS
  129. {$t-,p- No run-time tests, no post mortem analysis}
  130. .LE
  131. Notice that `+' always enables an option and `\-' always disables it,
  132. no matter what the default is.
  133. Thus `\-' has a different meaning in an option comment than it has on the
  134. command line.
  135. As shown in the examples,
  136. normal comment text may follow the option list.
  137. .NH 2
  138. Options common to Pi, Pc, and Pix
  139. .PP
  140. The following options are common to both the compiler
  141. and the interpreter.
  142. With each option we give its default setting,
  143. the setting it would have if it appeared on the command line,
  144. and a sample command using the option.
  145. Most options are on/off valued,
  146. with the
  147. .B b
  148. option
  149. taking a single digit value.
  150. .SH
  151. Buffering of the file output \- b
  152. .PP
  153. The
  154. .B b
  155. option controls the buffering of the file
  156. .I output .
  157. The default is line buffering, with flushing at
  158. each reference to the file
  159. .I input
  160. and under certain other circumstances detailed in section 5
  161. below.
  162. Mentioning
  163. .B b
  164. on the command line, e.g.
  165. .LS
  166. % \*bpi -b assembler.p\fR
  167. .LE
  168. causes standard output to be block buffered,
  169. where a block is some system\-defined number of characters.
  170. The
  171. .B b
  172. option may also be controlled in comments.
  173. It, unique among the
  174. .UP
  175. options,
  176. takes a single digit value rather than an on or off setting.
  177. A value of 0, e.g.
  178. .LS
  179.     {$b0}
  180. .LE
  181. causes the file
  182. .I output
  183. to be unbuffered.
  184. Any value 2 or greater causes block buffering and is equivalent
  185. to the flag on the command line.
  186. The option control comment setting
  187. .B b
  188. must precede the
  189. .B program
  190. statement.
  191. .SH
  192. Include file listing \- i
  193. .PP
  194. The
  195. .B i
  196. option takes the name of an
  197. .B include
  198. file,
  199. .B procedure
  200. or
  201. .B function
  202. name and causes it
  203. to be listed while translating\*(dg.
  204. .FS
  205. \*(dg\*bInclude\fR files are discussed in section 5.9.
  206. .FE
  207. Typical uses would be
  208. .LS
  209. % \*bpix -i scanner.i compiler.p\fR
  210. .LE
  211. to make a listing of the routines in the file scanner.i, and
  212. .LS
  213. % \*bpix -i scanner compiler.p\fR
  214. .LE
  215. to make a listing of only the routine
  216. .I scanner .
  217. This option is especially useful for conservation-minded programmers making
  218. partial program listings.
  219. .SH
  220. Make a listing \- l
  221. .PP
  222. The
  223. .B l
  224. option enables a listing of the program.
  225. The
  226. .B l
  227. option defaults off.
  228. When specified on the command line, it causes
  229. a header line identifying the version of the translator in use
  230. and a line giving the modification time of the file being translated
  231. to appear before the actual program listing.
  232. The
  233. .B l
  234. option is pushed and popped by the
  235. .B i
  236. option at appropriate points in the program.
  237. .SH
  238. Standard Pascal only \- s
  239. .PP
  240. The
  241. .B s
  242. option causes many of the features of the
  243. .SM UNIX
  244. implementation which are not found in standard Pascal
  245. to be diagnosed as `s' warning errors.
  246. This option defaults off and is enabled when mentioned on the command line.
  247. Some of the features which are diagnosed are:
  248. non-standard
  249. .B procedure s
  250. and
  251. .B function s,
  252. extensions to the
  253. .B procedure
  254. .I write ,
  255. and the padding of constant strings with blanks.
  256. In addition, all letters are mapped to lower case except in
  257. strings and characters so that the case of keywords and identifiers
  258. is effectively ignored.
  259. The
  260. .B s
  261. option is most useful when a program is to be transported, thus
  262. .LS
  263. % \*bpi -s isitstd.p\fR
  264. .LE
  265. will produce warnings unless the program meets the standard.
  266. .SH
  267. Runtime tests \- t and C
  268. .PP
  269. These
  270. options control the generation of tests that subrange variable
  271. values are within bounds at run time.
  272. .PI
  273. defaults to generating tests and uses the option
  274. .B t
  275. to disable them.
  276. .PC
  277. defaults to not generating tests,
  278. and uses the option
  279. .B C
  280. to enable them.
  281. Disabling runtime tests also causes
  282. .B assert
  283. statements to be treated as comments.\*(dd
  284. .FS
  285. \*(ddSee section A.1 for a description of
  286. .B assert
  287. statements.
  288. .FE
  289. .SH
  290. Suppress warning diagnostics \- w
  291. .PP
  292. The
  293. .B w
  294. option, which defaults on,
  295. allows the translator to print a number of warnings about inconsistencies
  296. it finds in the input program.
  297. Turning this option off with a comment of the form
  298. .LS
  299. {$w-}
  300. .LE
  301. or on the command line
  302. .LS
  303. % \*bpi -w tryme.p\fR
  304. .LE
  305. suppresses these usually useful diagnostics.
  306. .SH
  307. Generate counters for a pxp execution profile \- z
  308. .PP
  309. The
  310. .B z
  311. option, which defaults off,
  312. enables the production of execution profiles.
  313. By specifying
  314. .B z
  315. on the command line, i.e.
  316. .LS
  317. % \*bpi -z foo.p\fR
  318. .LE
  319. or by enabling it in a comment before the
  320. .B program
  321. statement causes
  322. .PI
  323. and
  324. .PC
  325. to insert operations in the interpreter code to
  326. count the number of times each statement was executed.
  327. An example of using
  328. .XP
  329. was given in section 2.6;
  330. its options are described in section 5.6.
  331. Note that the
  332. .B z
  333. option cannot be used on separately compiled programs.
  334. .NH 2
  335. Options available in Pi
  336. .SH
  337. Post-mortem dump \- p
  338. .PP
  339. The
  340. .B p
  341. option defaults on,
  342. and causes the runtime system to initiate a post-mortem
  343. backtrace when an error occurs.
  344. It also cause
  345. .X
  346. to count statements in the executing program,
  347. enforcing a statement limit to prevent infinite loops.
  348. Specifying
  349. .B p
  350. on the command line disables these checks and the ability
  351. to give this post-mortem analysis.
  352. It does make smaller and faster programs, however.
  353. It is also possible to control the
  354. .B p
  355. option in comments.
  356. To prevent the post-mortem backtrace on error,
  357. .B p
  358. must be off at the end of the
  359. .B program
  360. statement.
  361. Thus, the Pascal cross-reference program was translated with
  362. .LS
  363. % \*bpi -pbt pxref.p\fR
  364. .LE
  365. .NH 2
  366. Options available in Px
  367. .PP
  368. The first argument to
  369. .X
  370. is the name of the file containing the program to be interpreted.
  371. If no arguments are given, then the file
  372. .I obj
  373. is executed.
  374. If more arguments are given, they are available to the Pascal
  375. program by using the built-ins
  376. .I argc
  377. and
  378. .I argv
  379. as described in section 4.6.
  380. .ne 7
  381. .PP
  382. .I Px
  383. may also be invoked automatically.
  384. In this case, whenever a Pascal object file name is given as a command,
  385. the command will be executed with
  386. .X
  387. prepended to it; that is
  388. .LS
  389. % \*bobj primes\fR
  390. .LE
  391. will be converted to read
  392. .LS
  393. % \*bpx obj primes\fR
  394. .LE
  395. .NH 2
  396. Options available in Pc
  397. .SH
  398. Generate assembly language \- S
  399. .PP
  400. The program is compiled and the assembly language
  401. output is left in file appended .s.
  402. Thus
  403. .LS
  404. % \*bpc -S foo.p\fR
  405. .LE
  406. creates a file
  407. .I foo.s .
  408. No executable file is created.
  409. .SH
  410. Symbolic Debugger Information \- g
  411. .PP
  412. The
  413. .B g
  414. option causes the compiler to generate information
  415. needed by
  416. .I sdb (1)
  417. the symbolic debugger.
  418. For a complete description of
  419. .I sdb
  420. see Volume 2c of the
  421. .UX
  422. Reference Manual.
  423. .SH
  424. Redirect the output file \- o
  425. .PP
  426. The
  427. .I name
  428. argument after the
  429. .B -o
  430. is used as the name of the output file instead of
  431. .I a.out .
  432. Its typical use is to name the compiled program using
  433. the root of the file name.
  434. Thus:
  435. .LS
  436. % \*bpc -o myprog myprog.p\fR
  437. .LE
  438. causes the compiled program to be called
  439. .I myprog .
  440. .SH
  441. Generate counters for a \*iprof\fP execution profile \- p
  442. .PP
  443. The compiler produces code which counts the number of times each
  444. routine is called.
  445. The profiling is based on a periodic sample taken by the
  446. system rather than by inline counters used by
  447. .XP .
  448. This results in less degradation in execution,
  449. at somewhat of a loss in accuracy.
  450. See
  451. .I prof (1)
  452. for a more complete description.
  453. .SH
  454. Run the object code optimizer \- O
  455. .PP
  456. The output of the compiler is run through
  457. the object code optimizer.
  458. This provides an increase in compile time in
  459. exchange for a decrease in compiled code size
  460. and execution time.
  461. .NH 2
  462. Options available in Pxp
  463. .PP
  464. .I Pxp
  465. takes, on its command line, a list of options followed by the program file
  466. name, which must end in `.p' as it must for
  467. .PI ,
  468. .PC ,
  469. and
  470. .IX .
  471. .I Pxp
  472. will produce an execution profile if any of the
  473. .B z ,
  474. .B t
  475. or
  476. .B c
  477. options is specified on the command line.
  478. If none of these options is specified, then
  479. .XP
  480. functions as a program reformatter.
  481. .PP
  482. It is important to note that only the
  483. .B z
  484. and
  485. .B w
  486. options of
  487. .XP ,
  488. which are common to
  489. .PI ,
  490. .PC ,
  491. and
  492. .XP
  493. can be controlled in comments.
  494. All other options must be specified on the command line to have any effect.
  495. .PP
  496. The following options are relevant to profiling with
  497. .XP :
  498. .SH
  499. Include the bodies of all routines in the profile \- a
  500. .PP
  501. .I Pxp
  502. normally suppresses printing the bodies of routines
  503. which were never executed, to make the profile more compact.
  504. This option forces all routine bodies to be printed.
  505. .SH
  506. Suppress declaration parts from a profile \- d
  507. .PP
  508. Normally a profile includes declaration parts.
  509. Specifying
  510. .B d
  511. on the command line suppresses declaration parts.
  512. .SH
  513. Eliminate include directives \- e
  514. .PP
  515. Normally,
  516. .XP
  517. preserves
  518. .B include
  519. directives to the output when reformatting a program,
  520. as though they were comments.
  521. Specifying
  522. .B \-e
  523. causes the contents of the specified files to be reformatted
  524. into the output stream instead.
  525. This is an easy way to eliminate
  526. .B include
  527. directives, e.g. before transporting a program.
  528. .SH
  529. Fully parenthesize expressions \- f
  530. .PP
  531. Normally
  532. .XP
  533. prints expressions with the minimal parenthesization necessary to
  534. preserve the structure of the input.
  535. This option causes
  536. .I pxp
  537. to fully parenthesize expressions.
  538. Thus the statement which prints as
  539. .LS
  540. d := a + b mod c / e
  541. .LE
  542. with minimal parenthesization, the default, will print as
  543. .LS
  544. d := a + ((b mod c) / e)
  545. .LE
  546. with the
  547. .B f
  548. option specified on the command line.
  549. .SH
  550. Left justify all procedures and functions \- j
  551. .PP
  552. Normally, each
  553. .B procedure
  554. and
  555. .B function
  556. body is indented to reflect its static nesting depth.
  557. This option prevents this nesting and can be used if the indented
  558. output would be too wide.
  559. .SH
  560. Print a table summarizing procedure and function calls \- t
  561. .PP
  562. The
  563. .B t
  564. option causes
  565. .XP
  566. to print a table summarizing the number of calls to each
  567. .B procedure
  568. and
  569. .B function
  570. in the program.
  571. It may be specified in combination with the
  572. .B z
  573. option, or separately.
  574. .SH
  575. Enable and control the profile \- z
  576. .PP
  577. The
  578. .B z
  579. profile option is very similar to the
  580. .B i
  581. listing control option of
  582. .PI .
  583. If
  584. .B z
  585. is specified on the command line, then all arguments up to the
  586. source file argument which ends in `.p' are taken to be the names of
  587. .B procedure s
  588. and
  589. .B function s
  590. or
  591. .B include
  592. files which are to be profiled.
  593. If this list is null, then the whole file is to be profiled.
  594. A typical command for extracting a profile of part of a large program
  595. would be
  596. .LS
  597. % \*bpxp -z test parser.i compiler.p\fR
  598. .LE
  599. This specifies that profiles of the routines in the file
  600. .I parser.i
  601. and the routine
  602. .I test
  603. are to be made.
  604. .NH 2
  605. Formatting programs using pxp
  606. .PP
  607. The program
  608. .XP
  609. can be used to reformat programs, by using a command of the form
  610. .LS
  611. % \*bpxp dirty.p > clean.p\fR
  612. .LE
  613. Note that since the shell creates the output file `clean.p' before
  614. .XP
  615. executes, so `clean.p' and `dirty.p' must not be the same file.
  616. .PP
  617. .I Pxp
  618. automatically paragraphs the program, performing housekeeping
  619. chores such as comment alignment, and
  620. treating blank lines, lines containing exactly one blank
  621. and lines containing only a form-feed character as though they
  622. were comments, preserving their vertical spacing effect in the output.
  623. .I Pxp
  624. distinguishes between four kinds of comments:
  625. .HP
  626. .RS
  627. .IP 1)
  628. Left marginal comments, which begin in the first column of the
  629. input line and are placed in the first column of an output line.
  630. .IP 2)
  631. Aligned comments, which are preceded by no input tokens on the
  632. input line.
  633. These are aligned in the output with the running program text.
  634. .IP 3)
  635. Trailing comments, which are preceded in the input line by a token with
  636. no more than two spaces separating the token from the comment.
  637. .IP 4)
  638. Right marginal comments, which are preceded in the input line
  639. by a token from which they are separated by at least three spaces or a tab.
  640. These are aligned down the right margin of the output,
  641. currently to the first tab stop after the 40th column from the current
  642. ``left margin''.
  643. .RE
  644. .LP
  645. Consider the following program.
  646. .LS
  647. % \*bcat comments.p\fR
  648. .so comments1.p
  649. .LE
  650. When formatted by
  651. .XP
  652. the following output is produced.
  653. .LS
  654. % \*bpxp comments.p\fR
  655. .so commentsout
  656. %
  657. .LE
  658. The following formatting related options are currently available in
  659. .XP .
  660. The options
  661. .B f
  662. and
  663. .B j
  664. described in the previous section may also be of interest.
  665. .SH
  666. Strip comments \-s
  667. .PP
  668. The
  669. .B s
  670. option causes
  671. .XP
  672. to remove all comments from the input text.
  673. .SH
  674. Underline keywords \- \_
  675. .PP
  676. A command line argument of the form
  677. .B \-\_
  678. as in
  679. .LS
  680. % \*bpxp -_ dirty.p\fR
  681. .LE
  682. can be used to cause
  683. .XP
  684. to underline all keywords in the output for enhanced readability.
  685. .SH
  686. Specify indenting unit \- [23456789]
  687. .PP
  688. The normal unit which
  689. .XP
  690. uses to indent a structure statement level is 4 spaces.
  691. By giving an argument of the form
  692. \fB\-\fId\fR
  693. with
  694. .I d
  695. a digit,
  696. 2 \(<=
  697. .I d
  698. \(<= 9
  699. you can specify that
  700. .I d
  701. spaces are to be used per level instead.
  702. .NH 2
  703. Pxref
  704. .PP
  705. The cross-reference program
  706. .I pxref
  707. may be used to make cross-referenced listings of Pascal
  708. programs.
  709. To produce a cross-reference of the program in the file
  710. `foo.p'
  711. one can execute the command:
  712. .LS
  713. % \*bpxref foo.p\fR
  714. .LE
  715. The cross-reference is, unfortunately, not block structured.
  716. Full details on
  717. .I pxref
  718. are given in its manual section
  719. .I pxref
  720. (1).
  721. .NH 2
  722. Multi-file programs
  723. .PP
  724. A text inclusion facility is available with
  725. .UP .
  726. This facility allows the interpolation of source text from other
  727. files into the source stream of the translator.
  728. It can be used to divide large programs into more manageable pieces
  729. for ease in editing, listing, and maintenance.
  730. .PP
  731. The
  732. .B include
  733. facility is based on that of the
  734. .SM
  735. UNIX
  736. .NL
  737. C compiler.
  738. To trigger it you can place the character `#' in the first portion of
  739. a line and then, after an arbitrary number of blanks or tabs,
  740. the word
  741. `include'
  742. followed by a filename enclosed in single `\(aa' or double `"' quotation
  743. marks.
  744. The file name may be followed by a semicolon `;' if you wish to treat
  745. this as a pseudo-Pascal statement.
  746. The filenames of included files must end in `.i'.
  747. An example of the use of included files in a main program would be:
  748. .LS
  749. \*bprogram\fR compiler(input, output, obj);
  750.  
  751. #\*binclude\fR "globals.i"
  752. #\*binclude\fR "scanner.i"
  753. #\*binclude\fR "parser.i"
  754. #\*binclude\fR "semantics.i"
  755.  
  756. \*bbegin\fR
  757.     { main program }
  758. \*bend\fR.
  759. .LE
  760. .PP
  761. At the point the
  762. .B include
  763. pseudo-statement is encountered in the input, the lines from
  764. the included file are interpolated into the input stream.
  765. For the purposes of translation and runtime diagnostics and
  766. statement numbers in the listings and post-mortem backtraces,
  767. the lines in the included file are numbered from 1.
  768. Nested includes are possible up to 10 deep.
  769. .PP
  770. See the descriptions of the
  771. .B i
  772. option of
  773. .PI
  774. in section 5.2
  775. above;
  776. this can be used to control listing when
  777. .B include
  778. files are present.
  779. .PP
  780. When a non-trivial line is encountered in the source text after an
  781. .B include
  782. finishes, the
  783. `popped' filename is printed, in the same manner as above.
  784. .PP
  785. For the purposes of error diagnostics when not making a listing, the filename
  786. will be printed before each diagnostic if the current
  787. filename has changed since the last
  788. filename was printed.
  789. .NH 2
  790. Separate Compilation with Pc
  791. .PP
  792. A separate compilation facility is provided with the Berkeley Pascal compiler,
  793. .PC .
  794. This facility allows programs to be divided into a number of files and 
  795. the pieces to be compiled individually,
  796. to be linked together at some later time.
  797. This is especially useful for large programs,
  798. where small changes would otherwise require
  799. time-consuming re-compilation of the entire program.
  800. .PP
  801. Normally,
  802. .PC
  803. expects to be given entire Pascal programs.
  804. However, if given the
  805. .B \-c
  806. option on the command line, it will accept a sequence of definitions and
  807. declarations, and compile them into a
  808. .B .o
  809. file, to be linked with a Pascal program at a later time.
  810. In order that procedures and functions be available across
  811. separately compiled files, they must be declared with the directive
  812. .B external .
  813. This directive is similar to the directive
  814. .B forward
  815. in that it must precede the resolution of the function or procedure,
  816. and formal parameters and function result types must be specified
  817. at the
  818. .B external
  819. declaration and may not be specified at the resolution.
  820. .PP
  821. Type checking is performed across separately compiled files.
  822. Since Pascal type defintions define unique types,
  823. any types which are shared between separately compiled files
  824. must be the same definition.
  825. This seemingly impossible problem is solved using a facility similar
  826. to the
  827. .B include
  828. facility discussed above.
  829. Definitions may be placed in files with the extension
  830. .B .h
  831. and the files included by separately compiled files.
  832. Each definition from a 
  833. .B .h
  834. file defines a unique type, and all uses of a definition from the same 
  835. .B .h
  836. file define the same type.
  837. Similarly, the facility is extended to allow the definition of 
  838. .B const s
  839. and the declaration of
  840. .B label s,
  841. .B var s,
  842. and
  843. .B external
  844. .B function s
  845. and
  846. .B procedure s.
  847. Thus
  848. .B procedure s
  849. and
  850. .B function s
  851. which are used between separately compiled files must be declared
  852. .B external ,
  853. and must be so declared in a
  854. .B .h
  855. file included by any file which calls or resolves the 
  856. .B function
  857. or 
  858. .B procedure .
  859. Conversely,
  860. .B function s
  861. and
  862. .B procedure s
  863. declared
  864. .B external
  865. may only be so declared in 
  866. .B .h
  867. files.
  868. These files may be included only at the outermost level,
  869. and thus define or declare global objects.
  870. Note that since only
  871. .B external
  872. .B function
  873. and
  874. .B procedure
  875. declarations (and not resolutions) are allowed in
  876. .B .h
  877. files, statically nested
  878. .B function s
  879. and
  880. .B procedure s
  881. can not be declared
  882. .B external .
  883. .PP
  884. An example of the use of included
  885. .B .h
  886. files in a program would be:
  887. .LS
  888. \*bprogram\fR compiler(input, output, obj);
  889.  
  890. #\*binclude\fR "globals.h"
  891. #\*binclude\fR "scanner.h"
  892. #\*binclude\fR "parser.h"
  893. #\*binclude\fR "semantics.h"
  894.  
  895. \*bbegin\fR
  896.     { main program }
  897. \*bend\fR.
  898. .LE
  899. .PP
  900. This might include in the main program
  901. the definitions and declarations of all the global 
  902. .B label s,
  903. .B const s,
  904. .B type s and
  905. .B var s
  906. from the file globals.h,
  907. and the
  908. .B external
  909. .B function
  910. and
  911. .B procedure
  912. declarations for each of the
  913. separately compiled files for the scanner, parser and semantics.
  914. The header file
  915. .I scanner.h
  916. would contain declarations of the form:
  917. .LS
  918. \*btype\fR
  919.     token = \*brecord\fR
  920.     { token fields }
  921.     \*bend\fR;
  922.  
  923. \*bfunction\fR scan(\*bvar\fR inputfile: text): token;
  924.     \*bexternal\fR;
  925. .LE
  926. .ne 15
  927. Then the scanner might be in a separately compiled file containing:
  928. .LS
  929. #\*binclude\fR "globals.h"
  930. #\*binclude\fR "scanner.h"
  931.  
  932. \*bfunction\fR scan;
  933. \*bbegin\fR
  934.     { scanner code }
  935. \*bend\fR;
  936. .LE
  937. which includes the same global definitions and declarations
  938. and resolves the scanner functions and procedures declared
  939. .B external
  940. in the file scanner.h.
  941.