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

📄 puman3.n

📁 早期freebsd实现
💻 N
📖 第 1 页 / 共 2 页
字号:
.I opsin the example above or.I colorin.LS\*btype\fP color = (red, green, blue).LEFor integers, the more explicit denotation.I integeris used.Although it would be correct, in the context of the.I "User Manual"to refer to an integer variable as a.I scalarvariable.PIprefers the more specific identification..SHFunction and procedure type errors.PPFor built-in procedures and functions, two kinds of errors occur.If the routines are called with the wrong number of arguments a message similar to:.LS.so sinout1.LEis given.If the type of the argument is wrong, a message like.LS.so sinout2.LEis produced.A few functions and procedures implemented in Pascal 6000-3.4 arediagnosed as unimplemented inBerkeleyPascal, notably those related to.B segmented files..SHCan't read and write scalars, etc..PPThe messages which state that scalar (user-defined) typescannot be written to and from files are often mysterious.It is in fact the case that if you define.LS\*btype\fP color = (red, green, blue).LE``standard'' Pascal does not associate these constants with the strings`red', `green', and `blue' in any way.An extension has been added which allows enumerated typesto be read and written, however if the program is to be portable,you will have to write your own routines to perform these functions.Standard Pascal only allows the reading of characters, integers and realnumbers from text files.You cannot read strings or Booleans.It is possible to make a.LS\*bfile of\fP color.LEbut the representation is binary rather than string..SHExpression diagnostics.PPThe diagnostics for semantically ill-formed expressions are very explicit.Consider this sample translation:.LS% \*bpi -l expr.p\fP.so exprout%.LEThis example is admittedly far-fetched, but illustrates that the errormessages are sufficiently clear to allow easy determination of theproblem in the expressions..SHType equivalence.PPSeveral diagnostics produced by the Pascal translator complain about`non-equivalent types'.In general,BerkeleyPascal considers variables to have the same type only if they weredeclared with the same constructed type or with the same type identifier.Thus, the variables.I xand.I ydeclared as.LS\*bvar\fP    x: ^ integer;    y: ^ integer;.LEdo not have the same type.The assignment.LSx := y.LEthus produces the diagnostics:.LS.so typequout.LEThus it is always necessary to declare a type such as.LS\*btype\fP intptr = ^ integer;.LEand use it to declare.LS\*bvar\fP x: intptr; y: intptr;.LENote that if we had initially declared.LS\*bvar\fP x, y: ^ integer;.LEthen the assignment statement would have worked.The statement.LSx^ := y^.LEis allowed in either case.Since the parameter to a.B procedureor.B functionmust be declared with atype identifier rather than a constructed type,it is always necessary, in practice,to declare any type which will be used in this way..SHUnreachable statements.PPBerkeleyPascal flags unreachable statements.Such statements usually correspond to errors in the program logic.Note that a statement is considered to be reachableif there is a potential path of control,even if it can never be taken.Thus, no diagnostic is produced for the statement:.LS\*bif\fP false \*bthen\fP    writeln('impossible!').LE.SHGoto's into structured statements.PPThe translator detects and complains about.B gotostatements which transfer control into structured statements (\c.B for ,.B while ,etc.)It does not allow such jumps, nor does it allow branching from the.B thenpart of an.B ifstatement into the.B elsepart.Such checks are made only within the body of a single procedure orfunction..SHUnused variables, never set variables.PPAlthough.PIalways clears variables to 0 at.B procedureand.B functionentry,.PCdoes not unless runtime checking is enabled using the.B Coption.It is.B notgood programming practice to rely on this initialization.To discourage this practice, and to help detect errors in program logic,.PIflags as a `w' warning error:.IP.RS.HP 1)Use of a variable which is never assigned a value..IP 2)A variable which is declared but never used, distinguishingbetween those variables for which values are computed but which are neverused, and those completely unused..RE.LPIn fact, these diagnostics are applied to all declared items.Thus a.B constor a.B procedurewhich is declared but never used is flagged.The.B woption of.PImay be used to suppress these warnings;see sections 5.1 and 5.2..NH 2Translator panics, i/o errors.SHPanics.PPOne class of error which rarely occurs, but which causes terminationof all processing when it does is a panic.A panic indicates a translator-detected internal inconsistency.A typical panic message is:.LSsnark (rvalue) line=110 yyline=109Snark in pi.LEIf you receive such a message, the translation will be quickly and perhapsungracefully terminated.You should contact a teaching assistant or a member of the system staff,after saving a copy of your program for later inspection.If you were making changes to an existing program when the problemoccurred, you maybe able to work around the problem by ascertaining which change caused the.I snarkand making a different change or correcting an error in the program.A small number of panics are possible in.X .All panics should be reported to a teaching assistant or systemsstaff so that they can be fixed..SHOut of memory.PPThe only other error which will abort translation when no errors aredetected is running out of memory.All tables in the translator, with the exception of the parse stack,are dynamically allocated, and can grow to take up the full availableprocess space of 64000 bytes on the \s-2PDP\s0-11.  On the \s-2VAX\s0-11,table sizes are extremely generous and very large (25000) line programshave been easily accommodated.  For the \s-2PDP\s0\-11, it isgenerally true thatthe size of the largest translatable program is directly related to.B procedureand.B functionsize.A number of non-trivial Pascal programs, includingsome with more than 2000 lines and 2500 statementshave been translated and interpreted usingBerkeleyPascal on \s-2PDP\s0-11's.Notable among these are the Pascal-Sinterpreter,a large set of programs for automated generation ofcode generators,and a general context-free parsing program which has been used toparse sentences with a grammar for a superset of English.In general,very large programs should be translated using.PCand the separate compilation facility..PPIf you receive an out of space message from the translator during translation of a large.B procedureor.B functionor one containing a large number of string constantsyou may yet be ableto translate your program if you break this one.B procedureor.B functioninto several routines..SHI/O errors.PPOther errors which you may encounter when running.PIrelate to input-output.If.PIcannot open the file you specify,or if the file is empty,you will be so informed..NH 2Run-time errors.PPWe saw, in our second example, a run-time error.We here give the general description of run-time errors.The more unusual interpreter error messages are explainedbriefly in the manual section for.I px (1)..SHStart-up errors.PPThese errors occur when the object file to be executed is not availableor appropriate.Typical errors here are caused by the specified object file not existing,not being a Pascal object, or being inaccessible to the user..SHProgram execution errors.PPThese errors occur when the program interacts with the Pascal runtimeenvironment in an inappropriate way.Typical errors are values or subscripts out of range,bad arguments to built-in functions,exceeding the statement limit because of an infinite loop,or running out of memory\*(dd..FS\*(ddThe checks for running out of memory are not foolproof and thereis a chance that the interpreter will fault, producing a core imagewhen it runs out of memory.This situation occurs very rarely..FEThe interpreter will produce a backtrace after the error occurs,showing all the active routine calls,unless the.B poption was disabled when the program was translated.Unfortunately, no variable values are given and no way of extracting themis available.*.FS* On the \s-2VAX\s0-11, each variableis restricted to allocate at most 65000 bytes of storage (this is a\s-2PDP\s0-11ism that has survived to the \s-2VAX\s0.).FE.PPAs an example of such an error, assume that we have accidentallydeclared the constant.I n1to be 6, instead of 7on line 2 of the program primes as given in section 2.6 above.If we run this program we get the following response..LS% \*bpix primes.p\fP.so primeout3%.LE.PPHere the interpreter indicates that the program terminatedabnormally due to a subscript out of range near line 14,which is eight lines into the body of the program primes..SHInterrupts.PPIf the program is interrupted while executingand the.B poption was not specified,then a backtrace will be printed.\*(dg.FS\*(dgOccasionally, the Pascal system will be in an inconsistentstate when this occurs,e.g. when an interrupt terminates a.B procedureor.B functionentry or exit.In this case, the backtrace will only contain the current line.A reverse call order list of procedures will not be given..FEThe file.I pmon.outof profile information will be written if the program was translatedwith the.B zoption enabled to.PIor.IX ..SHI/O interaction errors.PPThe final class of interpreter errors results from inappropriateinteractions with files, including the user's terminal.Included here are bad formats for integer and real numbers (such asno digits after the decimal point) when reading.

⌨️ 快捷键说明

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