ack.7

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

7
2,091
字号
.ti -3non-ASCII char read, trap 106, non-fatal:.brthe character value of the next character-typefile element is out of range (0..127).Only for text files..in -6.IT 6.6.5.3It shall be an error if a variant of a variant-part within the newvariable becomes active and a different variant of the variant-part isone of the specified variants..ISThis error is not detected..IT 6.6.5.3It shall be an error to use dispose(q) if the identifying variable has beenallocated using the form new(p,c1,...,cn)..ISThis error is not detected.However, this error can cause more memoryto be freed then was allocated.Dispose causes a fatal trap 73 when memory already on the freelist is freed again..IT 6.6.5.3It shall be an error to use dispose(q,k1,...,km) if the identifyingvariable has been allocated using the form new(p,c1,...,cn) and m is notequal to n..ISThis error is not detected.However, this error can cause more memoryto be freed then was allocated.Dispose causes a fatal trap 73 when memory already on the freelist is freed again..IT 6.6.5.3It shall be an error if the variants of a variable to be disposedare different from those specified by the case-constants to dispose..ISThis error is not detected..IT 6.6.5.3It shall be an error if the value of the pointer parameter of dispose hasnil-value or is undefined..ISThis error is detected for nil-value (dispose error, trap 73, fatal)..IT 6.6.5.3It shall be an error if a variable created using the second form of new isaccessed by the identified variable of the variable-access of a factor,of an assignment-statement, or of an actual-parameter..ISThis error is not detected..IT 6.6.6.2It shall be an error if the value of sqr(x) does not exist..ISThis error is detected for real-type arguments (real overflow,trap 4, non-fatal)..IT 6.6.6.2It shall be an error if x in ln(x) is smaller than or equal to 0..ISThis error is detected (error in ln, trap 66, non-fatal).IT 6.6.6.2It shall be an error if x in sqrt(x) is smaller than 0..ISThis error is detected (error in sqrt, trap 67, non-fatal).SPIn addition to these errors, overflow in the expression exp(x) isdetected (error in exp, trap 65, non-fatal; real overflow, trap 4, non-fatal).IT 6.6.6.3It shall be an error ifthe integer value of trunc(x) does not exist..ISThis error is detected (conversion error, trap 10, non-fatal)..IT 6.6.6.3It shall be an error ifthe integer value of round(x) does not exist..ISThis error is detected (conversion error, trap 10, non-fatal)..IT 6.6.6.4It shall be an error ifthe integer value of ord(x) does not exist..ISThis error can not occur, because the compiler will not allowsuch ordinal types..IT 6.6.6.4It shall be an error ifthe character value of chr(x) does not exist..ISThis error is detected (range bound error, trap 1, non-fatal)..IT 6.6.6.4It shall be an error if the value of succ(x) does not exist..ISSame comments as for chr(x)..IT 6.6.6.4It shall be an error if the value of pred(x) does not exist..ISSame comments as for chr(x)..IT 6.6.6.5It shall be an error if f in eof(f) is undefined..ISThis error is detected (file not yet open, trap 72, fatal)..IT 6.6.6.5It shall be an error iff in eoln(f) is undefined, or if eof(f) is true at that time..ISThe following errors may occur:.ISfile not yet open, trap 72, fatal;.brnot readable, trap 97, fatal;.brend of file, trap 98, fatal..IT 6.7.1It shall be an error if a variable-access used as an operandin an expression is undefined at the time of its use..ISThe compiler performs some limited checks to see if identifiers areused before they are set.Since it can not always be sure (one could, forinstance, jump out of a loop), only a warning is generated.When anexpression contains a function-call, an error occurs if thefunction is not assigned at run-time..IT 6.7.2.2A term of the form x/y shall be an error if y is zero..ISThis error is detected (divide by 0.0, trap 7, non-fatal)..IT 6.7.2.2It shall be an error if j is zero in 'i div j'..ISThis error is detected (divide by 0, trap 6, non-fatal)..IT 6.7.2.2It shall be an error ifj is zero or negative in i MOD j..ISThis error is detected (only positive j in 'i mod j', trap 71, non-fatal)..IT 6.7.2.2It shall be an error if the result of any operation on integeroperands is not performed according to the mathematicalrules for integer arithmetic..ISThis implementation does not detect integer overflow..IT 6.8.3.5It shall be an error if none of the case-constants is equal to thevalue of the case-index upon entry to the case-statement..ISThis error is detected (case error, trap 20, fatal)..IT 6.9.1It shall be an error if the sequence of characters read looking for aninteger does not form a signed-integer as specified in 6.1.5..ISThis error is detected (digit expected, trap 105, non-fatal)..IT 6.9.1It shall be an error if the sequence of characters read looking for areal does not form a signed-number as specified in 6.1.5..ISThis error is detected (digit expected, trap 105, non-fatal)..IT 6.9.1When read is applied to f, it shall be an error if the buffer-variable f^is undefined or the pre-assertions for get do not hold..ISThis error is detected (see get(f))..IT 6.9.3When write is applied to a text file f, it shall be an error if f isundefined or f is opened for reading..ISThis error is detected (see put(f)).Furthermore, this error is alsodetected when f is not a text file..IT 6.9.3.1The values of TotalWidth or FracDigits shall be greater than or equal toone; it shall be an error if either value is less then one..ISWhen either value is less than zero, an error (illegal field width, trap75, non-fatal) occurs.Zero values are allowed, in order to maintain somecompatibility with the old .MXPascal compiler..IT 6.9.5It shall be an error if the pre-assertion required for writeln(f) doe nothold prior to the invocation of page(f);.ISThis error is detected (see put(f))..in 0.SS "Extensions to the standard".LP.ft I1. External routines.LPExcept for the required directive 'forward' the .MXPascal compiler recognizesthe directive 'extern'.This directive tells the compiler that the procedure block of thisprocedure will not be present in the current program.The code for the body of this procedure must be included at a laterstage of the compilation process..PPThis feature allows one to build libraries containing often used routines.These routines do not have to be included in all the programs using them.Maintenance is much simpler if there is only one library module to bechanged instead of many Pascal programs..PPAnother advantage is that these library modules may be written in a differentlanguage, for instance C..PPThe use of external routines, however, is dangerous.The compiler normally checks for the correct number and type of parameterswhen a procedure is called and for the result type of functions.If an external routine is called these checks are not sufficient,because the compiler can not check whether the procedure heading of theexternal routine as given in the Pascal program matches the actual routineimplementation.It should be the loader's task to check this.However, the current loaders are not that smart..PPFor those who wish the use the interface between C and Pascal wegive an incomplete list of corresponding formal parameters in C and Pascal..SP.XS.ta +\w'function a(pars):type   'u\fBPascal	C\fRa:integer	int aa:char	int aa:boolean	int aa:real	double aa:^type	type *avar a:type	type *aprocedure a(pars)	struct {	     void (*a)() ;	     char *static_link ;	}function a(pars):type	struct {	     type (*a)() ;	     char *static_link ;	}.DT.XEThe Pascal runtime system uses the following algorithm when callingfunction/procedures passed as parameters..XSif (static_link) {	(*a)(static_link, pars);} else {	(*a)(pars);}.XE.LP.ft I2. Separate compilation..LPThe compiler is able to (separately) compile a collection of declarations,procedures and functions to form a library.The library may be linked with the main program, compiled later.The syntax of these modules is.XS.in +\w'module = 'u.ti -\w'module = 'umodule = [constant-definition-part][type-definition-part][var-declaration-part][procedure-and-function-declaration-part].in -\w'module = 'u.XEThe compiler accepts a program or a module:.XSunit = program | module.XEAll variables declared outside a module must be importedby parameters, even the files input and output.Access to a variable declared in a module is only possibleusing the procedures and functions declared in that same module.By giving the correct procedure/function heading followed by thedirective 'extern' you may use procedures and functions declared inother units..LP.ft I3. Assertions..LPWhen the s-option is off, .MXPascal compiler recognizes an additionalstatement, the assertion.Assertions can be used as an aid in debuggingand documentation.The syntax is:.XSassertion = 'assert' Boolean-expression.XEAn assertion is a simple-statement, so.XS.in +\w'simple-statement = ['u.ti -\w'simple-statement = ['usimple-statement = [assignment-statement |procedure-statement |goto-statement |assertion.in -\w'['u].in -\w'simple-statement = 'u.XEAn assertion causes an error if the Boolean-expression is false.That is its only purpose.It does not change any of the variables, at least it should not.Therefore, do not use functions with side-effects in the Boolean-expression.If the a-option is turned on, then assertions are skipped by thecompiler. 'assert' is not a word-symbol (keyword) and may be used as identifier.However, assignment to a variable and calling of a procedure with thatname will be impossible.If the s-option is turned on, the compiler will not know a thing aboutassertions, so using assertions will then give a parse error..LP.ft I4. Additional procedures..LPThree additional standard procedures are available:.IP "halt:"a call of this procedure is equivalent to jumping to theend of your program.It is always the last statement executed.The exit status of the program may be suppliedas optional argument.If not, it will be zero..IP release:.IP mark:for most applications it is sufficient to use the heap as second stack.Mark and release are suited for this type of use, more suited than dispose.mark(p), with p of type pointer, stores the current value of theheap pointer in p. release(p), with p initialized by a callof mark(p), restores the heap pointer to its old value.All the heap objects, created by calls of new between the call ofmark and the call of release, are removed and the space they usedcan be reallocated.Never use mark and release together with dispose!.RE.LP.ft I5. UNIX interfacing..LPIf the c-option is turned on, then some special features are availableto simplify an interface with the UNIX environment.First of all, the compiler allows you to use a different typeof string constants.These string constants are delimited by double quotes ('"').To put a double quote into these strings, you must repeat the double quote,like the single quote in normal string constants.These special string constants are terminated by a zero byte (chr(0)).The type of these constants is a pointer to a packed array of characters,with lower bound 1 and unknown upper bound..brSecondly, the compiler predefines a new type identifier 'string' denotingthis just described string type..PPThe only thing you can do with these features is declaration ofconstants and variables of type 'string'.String objects may not be allocated on the heap and string pointersmay not be de-referenced.Still these strings are very useful in combination with external routines.The procedure write is extended to print these zero-terminatedstrings correctly..LP.ft I6. Double length (32 bit) integers..LPIf the d-option is turned on, then the additional type 'long' is knownto the compiler.Long variables have integer values in therange \(mi2147483648 .. +2147483647.Long constants can not be declared.Longs can not be used as control-variables.It is not allowed to form subranges of type long.All operations allowed on integers are alsoallowed on longs and are indicated by the sameoperators: '+', '-', '*', '/', 'div', 'mod'.The procedures read and write have been extended to handle longarguments correctly.It is possible to read longs from a file of integersand vice-versa, but only if longs and integers have the same size.The default width for longs is 11.The standard procedures 'abs' and 'sqr' have been extended to workon long arguments.Conversion from integer to long, long to real,real to long and long to integer are automatic, like the conversionfrom integer to real.These conversions may cause a.PP.RSconversion error, trap 10, non-fatal.RE.LP.ft I7. Underscore as letter..LPThe character '_' may be used in forming identifiers, if the u- or U-optionis turned on.It is forbidden to start identifiers with underscores, sincethis may cause name-clashes with run-time routines..LP.ft I8. Zero field width in write..LPZero TotalWidth arguments are allowed.In this case, no characters are written forcharacter, string or Boolean type arguments.A zero FracDigitsargument for fixed-point representation of reals causes the fraction andthe character '.' to be suppressed..LP.ft I9. Pre-processing..LPIf the very first character of a file containing a Pascalprogram is the sharp ('#', ASCII 23(hex)) the file is preprocessedin the same way as C programs.Lines beginning with a '#' are taken as preprocessor command linesand not fed to the Pascal compiler proper.C style comments, /*......*/, are removed by the C preprocessor,thus C comments inside Pascal programs are also removed when theyare fed through the preprocessor..in 0.SS "Deviations from the standard".PP

⌨️ 快捷键说明

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