⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 puman3.n

📁 早期freebsd实现
💻 N
📖 第 1 页 / 共 2 页
字号:
.\" Copyright (c) 1980, 1993.\"	The Regents of the University of California.  All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"	@(#)puman3.n	8.1 (Berkeley) 6/8/93.\".if !\n(xx \{\.so tmac.p \}.if n 'ND.nr H1 2.NHError diagnostics.PPThis section of the.UMdiscusses the error diagnostics of the programs.PI ,.PCand.X ..I Pixis a simple but useful program which invokes.PIand.Xto do all the real processing.See its manual section.IX(1)and section 5.2 below for more details.All the diagnostics given by.PIwill also be given by.PC ..NH 2Translator syntax errors.PPA few comments on the general nature of the syntax errors usuallymade by Pascal programmersand the recovery mechanisms of the current translator may help in usingthe system..SHIllegal characters.PPCharacters such as `$', `!', and `@' are not part of the language Pascal.If they are found in the source program,and are not part of a constant string, a constant character, or a comment,they are considered to be`illegal characters'.This can happen if you leave off an opening string quote `\(aa'.Note that the character `"', although used in English to quote strings,is not used to quote strings in Pascal.Most non-printing characters in your input are also illegal exceptin character constants and character strings.Except for the tab and form feed characters,which are used to ease formatting of the program,non-printing characters in the input file print as the character `?'so that they will show in your listing..SHString errors.PPThere is no character string of length 0 in Pascal.Consequently the input `\(aa\(aa' is not acceptable.Similarly, encountering an end-of-line after an opening string quote `\(aa'without encountering the matching closing quote yields the diagnostic``Unmatched \(aa for string''.It is permissible to use the character `#'instead of `\''to delimit character and constant strings for portability reasons.For this reason, a spuriously placed `#' sometimes causes the diagnosticabout unbalanced quotes.Similarly, a `#' in column one is used when preparing programs which are tobe kept in multiple files.See section 5.11 for details..SHComments in a comment, non-terminated comments.PPAs we saw above, these errors are usually caused by leaving off a commentdelimiter.You can convert parts of your program to commentswithout generating this diagnosticsince there are two different kinds of comments \- those delimited by`{' and `}', and those delimited by `(*' and `*)'.Thus consider:.LS{ This is a comment enclosing a piece of programa := functioncall;	(* comment within comment *)procedurecall;lhs := rhs;		(* another comment *)}.LE.PPBy using one kind of comment exclusively in your program you can usethe other delimiters when you need to``comment out''parts of your program\*(dg..FS\*(dgIf you wish to transport your program,especially to the 6000-3.4 implementation,you should use the character sequence `(*' to delimit comments.For transportation over the.I rcslinkto Pascal 6000-3.4, the character `#' should be used to delimit charactersand constant strings..FEIn this way you will also allow the translator to help by detectingstatements accidentally placed within comments..PPIf a comment does not terminate before the end of the input file,the translator will point to the beginning of the comment,indicating that the comment is not terminated.In this case processing will terminate immediately.See the discussion of ``QUIT'' below..SHDigits in numbers.PPThis part of the language is a minor nuisance.Pascal requires digits in real numbers both before and after the decimalpoint.Thus the following statements, which look quite reasonable to.SMFORTRAN.NLusers, generate diagnostics in Pascal:.LS.so digitsout.LEThese same constructs are also illegal as input to the Pascal interpreter.I px ..SHReplacements, insertions, and deletions.PPWhen a syntax error is encountered in the input text,the parser invokes an error recovery procedure.This procedure examines the input text immediately after the pointof error and considers a set of simple corrections to see whether theywill allow the analysis to continue.These corrections involve replacing an input token with a differenttoken,inserting a token,or replacing an input token with a different token.Most of these changes will not cause fatal syntax errors.The exception is the insertion of or replacement with a symbolsuch as an identifier or a number;in this case the recovery makes no attempt to determine.I whichidentifier or.I what number should be inserted,hence these are considered fatal syntax errors..PPConsider the following example..LS% \*bpix -l synerr.p\fR.tr --.so synerrout%.LEThe only surprise here may be that Pascal does not have an exponentiationoperator, hence the complaint about `**'.This error illustrates that, if you assume that the language has a featurewhich it does not, the translator diagnostic may not indicate this,as the translator is unlikely to recognize the construct you supply..SHUndefined or improper identifiers.PPIf an identifier is encountered in the input but is undefined,the error recovery will replace it with an identifier of theappropriate class.Further references to this identifier will be summarized at theend of the containing.B procedureor.B functionor at the end of the.B programif the reference occurred in the main program.Similarly,if an identifier is used in an inappropriate way,e.g. if a.B typeidentifier is used in an assignment statement,or if a simple variableis used where a.B recordvariable is required,a diagnostic will be produced and an identifier of the appropriatetype inserted.Further incorrect references to this identifier will be flagged onlyif they involve incorrect use in a different way,with all incorrect uses being summarized in the same way as undefinedvariable uses are..SHExpected symbols, malformed constructs.PPIf none of the above mentioned corrections appear reasonable, theerror recovery will examine the input to the left of the point of error to see if there is only one symbolwhich can follow this input.If this is the case, the recovery will print a diagnostic whichindicates that the given symbol was `Expected'..PPIn cases where none of these corrections resolve the problemsin the input,the recovery may issue a diagnostic that indicates that theinput is ``malformed''.If necessary, the translator may then skip forward in the input toa place where analysis can continue.This process may cause some errors in the text to be missed..PPConsider the following example:.LS% \*bpix -l synerr2.p\fR.so synerr2out%.LEHere we misspelled.I outputand gave a.SM FORTRANstyle variable declarationwhich the translator diagnosed as a `Malformed declaration'.When, on line 6, we used `(' and `)' for subscripting(as in.SM FORTRAN )rather than the `[' and `]' which are used in Pascal,the translator noted that.I awas not defined as a.B procedure .This occurred because.B procedureand.B functionargument lists are delimited by parentheses in Pascal.As it is not permissible to assign to procedure calls the translatordiagnosed a malformed statement at the point of assignment..SHExpected and unexpected end-of-file, ``QUIT''.PPIf the translator finds a complete program, but there is more non-comment textin the input file, then it will indicate that an end-of-file was expected.This situation may occur after a bracketing error, or if too many.B end sare present in the input.The message may appearafter the recovery says that it``Expected \`.\'\|''since `.' is the symbol that terminates a program..PPIf severe errors in the input prohibit further processingthe translator may produce a diagnostic followed by ``QUIT''.One example of this was given above \-a non-terminated comment;another example is a line which is longer than 160characters.Consider also the following example..LS% \*bpix -l mism.p\fR.so mismout%.LE.NH 2Translator semantic errors.PPThe extremely large number of semantic diagnostic messages which the translatorproduces make it unreasonable to discuss each message or group of messagesin detail.The messages are, however, very informative.We will here explain the typical formats and the terminology used in the errormessages so that you will be able to make sense out of them.In any case in which a diagnostic is not completely comprehensible you canrefer to the.I "User Manual"by Jensen and Wirth for examples..SHFormat of the error diagnostics.PPAs we saw in the example program above, the error diagnostics fromthe Pascal translator include the number of a line in the text of the programas well as the text of the error message.While this number is most often the line where the error occurred, itis occasionally the number of a line containing a bracketing keywordlike.B endor.B until .In this case, the diagnostic may refer to the previous statement.This occurs because of the method the translator uses for sampling linenumbers.The absence of a trailing `;' in the previous statement causes the linenumber corresponding to the.B endor.B until .to become associated with the statement.As Pascal is a free-format language, the line number associationscan only be approximate and may seem arbitrary to some users.This is the only notable exception, however, to reasonable associations..SHIncompatible types.PPSince Pascal is a strongly typed language, many semantic errors manifestthemselves as type errors.These are called `type clashes' by the translator.The types allowed for various operators in the language are summarized on page108 of theJensen-Wirth.I "User Manual" .It is important to know that the Pascal translator, in its diagnostics,distinguishes between the following type `classes':.br.ne 8.TScenter;lew(10) le le le le.array	Boolean	char	file	integerpointer	real	record	scalar	string.TEThese words are plugged into a great number of error messages.Thus, if you tried to assign an.I integervalue to a.I charvariable you would receive a diagnostic like the following:.LS.so clashout.LEIn this case, one error produced a two line error message.If the same error occurs more than once, the same explanatorydiagnostic will be given each time..SHScalar.PPThe only class whose meaning is not self-explanatory is `scalar'.Scalar has a precise meaning in theJensen-Wirth.I "User Manual"where, in fact, it refers to.I char ,.I integer ,.I real ,and.I Booleantypes as well as the enumerated types.For the purposes of the Pascal translator,scalarin an error message refers to a user-defined, enumeratedtype, such as

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -