const { constants used by pnx-dependent code in modules 3 and 4 } MaxArgString = 60 ; { maximum size of argument string } MaxArgs = 6 ; { maximum number of arguments } BufferSize = 512 ; { disk buffer size in bytes } Null = 0 ; { ASCII null character } BackSpace = 8 ; { ASCII back-space character } Tab = 9 ; { ASCII tab character } NewLine = 10 ; { ASCII new line character } FormFeed = 12 ; { ASCII form-feed character } CarriageReturn = 13 ; { ASCII carriage-return character } BackSlash = 92 ; { ASCII back-slash character } { constants used by the option-handler, module 3 } Level0 = 0 ; { conform to ISO 7185, level 0 } Level1 = 1 ; { conform to ISO 7185, level 1 } Level2 = 2 ; { conform to ICL Pascal, level 2 } Level3 = 3 ; { conform to ICL Pascal, level 3 } OptionFlag = '$' ; { introduce option-list } OptionSize = 12 ; { size of string below } UnknownOption = ' ' ; { denotes unknown option } FileWarning = 'Error summary not found.' ; { constants exported from the source handler, module 5 } LinesPerPage = 60 ; { source-text lines per page } BannerTitleSize = 24 ; { length of banner titles } ProgName = 'ICL Pascal - Version v.r' ; VerNumPos = 22 ; { position of 'v' in above } RelNumPos = 24 ; { position of 'r' in above } VerNum = 4 ; { compiler version } RelNum = 1 ; { compiler release } LineMax = 132 ; { maximum length of source line } StartCode = 0 ; { analysis error code base } MaxCode = 499 ; { total error range: 0..499 } AnalysisBase = StartCode ; { analysis errors: 1..300 } PredictedBase = 300 ; { runtime errors : 301..400 } SystemBase = 400 ; { system limit errors: 401..420 } FatalBase = 420 ; { fatal errors: 421..450 } OptionBase = 450 ; { option errors: 451..470 } PragmaticBase = 470 ; { pragmatic errors: 471..490 } WarningBase = 490 ; { warning errors: 491..500 } LinesPerText = 2 ; { lines per error text } { constant used by the object-program generator interface, module 6 } MaxWord = 2147483647; { 2**31- 1 } { constant used by the diagnostics handler, module 6 } NilSerial = 0 ; { unallocated serial number } { constants used by the lexical analyser, module 8 } NoWords = 54 ; { upper bound of word symbol table } AlfaSize = 12 ; { size of alfa header string } ChunkLength = 4 ; { size of trailing alfa chunks } DefaultSpelling = '????????????' ; { default alfa-header } { constants used in semantic analysis, module 10 } DispLimit = 20 ; { upper bound of display } GlobalLevel = 1 ; { scope level of program block } type { types used by unix-dependent code in module 3 and 4 } ArgIndex = 1..MaxArgString; ArgSize = 0..MaxArgString; ArgString = packed array[ArgIndex] of char; ArgStringPtr = ^ ArgString; ArgArray = array[0..MaxArgs] of ArgStringPtr; ArgPointer = ^ ArgArray; FileMode = (ForReading, ForWriting, ForBoth); BufferPosition = 1..BufferSize; FileBuffer = packed array[BufferPosition] of char; UnixFile = record Buffer: FileBuffer; Descriptor, FileAddress: integer; StartOfLine, EndOfLine, EndOfBuffer, BufferIndex: BufferPosition; Mode: FileMode; EofFlag: Boolean end; ImportEntry = ^ ImportRecord; ImportRecord = record FileName: ArgString; Next: ImportEntry end; { types applied globally } HostWord = integer ; Scalar = 0..maxint ; DeclKind = ( Predefined,Declared ) ; StdProcFuncs = (Getp,Putp,Resetp,Rewritep, Readp,Writep,Readlnp,Writelnp,Pagep, Newp,Disposep,Packp,Unpackp, Appendp,Linesp,Closep, Datep,Timep, Absf,Sqrf,Oddf,Succf,Predf,Ordf,Chrf,Truncf,Roundf, Sinf,Cosf,Expf,Lnf,Sqrtf,Arctanf,Eoff,Eolnf, Sizef,Ptrf,CPtrf,Wrdf,Intf,MinValf,MaxValf, AndWf,OrWf,NeqWf,NotWf,ShWf,RotWf,Floatf,Recastf) ; TypeForm = (Scalars,Subranges,Pointers,Arrays,CAPSchema, Records,Sets,Files,VariantPart,Variant) ; SetForms = ( Unpacked,IsPacked,Constructed ) ; IdClass = ( Domain,Types,Consts,Vars,Bound, PresetVars,ReadOnlyVars,Field,Proc,Func,Prog); { types used by the option-handler, module 3 } OptionContext = ( Locally,Globally) ; OptionClass = ( BoolClass,IntClass ) ; OptionType = ( Listing,Directives,Imports,Checks,PMDump, Level,Margin,Other ) ; BoolOptions = Listing..PMDump ; IntOptions = Level..Margin ; OptionIndex = 1..OptionSize ; OptionString = packed array[OptionIndex] of char ; SetOfOptions = set of OptionType ; ICLDirectives = (DoInclude,DoRead,DoPage,DoLines, DoHeading,DoList,DoNothing); DirectiveString = OptionString; { types used by the source-handler, module 5 } PageDepth = 0..LinesPerPage; BannerPositions = 1..BannerTitleSize ; BannerString = packed array[BannerPositions] of char ; DateString = packed array[1..8] of char ; ErrorSpan = 0..MaxCode ; LinePosition = 1..LineMax ; TextPosition = record LineNumber : Scalar ; CharNumber : LinePosition end ; ErrorEntry = ^ErrorRecord ; ErrorRecord = record ErrorCode : ErrorSpan ; ErrorPosition : TextPosition ; Next : ErrorEntry end ; ErrorList = record First,Last : ErrorEntry end ; SourceEntry = ^ SourceRecord; SourceRecord = record SourceFile: UnixFile; FirstLine,BlankLine : Boolean ; FirstRead,FirstNonBlank,LastNonBlank, LastSignificant : BufferPosition ; Position : TextPosition ; ErrorsToReport,ErrorStarted : Boolean ; ErrorsOnThisLine,EarlierErrors : ErrorList ; Control: SetOfOptions; Next: SourceEntry end ; { types used by the object-program generator interface, module 6 } GeneratorDefined = integer ; ICLWord = 0..MaxWord; Cast = (AsInteger,AsWord) ; ObjectValue = record case Cast of AsInteger : ( IVal : integer) ; AsWord : ( WVal : ICLWord ); end; ValueKind = (OrdValue,IntValue,BoolValue,CharValue,RealValue, BaseValue,SetValue,StringValue,PntrValue) ; ValueDetails = record Velue : ObjectValue ; case Kind : ValueKind of OrdValue : ( IVal : integer ) ; BaseValue, IntValue, BoolValue, CharValue, RealValue, SetValue, StringValue: ( Length : 0..LineMax ; String : packed array [1..LineMax] of char) ; PntrValue : ( ) end ; RunTimeAddress = GeneratorDefined ; FieldOffset = GeneratorDefined ; BlockLabel = GeneratorDefined ; StatementLabel = GeneratorDefined ; TypeRepresentation = GeneratorDefined ; CodeLabel = GeneratorDefined ; StackTop = (TopOfStack,NextToTop) ; OutputKind = (IntKind,RealKind,CharKind,BoolKind, WordKind,StringKind,CAPKind,DefaultKind ) ; InputKind = IntKind..CharKind ; FormatKind = (Default,Floating,Fixed) ; IOFormat = (Standard,Named,Flagged,Repeated,Full); { types used by the diagnostics handler, module 7 } SerialRange = Scalar ; { types used by the lexical analyser, module 8 } SymbolType = (Ident,IntConst,RealConst,CharConst,StringConst,NilSy, NotSy,MulOp,AddOp,RelOp, LeftParent,RightParent,LeftBracket,RightBracket, Comma,Semicolon,Period,Arrow,Colon,Becomes,Thru, LabelSy,ConstSy,TypeSy,VarSy,FuncSy,ProcSy, PackedSy,ArraySy,RecordSy,SetSy,FileSy, BeginSy,IfSy,CaseSy,RepeatSy,WhileSy,ForSy,WithSy,GoToSy, EndSy,ThenSy,ElseSy,UntilSy,OfSy,DoSy,ToSy, ProgramSy,PresetOp, BasedConst,ExternSy,VisibleSy,PresetSy,ReadOnlySy, PragmaSy,OccupiesSy,OtherwiseSy,Bar,Shriek,OtherSy) ; OpType = ( Mul,RDiv,AndOp,IDiv,IMod,Plus,Minus,OrOp, LtOp,LeOp,GeOp,GtOp,NeOp,EqOp,InOp,NotOp, SingleOp,RangeOp ) ; AlfaIndex = 1..AlfaSize ; AlfaHead = packed array[AlfaIndex] of char ; AlfaEntry = ^AlfaRecord ; AlfaRecord = record Chunk : packed array[1..ChunkLength] of char ; NextChunk : AlfaEntry end ; Alfa = record Head : AlfaHead ; Tail : AlfaEntry end ; CharSet = set of char; BaseValues = 2..16; { type used by syntax analysis and recovery, module 9 } SetOfSymbols = set of SymbolType ; { types used in static semantic analysis, modules 10,11 } TypEntry = ^TypeRecord ; IdEntry = ^IdRecord ; FormalEntry = ^FormalRecord ; LabelEntry = ^LabelRecord ; ScopeCopy = ^ScopeRecord ; ListEntry = ^ListRecord ; ListRecord = record Id : IdEntry ; Next : ListEntry end ; IdList = record FirstEntry,LastEntry : ListEntry end ; IdSet = IdList ; CAPBound = record case Fixed: Boolean of false : (Address: RunTimeAddress); true : (Value: ObjectValue) end; TypeRecord = record Serial : SerialRange ; Occupying : TypEntry; Next : TypEntry ; Representation : TypeRepresentation ; case Form : TypeForm of Scalars : (case ScalarKind : DeclKind of Predefined : ( ) ; Declared : (FirstConst : IdEntry)) ; Subranges : (RangeType : TypEntry ; Min,Max : ObjectValue) ; Pointers : (DomainType : TypEntry) ; Sets : (FormOfset : SetForms ; BaseType : TypEntry ) ; Arrays : (PackedArray,StringConstant : Boolean ; AelType,InxType : TypEntry) ; CAPSchema : (PackedSchema,ValueSchema, FirstIndex, Bounded : Boolean ; CompType,InxSpec : TypEntry ; LowBound, HighBound: CAPBound ) ; Records : (FileFree,PackedRecord : Boolean ; FieldScope : IdEntry ; FixedPart : IdEntry ; VarPart : TypEntry) ; Files : (PackedFile,TextFile : Boolean ; FelType : TypEntry) ; VariantPart : (TagType : TypEntry ; TagField,SelectorField : IdEntry ; DefaultVariant,FirstVariant : TypEntry) ; Variant : (VarFileFree,Distinct : Boolean ; SubFixedPart : IdEntry ; NextVariant,SubVarPart : TypEntry ; VariantValue1, VariantValue2: ObjectValue) end ; SetOfIdClass = set of IdClass ; IdKind = (Actual,Formal) ; KindOfVar = (ValueParam,VarParam,LocalVar, ReadOnlyParam, ExternalVar, VisibleVar) ; KindOfBlock = (LocalBlock, VisibleBlock, ExternalBlock); ScopeNumber = integer ; IdRecord = record Serial : SerialRange ; Name : Alfa ; LastUse : ScopeNumber ; LeftLink,RightLink : IdEntry ; IdType : TypEntry ; case Klass : IdClass of Domain, Types : ( ) ; Consts: ( Values : ObjectValue ; SuccId : IdEntry ) ; PresetVars, ReadOnlyVars, Vars: ( VarKind : KindOfVar ; VarAddress : RunTimeAddress ) ; Field: ( Offset : FieldOffset ; Tag : Boolean ; NextField : IdEntry ) ; Bound : ( BdAddress : RunTimeAddress ; NextBound : IdEntry ) ; Proc, Func: ( case PfDecKind : DeclKind of Predefined: ( PfIndex : StdProcFuncs ) ; Declared: ( Formals : FormalEntry ; case PfKind : IdKind of Actual: ( CodeBody : BlockLabel ; Assignable : Boolean ; Assigned : Boolean ; BlockKind: KindOfBlock; Declaration : TextPosition ; case Forwrd : Boolean of false: ( Result : RunTimeAddress ) ; true : ( FormalScope : ScopeCopy )) ; Formal: ( FAddress : RunTimeAddress ))) ; Prog: ( ProgBody : BlockLabel ) end ; ParmKind = (BoundParm,ValueParm,VarParm,ProcParm,FuncParm,ReadOnlyParm) ; FormalRecord = packed record Next : FormalEntry ; Section : Scalar ; FormalType : TypEntry ; case Parm : ParmKind of ReadOnlyParm, BoundParm, ValueParm, VarParm : ( ) ; ProcParm, FuncParm : ( ItsFormals : FormalEntry ) end ; LabelDepth = 1..maxint ; LabelRecord = record LabelValue : ObjectValue ; NextLabel : LabelEntry ; LabelledCode : StatementLabel ; case Defined : Boolean of false : (Declaration : TextPosition ; MaxDepth : LabelDepth ) ; true : (case Accessible : Boolean of false : ( ) ; true : (DefinedDepth : LabelDepth ) ) end ; ProgPmEntry = ^ ProgPmRecord ; ProgPmRecord = record Name : Alfa ; Declaration : TextPosition ; ParamId : IdEntry ; NextParam : ProgPmEntry end ; ScopeKind = ( ActualBlock,FormalBlock,RecordScope ) ; ScopeRecord = record ScopeNo : ScopeNumber ; Locals : IdEntry ; case Scope : ScopeKind of ActualBlock, FormalBlock : ( Threatened : IdSet ; TypeChain : TypEntry ; LabelChain : LabelEntry ) ; RecordScope : ( RecordType : TypEntry ; ReadOnlyScope, FieldsPacked : Boolean ) end ; DispRange = 0..DispLimit ; RefSecurity = ( Secure,MayBeInsecure ) ; var { variables used by pnx-dependent code in modules 3 and 4 } Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, BlankString: ArgString; extern; pargc: integer; extern; pargv: ArgPointer; extern; { global variables used by the option-handler, module 3 } CodeIsToBeGenerated : Boolean ; extern; OptionCh : char; extern; Requested,LocallyRequested : SetOfOptions ; extern; OptionFile : text; extern; AnyWarningsToReport : Boolean ; extern; OptionWarning : BannerString ; extern; OptionValue : array[IntOptions] of integer ;extern; OptionMap : array[OptionType] of record Name : OptionString ; Option : OptionType ; Class : OptionClass end ; extern; InHousePascal, ICLPascal : Boolean ; extern; Directive: ICLDirectives; extern; DirChars: CharSet; extern; DirName: array[ICLDirectives] of DirectiveString; extern; { global variables used by the source-handler, module 5 } Heading, SubHeading: BannerString; extern; PageLayout: record Title,SubTitle,BoolOps,IntOps : BannerString ; Today, Now: DateString ; PageNum : Scalar ; LinesLeft: PageDepth end ; extern; Ch: char ; extern; Source : SourceEntry ; extern; ImportList : ImportEntry ; extern; ErrorCount : Scalar ; extern; Reported : packed array[ErrorSpan] of Boolean ; extern; SourceFile, ListFile, ErrorFile : text; extern; { global variables provided for use with the object } { code generator interface, module 6 } EmptyRepresentation, RealRepresentation,BooleanRepresentation, CharRepresentation,IntegerRepresentation, PtrRepresentation,DefaultRepresentation, WordRepresentation: TypeRepresentation ; extern; EightValue, NilValue,EmptyValue, FalseValue,TrueValue, ZeroValue,OneValue,MaxintValue, MinLabValue,MaxLabValue, MinCharValue,MaxCharValue, MaxWordValue,MaxRealValue,MaxSetValue, LineFeed,PageThrow, DftValue : ObjectValue ; extern; DftAddress : RunTimeAddress ; extern; DftOffset : FieldOffset ; extern; { global variables used by the diagnostics handler, module 7 } NextSerial : SerialRange; extern; { global variables used by the lexical analyser, module 8 } PrecedingPeriod, TailToBeDisposed : Boolean ; extern; Symbol : SymbolType ; extern; Operator : OpType ; extern; Constant : ValueDetails ; extern; Spelling : Alfa ; extern; StartOfSymbol : TextPosition ; extern; WordSymbol : array[1..NoWords] of record Spelling : AlfaHead ; SymbolValue : SymbolType ; OpValue : OpType end ; extern; LastOfLength : array[0..AlfaSize] of 0..NoWords ; extern; Letters, Digits, LettersAndDigits, UnixSpecials, LowerCaseLetters, SymbolStarters : CharSet; extern; DigitsForBase: array[BaseValues] of CharSet; extern; { global variables used in syntax analysis, modules 9,11 } ConstFacBegSys, BlockBegSys,TypeBegSys,ConstBegSys,SimpTypeBegSys,TypeDels, StatBegSys,FacBegSys,SelectSymbols,ParamBegSys, ConformantParamBegSys, IndexSpecBegSys : SetOfSymbols ; extern; SymbolsSkipped,Recovering,ErrorReported : Boolean ; extern; { global variables used by semantic analysis, modules 10,11 } IntType,RealType,BoolType,CharType,PtrType, TextType,NilType,EmptyType,WordType,NaturalType,Unknown : TypEntry ; extern; ScopeLevel,BlockLevel,LevelFound : DispRange ; extern; Display : array [DispRange] of ScopeRecord ; extern; DummyVarId : IdEntry ; extern; ControlVars : IdSet ; extern; NextScopeNo : ScopeNumber ; extern; Depth : LabelDepth ; extern; ExpType,VarType : TypEntry ; extern; VntSelector : TypEntry ; extern; PackedVar,SimpleVar,TagVar,NewRecVar : Boolean ; extern; InputFile,OutputFile : IdEntry ; extern; SystemSpelling: Alfa; extern;