📄 puman5.n
字号:
will produce an execution profile if any of the.B z ,.B tor.B coptions is specified on the command line.If none of these options is specified, then.XPfunctions as a program reformatter..PPIt is important to note that only the.B zand.B woptions of.XP ,which are common to.PI ,.PC ,and.XPcan be controlled in comments.All other options must be specified on the command line to have any effect..PPThe following options are relevant to profiling with.XP :.SHInclude the bodies of all routines in the profile \- a.PP.I Pxpnormally suppresses printing the bodies of routineswhich were never executed, to make the profile more compact.This option forces all routine bodies to be printed..SHSuppress declaration parts from a profile \- d.PPNormally a profile includes declaration parts.Specifying.B don the command line suppresses declaration parts..SHEliminate include directives \- e.PPNormally,.XPpreserves.B includedirectives to the output when reformatting a program,as though they were comments.Specifying.B \-ecauses the contents of the specified files to be reformattedinto the output stream instead.This is an easy way to eliminate.B includedirectives, e.g. before transporting a program..SHFully parenthesize expressions \- f.PPNormally.XPprints expressions with the minimal parenthesization necessary topreserve the structure of the input.This option causes.I pxpto fully parenthesize expressions.Thus the statement which prints as.LSd := a + b mod c / e.LEwith minimal parenthesization, the default, will print as.LSd := a + ((b mod c) / e).LEwith the.B foption specified on the command line..SHLeft justify all procedures and functions \- j.PPNormally, each.B procedureand.B functionbody is indented to reflect its static nesting depth.This option prevents this nesting and can be used if the indentedoutput would be too wide..SHPrint a table summarizing procedure and function calls \- t.PPThe.B toption causes.XPto print a table summarizing the number of calls to each.B procedureand.B functionin the program.It may be specified in combination with the.B zoption, or separately..SHEnable and control the profile \- z.PPThe.B zprofile option is very similar to the.B ilisting control option of.PI .If.B zis specified on the command line, then all arguments up to thesource file argument which ends in `.p' are taken to be the names of.B procedure sand.B function sor.B includefiles which are to be profiled.If this list is null, then the whole file is to be profiled.A typical command for extracting a profile of part of a large programwould be.LS% \*bpxp -z test parser.i compiler.p\fR.LEThis specifies that profiles of the routines in the file.I parser.iand the routine.I testare to be made..NH 2Formatting programs using pxp.PPThe program.XPcan be used to reformat programs, by using a command of the form.LS% \*bpxp dirty.p > clean.p\fR.LENote that since the shell creates the output file `clean.p' before.XPexecutes, so `clean.p' and `dirty.p' must not be the same file..PP.I Pxpautomatically paragraphs the program, performing housekeepingchores such as comment alignment, andtreating blank lines, lines containing exactly one blankand lines containing only a form-feed character as though theywere comments, preserving their vertical spacing effect in the output..I Pxpdistinguishes between four kinds of comments:.HP.RS.IP 1)Left marginal comments, which begin in the first column of theinput line and are placed in the first column of an output line..IP 2)Aligned comments, which are preceded by no input tokens on theinput line.These are aligned in the output with the running program text..IP 3)Trailing comments, which are preceded in the input line by a token withno more than two spaces separating the token from the comment..IP 4)Right marginal comments, which are preceded in the input lineby a token from which they are separated by at least three spaces or a tab.These are aligned down the right margin of the output,currently to the first tab stop after the 40th column from the current``left margin''..RE.LPConsider the following program..LS% \*bcat comments.p\fR.so comments1.p.LEWhen formatted by.XPthe following output is produced..LS% \*bpxp comments.p\fR.so commentsout%.LEThe following formatting related options are currently available in.XP .The options.B fand.B jdescribed in the previous section may also be of interest..SHStrip comments \-s.PPThe.B soption causes.XPto remove all comments from the input text..SHUnderline keywords \- \_.PPA command line argument of the form.B \-\_as in.LS% \*bpxp -_ dirty.p\fR.LEcan be used to cause.XPto underline all keywords in the output for enhanced readability..SHSpecify indenting unit \- [23456789].PPThe normal unit which.XPuses to indent a structure statement level is 4 spaces.By giving an argument of the form\fB\-\fId\fRwith.I da digit,2 \(<=.I d\(<= 9you can specify that.I dspaces are to be used per level instead..NH 2Pxref.PPThe cross-reference program.I pxrefmay be used to make cross-referenced listings of Pascalprograms.To produce a cross-reference of the program in the file`foo.p'one can execute the command:.LS% \*bpxref foo.p\fR.LEThe cross-reference is, unfortunately, not block structured.Full details on.I pxrefare given in its manual section.I pxref(1)..NH 2Multi-file programs.PPA text inclusion facility is available with.UP .This facility allows the interpolation of source text from otherfiles into the source stream of the translator.It can be used to divide large programs into more manageable piecesfor ease in editing, listing, and maintenance..PPThe.B includefacility is based on that of the.SMUNIX.NLC compiler.To trigger it you can place the character `#' in the first portion ofa line and then, after an arbitrary number of blanks or tabs,the word`include'followed by a filename enclosed in single `\(aa' or double `"' quotationmarks.The file name may be followed by a semicolon `;' if you wish to treatthis as a pseudo-Pascal statement.The filenames of included files must end in `.i'.An example of the use of included files in a main program would be:.LS\*bprogram\fR compiler(input, output, obj);#\*binclude\fR "globals.i"#\*binclude\fR "scanner.i"#\*binclude\fR "parser.i"#\*binclude\fR "semantics.i"\*bbegin\fR { main program }\*bend\fR..LE.PPAt the point the.B includepseudo-statement is encountered in the input, the lines fromthe included file are interpolated into the input stream.For the purposes of translation and runtime diagnostics andstatement numbers in the listings and post-mortem backtraces,the lines in the included file are numbered from 1.Nested includes are possible up to 10 deep..PPSee the descriptions of the.B ioption of.PIin section 5.2above;this can be used to control listing when.B includefiles are present..PPWhen a non-trivial line is encountered in the source text after an.B includefinishes, the`popped' filename is printed, in the same manner as above..PPFor the purposes of error diagnostics when not making a listing, the filenamewill be printed before each diagnostic if the currentfilename has changed since the lastfilename was printed..NH 2Separate Compilation with Pc.PPA separate compilation facility is provided with the Berkeley Pascal compiler,.PC .This facility allows programs to be divided into a number of files and the pieces to be compiled individually,to be linked together at some later time.This is especially useful for large programs,where small changes would otherwise requiretime-consuming re-compilation of the entire program..PPNormally,.PCexpects to be given entire Pascal programs.However, if given the.B \-coption on the command line, it will accept a sequence of definitions anddeclarations, and compile them into a.B .ofile, to be linked with a Pascal program at a later time.In order that procedures and functions be available acrossseparately compiled files, they must be declared with the directive.B external .This directive is similar to the directive.B forwardin that it must precede the resolution of the function or procedure,and formal parameters and function result types must be specifiedat the.B externaldeclaration and may not be specified at the resolution..PPType checking is performed across separately compiled files.Since Pascal type defintions define unique types,any types which are shared between separately compiled filesmust be the same definition.This seemingly impossible problem is solved using a facility similarto the.B includefacility discussed above.Definitions may be placed in files with the extension.B .hand the files included by separately compiled files.Each definition from a .B .hfile defines a unique type, and all uses of a definition from the same .B .hfile define the same type.Similarly, the facility is extended to allow the definition of .B const sand the declaration of.B label s,.B var s,and.B external.B function sand.B procedure s.Thus.B procedure sand.B function swhich are used between separately compiled files must be declared.B external ,and must be so declared in a.B .hfile included by any file which calls or resolves the .B functionor .B procedure .Conversely,.B function sand.B procedure sdeclared.B externalmay only be so declared in .B .hfiles.These files may be included only at the outermost level,and thus define or declare global objects.Note that since only.B external.B functionand.B proceduredeclarations (and not resolutions) are allowed in.B .hfiles, statically nested.B function sand.B procedure scan not be declared.B external ..PPAn example of the use of included.B .hfiles in a program would be:.LS\*bprogram\fR compiler(input, output, obj);#\*binclude\fR "globals.h"#\*binclude\fR "scanner.h"#\*binclude\fR "parser.h"#\*binclude\fR "semantics.h"\*bbegin\fR { main program }\*bend\fR..LE.PPThis might include in the main programthe definitions and declarations of all the global .B label s,.B const s,.B type s and.B var sfrom the file globals.h,and the.B external.B functionand.B proceduredeclarations for each of theseparately compiled files for the scanner, parser and semantics.The header file.I scanner.hwould contain declarations of the form:.LS\*btype\fR token = \*brecord\fR { token fields } \*bend\fR;\*bfunction\fR scan(\*bvar\fR inputfile: text): token; \*bexternal\fR;.LE.ne 15Then the scanner might be in a separately compiled file containing:.LS#\*binclude\fR "globals.h"#\*binclude\fR "scanner.h"\*bfunction\fR scan;\*bbegin\fR { scanner code }\*bend\fR;.LEwhich includes the same global definitions and declarationsand resolves the scanner functions and procedures declared.B externalin the file scanner.h.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -