ack.7

来自「minix操作系统最新版本(3.1.1)的源代码」· 7 代码 · 共 2,091 行 · 第 1/5 页

7
2,091
字号
Even when underscores are enabled,they still may not start an identifier..PPConstants of type \*(CwLONGINT\fR are integers with a suffix letter \*(CwD\fR(for instance \*(Cw1987D\fR).Constants of type \*(CwLONGREAL\fR have suffix \*(CwD\fR if a scale factor is missing,or have \*(CwD\fR in place of \*(CwE\fR in the scale factor (f.i. \*(Cw1.0D\fR,\*(Cw0.314D1\fR).This addition was made,because there was no way to indicate long constants,and also because the addition was made in Wirth's newest Modula-2 compiler..SS "Declarations and scope rules (section 4)".PPStandard identifiers are predeclared,and valid in allparts of a program.They are called \fIpervasive\fR.Unfortunately,the Report does not state how this pervasiveness is accomplished.However,page 87 of [1] states: 'Standard identifiers are automaticallyimported into all modules'.Our implementation therefore allowsredeclarations of standard identifiers within procedures,but not withinmodules..SS "Constant expressions (section 5)".PPEach operand of a constant expression must be a constant:a string,a number,a set,an enumeration literal,a qualifier denoting aconstant expression,a type transfer with a constant argument,or one of the standard procedures\*(CwABS\fR,\*(CwCAP\fR,\*(CwCHR\fR,\*(CwLONG\fR,\*(CwMAX\fR,\*(CwMIN\fR,\*(CwODD\fR,\*(CwORD\fR,\*(CwSIZE\fR,\*(CwSHORT\fR,\*(CwTSIZE\fR,or \*(CwVAL\fR,with constant argument(s);\*(CwTSIZE\fR and \*(CwSIZE\fR may also have a variable as argument..SS "Type declarations (section 6)".LP.ft I1. Basic types (section 6.1).PPThe type \*(CwCHAR\fR includes the ASCII character set as a subset.Values range from\*(Cw0C\fR to \*(Cw377C\fR,not from \*(Cw0C\fR to \*(Cw177C\fR..LP.ft I2. Enumerations (section 6.2).PPThe maximum number of enumeration literals in any one enumeration typeis \*(CwMAX(INTEGER)\fR..LP.ft I3. Record types (section 6.5).PPThe syntax of variant sections in [1] is different from the one in [2].Our implementation recognizes both,giving a warning for the older one..LP.ft I4. Set types (section 6.6).PPThe only limitation imposed by the compiler is that the base type of theset must be a subrange type,an enumeration type,\*(CwCHAR\fR,or \*(CwBOOLEAN\fR.So,the lower bound may be negative.However,if a negative lower bound is used,the compiler gives a warning of the \fIrestricted\fR class..PPThe standard type \*(CwBITSET\fR is defined as.XS.CWTYPE BITSET = SET OF [0 .. 8*SIZE(INTEGER)-1];.ft P.XE.SS "Expressions (section 8)".LP.ft I1. Operators (section 8.2).LP.ft I1.1. Arithmetic operators (section 8.2.1).PPThe Report does not specify the priority of the unaryoperators \*(Cw+\fR or \*(Cw-\fR:It does not specify whether.XS.CW- 1 + 1.ft P.XEmeans.XS.CW- (1 + 1).ft P.XEor.XS.CW(-1) + 1.ft P.XEThe.MXModula-2 compiler implements the second alternative..SS "Statements (section 9)".LP.ft I1. Assignments (section 9.1).PPThe Report does not define the evaluation order in an assignment.Our compiler certainly chooses an evaluation order,but it is explicitly left undefined.Therefore,programs that depend on it may cease to work later..PPThe types \*(CwINTEGER\fR and \*(CwCARDINAL\fR are assignment-compatible with\*(CwLONGINT\fR,and \*(CwREAL\fR is assignment-compatible with \*(CwLONGREAL\fR..LP.ft I2. Case statements (section 9.5).PPThe size of the type of the case-expression must be less than or equal tothe word-size..PPThe Report does not specify what happens if the value of the case-expressiondoes not occur as a label of any case,and there is no \*(CwELSE\fR-part.In our implementation,this results in a runtime error..LP.ft I3. For statements (section 9.8).PPThe Report does not specify the legal types for a control variable.Our implementation allows the basic types (except \*(CwREAL\fR),enumeration types,and subranges.A runtime warning is generated when the value of the control variableis changed by the statement sequence that forms the body of the loop,unless runtime checking is disabled..LP.ft I4. Return and exit statements (section 9.11).PPThe Report does not specify which result-types are legal.Our implementation allows any result type..SS "Procedure declarations (section 10)".PPFunction procedures must exit through a RETURN statement,or a runtime error occurs..LP.ft I1. Standard procedures (section 10.2).PPOur implementation supports \*(CwNEW\fR and \*(CwDISPOSE\fRfor backwards compatibility,but issues warnings for their use..PPAlso,some new standard procedures were added,similar to the new standard procedures in Wirth's newest compiler:.IP \-\*(CwLONG\fR converts an argument of type \*(CwINTEGER\fR or \*(CwREAL\fR to thetypes \*(CwLONGINT\fR or \*(CwLONGREAL\fR..IP \-\*(CwSHORT\fR performs the inverse transformation,without range checks..IP \-\*(CwFLOATD\fR is analogous to \*(CwFLOAT\fR,but yields a result of type\*(CwLONGREAL\fR..IP \-\*(CwTRUNCD\fR is analogous to \*(CwTRUNC\fR,but yields a result of type\*(CwLONGINT\fR..SS "System-dependent facilities (section 12)".PPThe type \*(CwBYTE\fR is added to the \*(CwSYSTEM\fR module.It occupies a storage unit of 8 bits.\*(CwARRAY OF BYTE\fR has a similar effect to \*(CwARRAY OF WORD\fR,but is safer.In some obscure cases the \*(CwARRAY OF WORD\fR mechanism does not quitework properly..PPThe procedure \*(CwIOTRANSFER\fR is not implemented..SS "Backwards compatibility".PPBesides recognizing the language as described in [1],the compiler recognizes most of the language described in [2],for backwards compatibility.It warns the user for old-fashionedconstructions (constructions that [1] does not allow).If the \fI\(en3\fR option is passed to \fIm2\fR,this backwards compatibility feature is disabled..SS "Compile time errors".PPThe compile time error messages are intended to be self-explanatory,and not listed here.The compiler also sometimes issues warnings,recognizable by a warning-classification between parentheses.There are 3 classifications:.IP "(old-fashioned use)".brThese warnings are given on constructions that are not allowed by [1],but are allowed by [2]..IP (strict).brThese warnings are given on constructions that are supported by the.MXModula-2 compiler,but might not be supported by others.Examples: functions returning structured types,SET types of subranges withnegative lower bound..IP (warning).brThe other warnings,such as warnings about variables that are never assigned,never used,etc..SS "Runtime errors".PPThe \fITraps\fR module enables the user to install his own runtimeerror handler.The default one just displays what happened and exits.Basically,a trap handler is just a procedure that takes an INTEGER asparameter.The INTEGER is the trap number.This INTEGER can be one of theEM trap numbers,listed in [3],or one of the numbers listed in the\fITraps\fR definition module..PPThe following runtime errors may occur:.IP "array bound error".brThis error is detected if the \fI\(enA\fR option is given to \fIm2\fR..IP "range bound error".brRange bound errors are always detected,unless runtime checks are disabled..IP "set bound error".IP "cardinal overflow".brThis error is detected,unless runtime checks are disabled..IP "cardinal underflow".brThis error is detected,unless runtime checks are disabled..IP "divide by 0".IP "divide by 0.0".IP "conversion error".brThis error occurs when assigning a negative value of type INTEGER to avariable of type CARDINAL,or when assigning a value of CARDINAL that is > MAX(INTEGER),to a variable of type INTEGER.It is detected,unless runtime checking is disabled..IP "heap overflow".brThis might happen when ALLOCATE fails..IP "case error".brThis error occurs when non of the cases in a CASE statement are selected,and the CASE statement has no ELSE part..IP "stack size of process too large".brThis is most likely to happen if the reserved space for a coroutine stackis too small.In this case,increase the size of the area given to\*(CwNEWPROCESS\fR.It can also happen if the stack needed for the mainprocess is too large and there are coroutines.In this case,the only fix is to reduce the stack size needed by the main process,f.i. by avoiding local arrays..IP "too many nested traps + handlers".brThis error can only occur when the user has installed his own trap handler.It means that during execution of the trap handler another trap has occurred,and that several times.In some cases,this is an error because of overflow of some internal tables..IP "no RETURN from function procedure".brThis error occurs when a function procedure does not return properly('falls' through)..IP "illegal instruction".brThis error might occur when you use floating point operations on animplementation that does not have floating point..PPIn addition,some of the library modules may give error messages.The \fBTraps\fR-module has a suitable mechanism for this..SS "The procedure call interface".PPParameters are pushed on the stack in reversed order.For VAR parameters,its address is passed,for value parameters its value.The only exception to this rule is with conformant arrays.For conformant arrays,the address is passed,and an array descriptor ispassed.The descriptor is an EM array descriptor.It consists of threefields: the lower bound (always 0),upper bound \(mi lower bound,and the size of the elements.The descriptor is pushed first.If the parameter is a value parameter,the called routine must make surethat its value is never changed,for instance by making its own copyof the array..PPWhen the size of the return value of a function procedure is larger thanthe maximum of \*(CwSIZE(LONGREAL)\fR and twice the pointer-size,the caller reserves this space on the stack,above the parameters.Callee then storesits result there,and returns no other value..SS "The Modula-2 runtime library".PPThe definition modules of the modules available in the.MXModula-2 runtime library reside in the directory \fI/usr/lib/ack/m2\fR..SS References.IP [1]Niklaus Wirth,.ft IProgramming in Modula-2, third, corrected edition,.ft RSpringer-Verlag, Berlin (1985).IP [2]Niklaus Wirth,.ft IProgramming in Modula-2,.ft RStringer-Verlag, Berlin (1983).IP [3]A.S.Tanenbaum, J.W.Stevenson, Hans van Staveren, E.G.Keizer,.ft IDescription of a machine architecture for use with block structured languages,.ft RInformatica rapport IR-81, Vrije Universiteit, Amsterdam.SH "THE MINIX PASCAL COMPILER".PP.de IT.PP.B BS\ \\$1:...de IS.PP.in +.5i...PPThis section refers to the (1982) BSI standard for Pascal [1]..MXPascal complies with the requirements of level 1 of BS 6192: 1982, withthe exceptions as listed in this section..PPThe standard requires an accompanying document describing theimplementation-defined and implementation-dependent features,the reaction on errors and the extensions to standard Pascal.These four items will be treated in the rest of this section..SS "Implementation-defined features".PPFor each implementation-defined feature mentioned in the BSI standardwe give the section number, the quotation from that section and the definition.First we quote the definition of implementation-defined:.PP.RSPossibly differing between processors, but defined for any particularprocessor..RE.IT 6.1.7Each string-character shall denote an implementation-defined value of therequired char-type..ISAll 7-bit ASCII characters except linefeed LF (10) are allowed..IT 6.4.2.2The values of type real shall be an implementation-defined subsetof the real numbers denoted as specified by 6.1.5 by the signed-real values..ISThe set of real values range from a low of \(mi1.7976931348623157e+308 toa high of 1.7976931348623157e+308..IT 6.4.2.2The type char shall be the enumeration of a set of implementation-defined

⌨️ 快捷键说明

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