SiroccoParser: Control Module; Wart: Module = Begin Generic: EnumeratedBaseType = {array, boolean, bulkDataSink, bulkDataSource, cardinal, choice, enumeration, error, integer, longCardinal, longInteger, procedure, record, sequence, string, unspecified}; identifier: GenericToken = "tokenID"; numberD: GenericToken = "tokenDECIMAL"; numberO: GenericToken = "tokenOCTAL"; numberH: GenericToken = "tokenHEX"; Rope: GenericToken = "tokenROPE"; BOOLEAN: CedarType; CARDINAL: CedarType; CARD: CedarType; NAT: CedarType; INT: CedarType; CComponent: CedarType From SiroccoPrivate; CType: CedarType From SiroccoPrivate; EqualProc: CedarType From HashTable; FunctionList: CedarType From SiroccoPrivate; HashProc: CedarType From HashTable; Key: CedarType From HashTable; ROPE: CedarType From Rope; SeqIndex: CedarType From HashTable; Table: CedarType From HashTable; TABLES: CedarType From SiroccoPrivate; Value: CedarType From HashTable; Cat: CedarFunction [ROPE.a, ROPE.b, ROPE.c] Returns [ROPE.d] From Rope; Concat: CedarFunction [ROPE.a, ROPE.b] Returns [ROPE.c] From Rope; Equal: CedarFunction [ROPE.a, ROPE.b] Returns [BOOLEAN] From Rope; Fetch: CedarFunction [Table, ROPE] Returns [BOOLEAN, Value] From HashTable; Length: CedarFunction [ROPE] Returns [INT] From Rope; Nest: CedarFunction [ROPE.a, NAT.level] Returns [ROPE.b] From SiroccoPrivate; NewFcn: CedarFunction [ROPE.name, ROPE.obj, INT.size] Returns [ROPE.out] From SiroccoPrivate; RopeFromCard: CedarFunction [CARD] Returns [ROPE] From Convert; RopeFromInt: CedarFunction [INT] Returns [ROPE] From Convert; End; ParserPrivate: Module = Begin card: BaseFunction [INT] Returns [CARD]; int: BaseFunction [CARD] Returns [INT]; nat: BaseFunction [INT] Returns [NAT]; GetCardFromDecimal: BaseFunction [numberD] Returns [CARD]; GetCardFromOctal: BaseFunction [numberO] Returns [CARD]; GetCardFromHex: BaseFunction [numberH] Returns [CARD]; RopeTokenToROPE: BaseFunction [Rope] Returns [ROPE]; CopyRope: BaseFunction [ROPE.a] Returns [ROPE.b]; CopyTables: BaseFunction [TABLES.ARG] Returns [TABLES.RES]; CopyAll: BaseFunction [ROPE.ARG, FunctionList.ARG, TABLES.ARG] Returns [ROPE.RES, FunctionList.RES, TABLES.RES]; CreateCanonicalKey: BaseFunction [identifier, numberD.prog, numberD.val] Returns [ROPE]; CreateKey: BaseFunction [identifier] Returns [ROPE]; CopyFunctionList: BaseFunction [FunctionList.ARG] Returns [FunctionList.RES]; CreateTables: BaseFunction Returns [TABLES]; DiskToTable: BaseFunction [TABLES.ARG, identifier, numberD.progno, numberD.verno] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; FetchFromGlobalTable: BaseFunction [TABLES.ARG, ROPE] Returns [Table]; CheckCanonicalType: BaseFunction [ROPE.type, ROPE.constant, TABLES.ARG] Returns [TABLES.RES]; CheckResultsForSourceAndSink: BaseFunction [CComponent] Returns [INT]; -- actually BOOLEAN CompareTypes: BaseFunction [CType.a, CType.b, TABLES] Returns [INT]; -- actually BOOLEAN GetCType: BaseFunction [identifier, CComponent, TABLES] Returns [CType, ROPE]; GetLengthOfCComponentList: BaseFunction [CComponent, INT.arg] Returns [INT.res]; SeeIfArrOrSeq: BaseFunction [CType.arg, INT, TABLES] Returns [CType.res, ROPE]; AddOne: BaseFunction [INT.arg] Returns [INT.res]; Add: BaseFunction [INT.a, INT.b] Returns [INT.c]; Subtract: BaseFunction [INT.a, INT.b] Returns [INT.c]; CopyCComponent: BaseFunction [CComponent.arg] Returns [CComponent.res]; GetCTypeFirstChild: BaseFunction [CType] Returns [CComponent]; MkCComponent: BaseFunction [ROPE.name, INT.valBinding, ROPE.typeBinding, CComponent.sibling] Returns [CComponent]; MkCType: BaseFunction [Generic.class, INT.bound, CComponent.firstChild] Returns [CType]; MkNILCComponent: BaseFunction [] Returns [CComponent]; ValueToConstant: BaseFunction [Value] Returns [Constant]; ValueToRope: BaseFunction [Value] Returns [ROPE]; ValueToRopeConstant: BaseFunction [Value] Returns [ROPE]; Copy: BaseFunction [ROPE.arg, CType.arg, Constant.arg, TABLES.arg] Returns [ROPE.res, CType.res, Constant.res, TABLES.res]; FetchFromTypeTable: BaseFunction [TABLES.ARG, ROPE] Returns [CType]; GetObjectName: BaseFunction [ROPE.type, TABLES] Returns [ROPE.typeobject]; Remove: BaseFunction [identifier, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; SendError: BaseFunction [ROPE] Returns [CARD]; IntoUnresolvedConstantTable: BaseFunction [TABLES.ARG, ROPE.key, Type.value, Constant.value] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; IntoUnresolvedTypeTable: BaseFunction [TABLES.ARG, ROPE.key, Type.value] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; ClearWorkTable: BaseFunction [TABLES.arg] Returns [TABLES.res] DamagedReps [TABLES.arg]; EnterNamesIntoWorkTable: BaseFunction [CType, TABLES.arg] Returns [TABLES.res] DamagedReps [TABLES.arg]; FillWorkTable: BaseFunction [CType, TABLES.arg] Returns [TABLES.res] DamagedReps [TABLES.arg]; LocalConstantToRope: BaseFunction [identifier, ROPE.constantType, TABLES.arg] Returns [ROPE.constant, TABLES.res] DamagedReps [TABLES.arg]; CanonicaliseLocalReferenceType: BaseFunction [identifier, TABLES.ARG] Returns [ROPE, CType, TABLES.RES] DamagedReps [TABLES.ARG]; GetConstantType: BaseFunction [identifier, TABLES.arg] Returns [ROPE, CType, Constant, TABLES.res] DamagedReps [TABLES.arg]; TryToCoerceNumber: BaseFunction [CType, CARD] Returns [INT]; Array: BaseFunction [ROPE.type, TABLES] Returns [BOOLEAN];-- Sees if type is array CheckIfEmpty: BaseFunction [TABLES.ARG] Returns [TABLES.RES]; CompareClass: BaseFunction [CType, Generic.b] Returns [CComponent]; InsureErrorType: BaseFunction [identifier, TABLES.ARG] Returns [TABLES.RES]; IsEnumerationConstant: BaseFunction [CType, identifier] Returns [INT]; NotEnumeration: BaseFunction [CType] Returns [BOOLEAN]; SeeIfDuplicated: BaseFunction [TABLES.ARG, identifier, CARD] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; SeeIfInt: BaseFunction [CType] Returns [BOOLEAN]; AddFunctionList: BaseFunction [Value, FunctionList.ARG] Returns [FunctionList.RES] DamagedReps [FunctionList.ARG]; AddFunctionToTable: BaseFunction [Value, FunctionList, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; ConsFunctionList: BaseFunction [FunctionList.arg, ROPE] Returns [FunctionList.res] DamagedReps [FunctionList.arg]; GetTypeOfComponent: BaseFunction [identifier, ROPE.arg, TABLES] Returns [ROPE.TypeOfComponent]; GetTypeOfElement: BaseFunction [ROPE.arg, TABLES] Returns [ROPE.TypeOfElement]; TypeOfSequence: BaseFunction [ROPE.sequenceName, TABLES] Returns [ROPE.TypeOfSequence]; End; AbstractTypes: Module = Begin Program: AbstractType [MakeSymbolTable]; ReferencedProgramList: AbstractType [ReadInTable]; ReferencedProgram: AbstractType [ReadInTable]; DeclarationList: AbstractType [BuildTable, RecordNames]; Declaration: AbstractType [BuildTable, RecordNames]; Type: AbstractType [CanonicaliseType]; CorrespondenceList: AbstractType [CanonicaliseCorrespondenceList, CheckCorrespondenceList]; CandidateList: AbstractType [CanonicaliseCandidateList, EmptyWorkTableOfNames]; FieldList: AbstractType [CanonicaliseFieldList]; -- I want a FIELD type (ajd) Constant: AbstractType [Coerce, GetCARDINAL, ConstantToRope]; ElementList: AbstractType [CoerceElementList, ElementListConstantToRope, Size]; ComponentList: AbstractType [CoerceComponents, ConstantToRope, CheckAllNames]; Component: AbstractType [CoerceComponents, ConstantToRope, CheckAllNames]; NameList: AbstractType [CheckIfErrorNames, CanonicaliseFieldsFromNameList, CoerceComponentNameList, NameListToRope, EmptyWorkTableOfNames, TypeOfNameList]; number: AbstractType [GetCARDINAL, NumberToCard]; BuildTable: TreeRecursiveFunction [Tree, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; CanonicaliseCandidateList: TreeRecursiveFunction [Tree, CComponent.arg, CType, TABLES.ARG] Returns [CComponent.res, TABLES.RES] DamagedReps [TABLES.ARG] SharedReps [CComponent.arg, CComponent.res]; CanonicaliseCorrespondenceList: TreeRecursiveFunction [Tree, CComponent.arg, TABLES.ARG] Returns [CComponent.res, TABLES.RES] DamagedReps [TABLES.ARG] SharedReps [CComponent.arg, CComponent.res]; CanonicaliseFieldList: TreeRecursiveFunction [Tree, CComponent.arg, TABLES.ARG] Returns [CComponent.res, TABLES.RES] DamagedReps [TABLES.ARG] SharedReps [CComponent.arg, CComponent.res]; CanonicaliseFieldsFromNameList: TreeRecursiveFunction [Tree, ROPE.arg, CComponent.arg, TABLES.ARG] Returns [CComponent.res, TABLES.RES] DamagedReps [TABLES.ARG] SharedReps [CComponent.arg, CComponent.res]; CanonicaliseType: TreeRecursiveFunction [Tree, TABLES.ARG] Returns [ROPE, CType, TABLES.RES] DamagedReps [TABLES.ARG]; CheckAllNames: TreeRecursiveFunction [Tree, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; CheckCorrespondenceList: TreeRecursiveFunction [Tree, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; CheckIfErrorNames: TreeRecursiveFunction [Tree, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; Coerce: TreeRecursiveFunction [Tree, CType, ROPE, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; CoerceComponentNameList: TreeRecursiveFunction [Tree, Constant, CComponent, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; CoerceComponents: TreeRecursiveFunction [Tree, CComponent, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; CoerceElementList: TreeRecursiveFunction [Tree, CType, ROPE, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; ConstantToRope: TreeRecursiveFunction [Tree, ROPE.arg, TABLES.arg] Returns [ROPE.res, TABLES.res] DamagedReps [TABLES.arg]; ElementListConstantToRope: TreeRecursiveFunction [Tree, ROPE.arg, TABLES.arg] Returns [ROPE.res, INT.length, TABLES.res] DamagedReps [TABLES.arg]; EmptyWorkTableOfNames: TreeRecursiveFunction [Tree, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; GetCARDINAL: TreeRecursiveFunction [Tree, TABLES.ARG] Returns [CARD, TABLES.RES] DamagedReps [TABLES.ARG]; MakeSymbolTable: TreeRecursiveFunction [Tree] Returns [TABLES.RES]; NumberToCard: TreeRecursiveFunction [Tree] Returns [CARD]; NameListToRope: TreeRecursiveFunction [Tree, ROPE.const] Returns [ROPE.res]; ReadInTable: TreeRecursiveFunction [Tree, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; RecordNames: TreeRecursiveFunction [Tree, TABLES.ARG] Returns [TABLES.RES] DamagedReps [TABLES.ARG]; ReturnNodeClass: TreeRecursiveFunction [Tree] Returns [Generic]; Size: TreeRecursiveFunction [Tree, INT.arg] Returns [INT.res] DamagedReps [INT.arg]; --Gets Size of Element List TypeOfNameList: TreeRecursiveFunction [Tree, ROPE.constantType, TABLES] Returns [ROPE.typeOf]; End; AbstractProductions: Module = Begin Program: AbstractProduction [identifier, numberD.progno, numberD.verno, ReferencedProgramList, DeclarationList]; ReferencedProgramList.empty: AbstractProduction []; ReferencedProgramList.more: AbstractProduction [ReferencedProgramList, ReferencedProgram]; ReferencedProgram: AbstractProduction [identifier, numberD.progno, numberD.verno]; DeclarationList.empty: AbstractProduction []; DeclarationList.more: AbstractProduction [DeclarationList, Declaration]; Declaration.type: AbstractProduction [identifier, Type]; Declaration.constant: AbstractProduction [identifier, Type, Constant]; Type.array: AbstractProduction [Constant, Type]; Type.boolean: AbstractProduction []; Type.bulkDataSink: AbstractProduction []; Type.bulkDataSource: AbstractProduction []; Type.cardinal: AbstractProduction []; Type.choice: AbstractProduction [Type, CandidateList]; Type.emptyRecord: AbstractProduction []; Type.enumeration: AbstractProduction [CorrespondenceList]; Type.error: AbstractProduction [FieldList]; Type.integer: AbstractProduction []; Type.localReference: AbstractProduction [identifier]; Type.longCardinal: AbstractProduction []; Type.longInteger: AbstractProduction []; Type.procedure: AbstractProduction [FieldList.arg, FieldList.res, NameList]; Type.record: AbstractProduction [FieldList]; Type.remoteReference: AbstractProduction [identifier.a, identifier.b]; Type.sequence: AbstractProduction [Constant, Type]; Type.string: AbstractProduction []; Type.unspecified: AbstractProduction []; CorrespondenceList.one: AbstractProduction [identifier, Constant]; CorrespondenceList.more: AbstractProduction [CorrespondenceList.value, CorrespondenceList.next]; CandidateList.one: AbstractProduction [NameList, Type]; CandidateList.more: AbstractProduction [CandidateList.value, CandidateList.next]; FieldList.empty: AbstractProduction []; FieldList.one: AbstractProduction [NameList, Type]; FieldList.more: AbstractProduction [FieldList.value, FieldList.rest]; Constant.choice: AbstractProduction [identifier, Constant]; Constant.componentlist: AbstractProduction [ComponentList]; Constant.elementList: AbstractProduction [ElementList]; Constant.empty: AbstractProduction []; Constant.false: AbstractProduction []; Constant.id: AbstractProduction [identifier]; Constant.negativeNumber: AbstractProduction [number]; Constant.number: AbstractProduction [number]; Constant.remoteReference: AbstractProduction [identifier.left, identifier.right]; Constant.string: AbstractProduction [Rope]; Constant.true: AbstractProduction []; Constant.unbounded: AbstractProduction []; ElementList.one: AbstractProduction [Constant]; ElementList.more: AbstractProduction [Constant, ElementList]; ComponentList.one: AbstractProduction [Component]; ComponentList.more: AbstractProduction [Component, ComponentList]; Component: AbstractProduction [NameList, Constant]; NameList.empty: AbstractProduction []; NameList.one: AbstractProduction [identifier]; NameList.more: AbstractProduction [identifier, NameList]; number.decimal: AbstractProduction [numberD]; number.hex: AbstractProduction [numberH]; number.octal: AbstractProduction [numberO]; End; AbstractSyntax: Module = Begin for Program: AbstractProduction [identifier, numberD.progno, numberD.verno, ReferencedProgramList, DeclarationList] let MakeSymbolTable[tree] _ BuildTable[DeclarationList, tables2] where tables2 _ ReadInTable[ReferencedProgramList, tables1] where programKey _ CreateCanonicalKey[identifier, numberD.progno, numberD.verno] where tables1 _ RecordNames[DeclarationList, tables] where tables _ CreateTables[] ; for ReferencedProgramList.empty: AbstractProduction [] let ReadInTable[tree, tables] _ CopyTables[tables] ; for ReferencedProgramList.more: AbstractProduction [ReferencedProgramList, ReferencedProgram] let ReadInTable[tree, tables] _ ReadInTable[ReferencedProgram, tables1] where tables1 _ ReadInTable[ReferencedProgramList, tables] ; for ReferencedProgram: AbstractProduction [identifier, numberD.progno, numberD.verno] let ReadInTable[tree, tables] _ DiskToTable[tables, identifier, numberD.progno, numberD.verno] ; for DeclarationList.empty: AbstractProduction [] let BuildTable[tree, tables] _ CopyTables[tables] let RecordNames[tree, tables] _ CopyTables[tables] ; for DeclarationList.more: AbstractProduction [DeclarationList, Declaration] let BuildTable[tree, tables] _ tables2 where tables2 _ BuildTable[DeclarationList, tables1] where tables1 _ BuildTable[Declaration, tables] let RecordNames[tree, tables] _ RecordNames[DeclarationList, RecordNames[Declaration, tables]] ; for Declaration.type: AbstractProduction [identifier, Type] let BuildTable[tree, tables] _ tables1 where < canonicalType, typeTree, tables1 > _ CanonicaliseLocalReferenceType[identifier, tables] let RecordNames[tree, tables] _ IntoUnresolvedTypeTable[tables, CreateKey[identifier], Type] ; for Declaration.constant: AbstractProduction [identifier, Type, Constant] let BuildTable[tree, tables] _ tables1 where < canonicalType, constantTree, value, tables1 > _ GetConstantType[identifier, tables] let RecordNames[tree, tables] _ IntoUnresolvedConstantTable[tables, CreateKey[identifier], Type, Constant] ; for Type.array: AbstractProduction [Constant, Type] let CanonicaliseType[tree, tables] _ < "DEFAULT", cType2, tables2 > where cType2 _ MkCType[Generic.array, int[bound], cComponent] where < bound, tables2 > _ GetCARDINAL[Constant, tables1] where cComponent _ MkCComponent["", 0, cName1, MkNILCComponent[]] where < cName1, cType1, tables1 > _ CanonicaliseType[Type, tables] ; for Type.boolean: AbstractProduction [] let CanonicaliseType[tree, tables] _ < "BOOLEAN", MkCType[Generic.boolean, 0, MkNILCComponent[]], CopyTables[tables] > ; for Type.bulkDataSink: AbstractProduction [] let CanonicaliseType[tree, tables] _ < "SINK", MkCType[Generic.bulkDataSink, 0, MkNILCComponent[]], CopyTables[tables] > ; for Type.bulkDataSource: AbstractProduction [] let CanonicaliseType[tree, tables] _ < "SOURCE", MkCType[Generic.bulkDataSource, 0, MkNILCComponent[]], CopyTables[tables] > ; for Type.cardinal: AbstractProduction [] let CanonicaliseType[tree, tables] _ < "CARDINAL", MkCType[Generic.cardinal, 0, MkNILCComponent[]], CopyTables[tables] > ; for Type.choice: AbstractProduction [Type, CandidateList] let CanonicaliseType[tree, tables] _ < "DEFAULT", cType2, tables5 > where cType2 _ MkCType[Generic.choice, 0, cComponent2] where cComponent2 _ MkCComponent["", 0, cName1, cComponent1] -- the tag type where < cComponent1, tables5 > _ CanonicaliseCandidateList[CandidateList, MkNILCComponent[], cType1, tables3] where junk _ CheckIfEmpty[tables3] where tables3 _ EmptyWorkTableOfNames[CandidateList, tables2] where tables2 _ FillWorkTable[cType1, tables1] where match _ CompareClass[cType1, Generic.enumeration] where < cName1, cType1, tables1 > _ CanonicaliseType[Type, tables] ; for Type.emptyRecord: AbstractProduction [] let CanonicaliseType[tree, tables] _ < "DEFAULT", cType, CopyTables[tables] > where cType _ MkCType[Generic.record, 0, MkNILCComponent[]] ; for Type.enumeration: AbstractProduction [CorrespondenceList] let CanonicaliseType[tree, tables] _ < "DEFAULT", cType, tables2 > where cType _ MkCType[Generic.enumeration, 0, cComponent] where < cComponent, tables2 > _ CanonicaliseCorrespondenceList[CorrespondenceList, MkNILCComponent[], tables1] where tables1 _ CheckCorrespondenceList[CorrespondenceList, ClearWorkTable[tables]] ; for Type.error: AbstractProduction [FieldList] let CanonicaliseType[tree, tables] _ < "DEFAULT", cType, tables1 > where cType _ MkCType[Generic.error, 0, cComponent] where < cComponent, tables1 > _ CanonicaliseFieldList[FieldList, MkNILCComponent[], tables] ; for Type.integer: AbstractProduction [] let CanonicaliseType[tree, tables] _ < "INTEGER", MkCType[Generic.integer, 0, MkNILCComponent[]], CopyTables[tables] > ; for Type.localReference: AbstractProduction [identifier] let CanonicaliseType[tree, tables] _ CanonicaliseLocalReferenceType[identifier, tables] ; for Type.longCardinal: AbstractProduction [] let CanonicaliseType[tree, tables] _ < "LONGCARDINAL", MkCType[Generic.longCardinal, 0, MkNILCComponent[]], CopyTables[tables] > ; for Type.longInteger: AbstractProduction [] let CanonicaliseType[tree, tables] _ < "LONGINTEGER", MkCType[Generic.longInteger, 0, MkNILCComponent[]], CopyTables[tables] > ; for Type.procedure: AbstractProduction [FieldList.arg, FieldList.res, NameList] let CanonicaliseType[tree, tables] _ < "DEFAULT", cType, tables3 > where cType _ MkCType[Generic.procedure, nArgs, cComponent] where nArgs _ GetLengthOfCComponentList[cComponent, nResults] where < cComponent, tables3 > _ CanonicaliseFieldList[FieldList.arg, resultCComponent, tables2] where nResults _ GetLengthOfCComponentList[resultCComponent, 0] where okay _ CheckResultsForSourceAndSink[resultCComponent] where < resultCComponent, tables2 > _ CanonicaliseFieldList[FieldList.res, MkNILCComponent[], tables1] where tables1 _ CheckIfErrorNames[NameList, tables] ; for Type.record: AbstractProduction [FieldList] let CanonicaliseType[tree, tables] _ < "DEFAULT", cType, tables1 > where cType _ MkCType[Generic.record, 0, cComponent] where < cComponent, tables1 > _ CanonicaliseFieldList[FieldList, MkNILCComponent[], tables] ; for Type.remoteReference: AbstractProduction [identifier.a, identifier.b] let CanonicaliseType[tree, tables] _ < canonicalName, cType, CopyTables[tables] > where cType _ FetchFromTypeTable[tables, canonicalName] where canonicalName _ ValueToRope[DirectoryEntry] where okay _ if successful then 0 else int[SendError["Undeclared Remote Identifier"]] where < successful, DirectoryEntry > _ Fetch[remoteDirectory, CreateKey[identifier.b]] where remoteDirectory _ FetchFromGlobalTable[tables, CreateKey[identifier.a]] ; for Type.sequence: AbstractProduction [Constant, Type] let CanonicaliseType[tree, tables] _ < "DEFAULT", cType2, tables2 > where cType2 _ MkCType[Generic.sequence, int[bound], cComponent] where < bound, tables2 > _ GetCARDINAL[Constant, tables1] where cComponent _ MkCComponent["", 0, cName1, MkNILCComponent[]] where < cName1, cType1, tables1 > _ CanonicaliseType[Type, tables] ; for Type.string: AbstractProduction [] let CanonicaliseType[tree, tables] _ < "STRING", MkCType[Generic.string, 0, MkNILCComponent[]], CopyTables[tables] > ; for Type.unspecified: AbstractProduction [] let CanonicaliseType[tree, tables] _ < "UNSPECIFIED", MkCType[Generic.unspecified, 0, MkNILCComponent[]], CopyTables[tables] > ; for CorrespondenceList.one: AbstractProduction [identifier, Constant] let CanonicaliseCorrespondenceList[tree, cComponentArg, tables] _ < cComponent, tables1 > where cComponent _ MkCComponent[CreateKey[identifier], int[value], "", cComponentArg] where < value, tables1 > _ GetCARDINAL[Constant, tables] let CheckCorrespondenceList[tree, tables] _ SeeIfDuplicated[tables1, identifier, value] where < value, tables1 > _ GetCARDINAL[Constant, tables] ; for CorrespondenceList.more: AbstractProduction [CorrespondenceList.value, CorrespondenceList.next] let CanonicaliseCorrespondenceList[tree, cComponentArg, tables] _ CanonicaliseCorrespondenceList[CorrespondenceList.value, cComponent1, tables1] where < cComponent1, tables1 > _ CanonicaliseCorrespondenceList[CorrespondenceList.next, cComponentArg, tables] let CheckCorrespondenceList[tree, tables] _ CheckCorrespondenceList[CorrespondenceList.next, CheckCorrespondenceList[CorrespondenceList.value, tables]] ; for CandidateList.one: AbstractProduction [NameList, Type] let CanonicaliseCandidateList[tree, cComponentArg, cTypeTag, tables] _ CanonicaliseFieldsFromNameList[NameList, variantCName, cComponentArg, tables1] where < variantCName, variantCType, tables1 > _ CanonicaliseType[Type, tables] let EmptyWorkTableOfNames[tree, tables] _ EmptyWorkTableOfNames[NameList, tables] ; for CandidateList.more: AbstractProduction [CandidateList.value, CandidateList.next] let CanonicaliseCandidateList[tree, cComponentArg, cTypeTag, tables] _ CanonicaliseCandidateList[CandidateList.value, cComponent1, cTypeTag, tables1] where < cComponent1, tables1 > _ CanonicaliseCandidateList[CandidateList.next, cComponentArg, cTypeTag, tables] let EmptyWorkTableOfNames[tree, tables] _ EmptyWorkTableOfNames[CandidateList.next, EmptyWorkTableOfNames[CandidateList.value, tables]] ; for FieldList.empty: AbstractProduction [] let CanonicaliseFieldList[tree, CComponentArg, tables] _ < CopyCComponent[CComponentArg], CopyTables[tables] > ; for FieldList.one: AbstractProduction [NameList, Type] let CanonicaliseFieldList[tree, cComponentArg, tables] _ CanonicaliseFieldsFromNameList[NameList, cName, cComponentArg, tables1] where < cName, cType, tables1 > _ CanonicaliseType[Type, tables] ; for FieldList.more: AbstractProduction [FieldList.value, FieldList.rest] let CanonicaliseFieldList[tree, CComponentArg, tables] _ CanonicaliseFieldList[FieldList.value, cComponent1, tables1] where < cComponent1, tables1 > _ CanonicaliseFieldList[FieldList.rest, CComponentArg, tables] ; for Constant.choice: AbstractProduction [identifier, Constant] let GetCARDINAL[tree, tables] _ < SendError["Expected CARDINAL found Choice"], CopyTables[tables] > let Coerce[tree, typeCtype, typeTypeName, tables] _ Coerce[Constant, cType, ctypeName, tables] where < cType, ctypeName > _ GetCType[identifier, cComponent, tables] where cComponent _ GetCTypeFirstChild[typeCtype] let ConstantToRope[tree, constantType, tables] _ < Cat[CreateKey[identifier], " ", value], tables1 > where < value, tables1 > _ ConstantToRope[Constant, constantType1, tables] where constantType1 _ GetTypeOfComponent[identifier, constantType, tables] ; for Constant.componentlist: AbstractProduction [ComponentList] let GetCARDINAL[tree, tables] _ < SendError["Expected CARDINAL found Record"], CopyTables[tables] > let Coerce[tree, typeCtype, typeTypeName, tables] _ CoerceComponents[ComponentList, cComponent, tables2] where junk _ CheckIfEmpty[tables2] where tables2 _ CheckAllNames[ComponentList, tables1] where tables1 _ EnterNamesIntoWorkTable[typeCtype, tables] where cComponent _ CompareClass[typeCtype, Generic.record] let ConstantToRope[tree, constantType, tables] _ ConstantToRope[ComponentList, constantType, tables] ; for Constant.elementList: AbstractProduction [ElementList] let GetCARDINAL[tree, tables] _ < SendError["Expected CARDINAL found ElementList"], CopyTables[tables] > let Coerce[tree, typeCtype, typeTypeName, tables] _ CoerceElementList[ElementList, cType, cName, tables] where < cType, cName > _ SeeIfArrOrSeq[typeCtype, numberOfElementInList, tables] where numberOfElementInList _ Size[ElementList, 0] let ConstantToRope[tree, constantType, tables] _ < Cat[lengthRope, " ", valueRope], tables1 > where lengthRope _ RopeFromInt[length] where < valueRope, length, tables1 > _ ElementListConstantToRope[ElementList, elementType, tables] where elementType _ GetTypeOfElement[constantType, tables] ; for Constant.empty: AbstractProduction [] let GetCARDINAL[tree, tables] _ < SendError["Expected CARDINAL found Empty ElementList"], CopyTables[tables] > let Coerce[tree, typeCtype, typeTypeName, tables] _ tables1 where junk _ CheckIfEmpty[tables1] where tables1 _ EnterNamesIntoWorkTable[typeCtype, tables] where cComponent _ CompareClass[typeCtype, Generic.record] let ConstantToRope[tree, constantType, tables] _ < "", CopyTables[tables] > ; for Constant.false: AbstractProduction [] let GetCARDINAL[tree, tables] _ < SendError["Expected CARDINAL found Boolean"], CopyTables[tables] > let Coerce[tree, type, typeTypeName, tables] _ CheckCanonicalType[typeTypeName, "BOOLEAN", tables] let ConstantToRope[tree, constantType, tables] _ < "FALSE ", CopyTables[tables] > ; for Constant.id: AbstractProduction [identifier] let GetCARDINAL[tree, tables] _ GetCARDINAL[value, tables1] where < constantType, constantTree, value, tables1 > _ GetConstantType[identifier, tables] let Coerce[tree, typeCtype, typeTypeName, tables] _ tables1 where match _ if Equal[typeTypeName, constantTypeName] then 0 else CompareTypes[typeCtype, ConstantCType, tables1] where < constantTypeName, ConstantCType, value, tables1 > _ if NotEnumeration[typeCtype] then GetConstantType[identifier, tables] else < Copy[typeTypeName, typeCtype, tree, tables] where junk _ IsEnumerationConstant[typeCtype, identifier] > let ConstantToRope[tree, constantType, tables] _ LocalConstantToRope[identifier, constantType, tables] ; for Constant.negativeNumber: AbstractProduction [number] let GetCARDINAL[tree, tables] _ < SendError["Expected CARDINAL found Negative Number"], CopyTables[tables] > let Coerce[tree, ctype, typeName, tables] _ tables1 where okay _ TryToCoerceNumber[ctype, value] where < value, tables1 > _ GetCARDINAL[number, tables] where junk _ SeeIfInt[ctype] let ConstantToRope[tree, constantType, tables] _ < Cat["-", RopeFromCard[NumberToCard[number]], " "], CopyTables[tables] > ; for Constant.number: AbstractProduction [number] let GetCARDINAL[tree, tables] _ GetCARDINAL[number, tables] let Coerce[tree, ctype, typeName, tables] _ tables1 where okay _ TryToCoerceNumber[ctype, value] where < value, tables1 > _ GetCARDINAL[number, tables] let ConstantToRope[tree, constantType, tables] _ < Concat[RopeFromCard[NumberToCard[number]], " "], CopyTables[tables] > ; for Constant.remoteReference: AbstractProduction [identifier.left, identifier.right] let GetCARDINAL[tree, tables] _ GetCARDINAL[value, tables] where value _ ValueToConstant[DirectoryEntry] where constantType _ ValueToRope[DirectoryEntry] where okay _ if successful then 0 else int[SendError["Undeclared Remote Identifier"]] where < successful, DirectoryEntry > _ Fetch[remoteDirectory, CreateKey[identifier.right]] where remoteDirectory _ FetchFromGlobalTable[tables, CreateKey[identifier.left]] let Coerce[tree, typeCtype, typeTypeName, tables] _ CopyTables[tables] where match _ if Equal[typeTypeName, constantTypeName] then 0 else CompareTypes[ConstantCType, typeCtype, tables] where value _ ValueToConstant[DirectoryEntry] where ConstantCType _ FetchFromTypeTable[tables, constantTypeName] where constantTypeName _ ValueToRope[DirectoryEntry] where < successful2, DirectoryEntry > _ Fetch[remoteDirectory, CreateKey[identifier.right]] where remoteDirectory _ FetchFromGlobalTable[tables, CreateKey[identifier.left]] let ConstantToRope[tree, constantType, tables] _ < ValueToRopeConstant[directoryEntry], CopyTables[tables] > where < successful2, directoryEntry > _ Fetch[remoteDirectory, CreateKey[identifier.right]] where remoteDirectory _ FetchFromGlobalTable[tables, CreateKey[identifier.left]] ; for Constant.string: AbstractProduction [Rope] let GetCARDINAL[tree, tables] _ < SendError["Expected CARDINAL found String"], CopyTables[tables] > let Coerce[tree, type, canonicalType, tables] _ CheckCanonicalType[canonicalType, "STRING", tables] let ConstantToRope[tree, constantType, tables] _ < Cat[lengthRope, " ", value], CopyTables[tables] > where lengthRope _ RopeFromInt[Subtract[Length[value], 3]] -- 3 = 2 quotes + trailing space where value _ Concat[RopeTokenToROPE[Rope], " "] ; for Constant.true: AbstractProduction [] let GetCARDINAL[tree, tables] _ < SendError["Expected CARDINAL found Boolean"], CopyTables[tables] > let Coerce[tree, type, typeTypeName, tables] _ CheckCanonicalType[typeTypeName, "BOOLEAN", tables] let ConstantToRope[tree, constantType, tables] _ < "TRUE ", CopyTables[tables] > ; for Constant.unbounded: AbstractProduction [] let GetCARDINAL[tree, tables] _ < card[65536], CopyTables[tables] > let Coerce[tree, type, canonicalType, tables] _ CheckCanonicalType[canonicalType, "UNBOUNDED", tables] let ConstantToRope[tree, constantType, tables] _ < "65536 ", CopyTables[tables] > ; for ElementList.one: AbstractProduction [Constant] let CoerceElementList[tree, cType, ctypeName, tables] _ Coerce[Constant, cType, ctypeName, tables] let Size[tree, numberOfElementInList] _ AddOne[numberOfElementInList] let ElementListConstantToRope[tree, elementType, tables] _ < value, 1, tables1 > where < value, tables1 > _ ConstantToRope[Constant, elementType, tables] ; for ElementList.more: AbstractProduction [Constant, ElementList] let CoerceElementList[tree, cType, ctypeName, tables] _ CoerceElementList[ElementList, cType, ctypeName, tables1] where tables1 _ Coerce[Constant, cType, ctypeName, tables] let Size[tree, numberOfElementInList] _ Size[ElementList, AddOne[numberOfElementInList]] let ElementListConstantToRope[tree, elementType, tables] _ < Concat[first, rest], AddOne[size], tables2 > where < rest, size, tables2 > _ ElementListConstantToRope[ElementList, elementType, tables1] where < first, tables1 > _ ConstantToRope[Constant, elementType, tables] ; for ComponentList.one: AbstractProduction [Component] let CoerceComponents[tree, cComponent, tables] _ CoerceComponents[Component, cComponent, tables] let ConstantToRope[tree, componentListType, tables] _ ConstantToRope[Component, componentListType, tables] let CheckAllNames[tree, tables] _ CheckAllNames[Component, tables] ; for ComponentList.more: AbstractProduction [Component, ComponentList] let CoerceComponents[tree, cComponent, tables] _ CoerceComponents[ComponentList, cComponent, tables1] where tables1 _ CoerceComponents[Component, cComponent, tables] let ConstantToRope[tree, componentListType, tables] _ < Concat[first, rest], tables2 > where < rest, tables2 > _ ConstantToRope[ComponentList, componentListType, tables1] where < first, tables1 > _ ConstantToRope[Component, componentListType, tables] let CheckAllNames[tree, tables] _ CheckAllNames[ComponentList, CheckAllNames[Component, tables]] ; for Component: AbstractProduction [NameList, Constant] let CoerceComponents[tree, cComponent, tables] _ CoerceComponentNameList[NameList, Constant, cComponent, tables] let ConstantToRope[tree, componentListType, tables] _ < NameListToRope[NameList, value], tables1 > where < value, tables1 > _ ConstantToRope[Constant, componentType, tables] where componentType _ TypeOfNameList[NameList, componentListType, tables] let CheckAllNames[tree, tables] _ EmptyWorkTableOfNames[NameList, tables] ; for NameList.empty: AbstractProduction [] let CheckIfErrorNames[tree, tables] _ CopyTables[tables] let CanonicaliseFieldsFromNameList[tree, cName, cComponentArg, tables] _ < MkNILCComponent[], CopyTables[tables] > let CoerceComponentNameList[tree, constant, cComponent, tables] _ CopyTables[tables] let NameListToRope[tree, constantRope] _ "" let EmptyWorkTableOfNames[tree, tables] _ CopyTables[tables] let TypeOfNameList[tree, constantType, tables] _ CopyRope[constantType] -- Should Yield Error ; for NameList.one: AbstractProduction [identifier] let CheckIfErrorNames[tree, tables] _ InsureErrorType[identifier, tables] let CanonicaliseFieldsFromNameList[tree, cName, cComponentArg, tables] _ < cComponentres, CopyTables[tables] > where cComponentres _ MkCComponent[CreateKey[identifier], 0, cName, cComponentArg] let CoerceComponentNameList[tree, constant, cComponent, tables] _ Coerce[constant, cType, ctypeName, tables] where < cType, ctypeName > _ GetCType[identifier, cComponent, tables] let NameListToRope[tree, constantRope] _ Cat[CreateKey[identifier], " ", constantRope] let EmptyWorkTableOfNames[tree, tables] _ Remove[identifier, tables] let TypeOfNameList[tree, constantType, tables] _ GetTypeOfComponent[identifier, constantType, tables] ; for NameList.more: AbstractProduction [identifier, NameList] let CheckIfErrorNames[tree, tables] _ CheckIfErrorNames[NameList, tables1] where tables1 _ InsureErrorType[identifier, tables] let CanonicaliseFieldsFromNameList[tree, cName, cComponentArg, tables] _ < cComponentres, CopyTables[tables1] > where cComponentres _ MkCComponent[CreateKey[identifier], 0, cName, cComponent1] where < cComponent1, tables1 > _ CanonicaliseFieldsFromNameList[NameList, cName, cComponentArg, tables] let CoerceComponentNameList[tree, constant, cComponent, tables] _ tables2 where tables2 _ CoerceComponentNameList[NameList, constant, cComponent, tables1] where tables1 _ Coerce[constant, cType, ctypeName, tables] where < cType, ctypeName > _ GetCType[identifier, cComponent, tables] let NameListToRope[tree, constantRope] _ Concat[first, rest] where rest _ NameListToRope[NameList, constantRope] where first _ Cat[CreateKey[identifier], " ", constantRope] let EmptyWorkTableOfNames[tree, tables] _ EmptyWorkTableOfNames[NameList, Remove[identifier, tables]] let TypeOfNameList[tree, constantType, tables] _ GetTypeOfComponent[identifier, constantType, tables] ; for number.decimal: AbstractProduction [numberD] let GetCARDINAL[tree, tables] _ < GetCardFromDecimal[numberD], CopyTables[tables] > let NumberToCard[tree] _ GetCardFromDecimal[numberD] ; for number.hex: AbstractProduction [numberH] let GetCARDINAL[tree, tables] _ < GetCardFromHex[numberH], CopyTables[tables] > let NumberToCard[tree] _ GetCardFromHex[numberH] ; for number.octal: AbstractProduction [numberO] let GetCARDINAL[tree, tables] _ < GetCardFromOctal[numberO], CopyTables[tables] > let NumberToCard[tree] _ GetCardFromOctal[numberO] ; End; ConcreteSyntax: Module = Begin { "ARRAY" "BEGIN" "BOOLEAN" "CARDINAL" "CHOICE" "DEPENDS" "END" "ERROR" "FALSE" "INTEGER" "LONG" "OF" "PROCEDURE" "PROGRAM" "RECORD" "REPORTS" "RETURNS" "SEQUENCE" "SINK" "SOURCE" "STRING" "TRUE" "TYPE" "UNSPECIFIED" "UPON" "VERSION" }: SimpleTokens; { "(" ")" "[" "]" "{" "}" ":" "." ";" "=" "=>" "," "-" }: SimpleTokens; OuterProgram: NonTerminal Builds Program; for OuterProgram _ Program "." Build Program; Program: NonTerminal Builds Program; for Program _ identifier ":" "PROGRAM" numberD.a "VERSION" numberD.b "=" "BEGIN" DependencyList DeclarationList "END" Build Program[identifier, numberD.a, numberD.b, DependencyList, DeclarationList]; DependencyList: NonTerminal Builds ReferencedProgramList; for DependencyList.empty _ Build ReferencedProgramList.empty[]; for DependencyList.more_ "DEPENDS" "UPON" ReferencedProgramList ";" Build ReferencedProgramList; ReferencedProgramList: NonTerminal Builds ReferencedProgramList; for ReferencedProgramList.one _ ReferencedProgram Build ReferencedProgramList.more[ReferencedProgramList.empty[[ReferencedProgram, ReferencedProgram)], ReferencedProgram]; for ReferencedProgramList.more _ ReferencedProgramList "," ReferencedProgram Build ReferencedProgramList.more[ReferencedProgramList, ReferencedProgram]; ReferencedProgram: NonTerminal Builds ReferencedProgram; for ReferencedProgram _ identifier "(" numberD.a ")" "VERSION" numberD.b Build ReferencedProgram[identifier, numberD.a, numberD.b]; DeclarationList: NonTerminal Builds DeclarationList; for DeclarationList.a _ Build DeclarationList.empty[]; for DeclarationList .b_ DeclarationList Declaration Build DeclarationList.more[DeclarationList, Declaration]; Declaration: NonTerminal Builds Declaration; for Declaration.type _ identifier ":" "TYPE" "=" Type";" Build Declaration.type[identifier, Type]; for Declaration.constant _ identifier ":" Type "=" Constant ";" Build Declaration.constant[identifier, Type, Constant]; for Declaration.id _ identifier.name ":" Type "=" identifier.constant ";" Build Declaration.constant[identifier.name, Type, Constant.id[identifier.constant]]; Type: NonTerminal Builds Type; for Type.simple _ SimpleType Build SimpleType; for Type.ConstructedType _ ConstructedType Build ConstructedType; SimpleType: NonTerminal Builds Type; for SimpleType.predefinedType _ PredefinedType Build PredefinedType; for SimpleType.referencedType _ ReferencedType Build ReferencedType; PredefinedType: NonTerminal Builds Type; for PredefinedType.boolean _ "BOOLEAN" Build Type.boolean[]; for PredefinedType.Cardinal _ "CARDINAL" Build Type.cardinal[]; for PredefinedType.longCardinal _ "LONG" "CARDINAL" Build Type.longCardinal[]; for PredefinedType.integer_ "INTEGER" Build Type.integer[]; for PredefinedType.longInteger _ "LONG" "INTEGER" Build Type.longInteger[]; for PredefinedType.string _ "STRING" Build Type.string[]; for PredefinedType.unspecified _ "UNSPECIFIED" Build Type.unspecified[]; for PredefinedType.bulkDataSource _ "SOURCE" Build Type.bulkDataSource[]; for PredefinedType.bulkDataSink _ "SINK" Build Type.bulkDataSink[]; ConstructedType: NonTerminal Builds Type; for ConstructedType.enumeration _ "{" CorrespondenceList "}" Build Type.enumeration[CorrespondenceList]; for ConstructedType.array _ "ARRAY" MandatoryNumber "OF" SimpleType Build Type.array[MandatoryNumber, SimpleType]; for ConstructedType.sequence _ "SEQUENCE" OptionalNumber "OF" SimpleType Build Type.sequence[OptionalNumber, SimpleType]; --Can be empty for ConstructedType.record _ "RECORD" "[" FieldList"]" Build Type.record[FieldList]; for ConstructedType.emptyRecord _ "RECORD" "[" "]" Build Type.emptyRecord[]; for ConstructedType.choice _ "CHOICE" ReferencedType "OF" "{" CandidateList "}" Build Type.choice[ReferencedType, CandidateList]; for ConstructedType.procedure _ "PROCEDURE" ArgumentList ResultList ErrorList Build Type.procedure[ArgumentList, ResultList, ErrorList]; for ConstructedType.error _ "ERROR" ArgumentList Build Type.error[ArgumentList]; ReferencedType: NonTerminal Builds Type; for ReferencedType.localReference _ identifier Build Type.localReference[identifier]; for ReferencedType.remoteReference _ identifier.remote "." identifier.id Build Type.remoteReference[identifier.remote, identifier.id]; CorrespondenceList: NonTerminal Builds CorrespondenceList; for CorrespondenceList.one _ Correspondence Build Correspondence; for CorrespondenceList.more _ Correspondence "," CorrespondenceList Build CorrespondenceList.more[Correspondence, CorrespondenceList]; Correspondence: NonTerminal Builds CorrespondenceList; for Correspondence _ identifier "(" MandatoryNumber ")" Build CorrespondenceList.one[identifier, MandatoryNumber]; OptionalNumber: NonTerminal Builds Constant; for OptionalNumber.nonEmpty _ Constant Build Constant; for OptionalNumber.localReference _ identifier Build Constant.id[identifier]; for OptionalNumber.empty _ Build Constant.unbounded[]; MandatoryNumber: NonTerminal Builds Constant; for MandatoryNumber.value _ Constant Build Constant; for MandatoryNumber.localReference _ identifier Build Constant.id[identifier]; CandidateList: NonTerminal Builds CandidateList; for CandidateList.one _ Candidate Build Candidate; for CandidateList.more _ Candidate "," CandidateList Build CandidateList.more[Candidate, CandidateList]; Candidate: NonTerminal Builds CandidateList; for Candidate.one _ NameList "=>" SimpleType Build CandidateList.one[NameList, SimpleType]; for Candidate.two _ NameList "(" number ")" "=>" SimpleType Build CandidateList.one[NameList, SimpleType]; ArgumentList: NonTerminal Builds FieldList; for ArgumentList.a _ Build FieldList.empty[]; for ArgumentList.b _ "[" FieldList "]" Build FieldList; for ArgumentList.c _ "[" "]" Build FieldList.empty[]; ResultList: NonTerminal Builds FieldList; for ResultList.a _ Build FieldList.empty[]; for ResultList.b _ "RETURNS" "[" FieldList "]" Build FieldList; for ResultList.c _ "RETURNS" "[" "]" Build FieldList.empty[]; ErrorList: NonTerminal Builds NameList; for ErrorList.a _ Build NameList.empty[]; for ErrorList.b _ "REPORTS" "[" NameList "]" Build NameList; FieldList: NonTerminal Builds FieldList; for FieldList.a _ Field Build FieldList.more[Field, FieldList.empty[[Field, Field)]]; for FieldList.b _ Field "," FieldList Build FieldList.more[Field, FieldList]; Field: NonTerminal Builds FieldList; for Field _ NameList ":" SimpleType Build FieldList.one[NameList, SimpleType]; Constant: NonTerminal Builds Constant; for Constant.predefined _ PredefinedConstant Build PredefinedConstant; for Constant.constructed _ ConstructedConstant Build ConstructedConstant; for Constant.choiceConstant _ identifier Constant Build Constant.choice[identifier, Constant]; for Constant.choiceIdentifier _ identifier.first identifier.next Build Constant.choice[identifier.first, Constant.id[identifier.next]]; for Constant.remoteReference _ identifier.left "." identifier.right Build Constant.remoteReference[identifier.left, identifier.right]; PredefinedConstant: NonTerminal Builds Constant; for PredefinedConstant.true _ "TRUE" Build Constant.true[]; for PredefinedConstant.false _ "FALSE" Build Constant.false[]; for PredefinedConstant.number _ number Build Constant.number[number]; for PredefinedConstant.negativeNumber _ "-" number Build Constant.negativeNumber[number]; for PredefinedConstant.string _ Rope Build Constant.string[Rope]; ConstructedConstant: NonTerminal Builds Constant; for ConstructedConstant.elementList _ "[" ElementList "]" Build Constant.elementList[ElementList]; for ConstructedConstant.componentlist _ "[" ComponentList "]" Build Constant.componentlist[ComponentList]; for ConstructedConstant.empty _ "[" "]" Build Constant.empty[]; ElementList: NonTerminal Builds ElementList; for ElementList.one _ Constant Build ElementList.one[Constant]; for ElementList.more _ Constant "," ElementList Build ElementList.more[Constant, ElementList]; for ElementList.id _ identifier Build ElementList.one[Constant.id[identifier]]; for ElementList.idAndMore _ identifier "," ElementList Build ElementList.more[Constant.id[identifier], ElementList]; ComponentList: NonTerminal Builds ComponentList; for ComponentList.one _ Component Build ComponentList.one[Component]; for ComponentList.more _ Component "," ComponentList Build ComponentList.more[Component, ComponentList]; Component: NonTerminal Builds Component; for Component.more _ NameList ":" Constant Build Component[NameList, Constant]; for Component.one _ NameList ":" identifier Build Component[NameList, Constant.id[identifier]]; NameList: NonTerminal Builds NameList; for NameList.one _ identifier Build NameList.one[identifier]; for NameList.more _ identifier "," NameList Build NameList.more[identifier, NameList]; number: NonTerminal Builds number; for number.a _ numberD Build number.decimal[numberD]; for number.b _ numberO Build number.octal[numberO]; for number.c _ numberH Build number.hex[numberH] End. ŽSirocco.ThreeC4 Copyright c 1986 by Xerox Corporation. All rights reserved. Bhargava, August 12, 1986 11: 24: 02 pm PDT Bill Jackson (bj) August 18, 1986 4:13:16 pm PDT Demers, December 29, 1986 8:05:56 pm PST Tokens Types Primitive Types Imported Types Imported Procs SharedReps [ROPE.a, ROPE.b, ROPE.c, ROPE.d]; Since Casaba only understands INTs Get values from tokens Convince Casaba that things are not damaged Hash Key Functions Hash Table Operations Type Tree (lists) Operations Arithmetic Operations Canonical Type manipulation Narrowing from Values from Hash Tables Utility Functions Insert Key, Value pairs into Tables Work Table Functions Misc Functions Predicates Unknown Purpose... Abstract Types Abstract Type Operations NOTE: THIS PROBABLY DOES NOT NEED THE TABLES ARGUMENT/RESULT Program: AbstractType [MakeSymbolTable]; ReferencedProgramList: AbstractType [ReadInTable]; ReferencedProgram: AbstractType [ReadInTable]; DeclarationList: AbstractType [BuildTable, RecordNames]; Declaration: AbstractType [BuildTable, RecordNames]; Type: AbstractType [CanonicaliseType]; CorrespondenceList: AbstractType [CanonicaliseCorrespondenceList, CheckCorrespondenceList]; CandidateList: AbstractType [CanonicaliseCandidateList, EmptyWorkTableOfNames]; FieldList: AbstractType [CanonicaliseFieldList]; -- I want a FIELD type (ajd) Constant: AbstractType [Coerce, GetCARDINAL, ConstantToRope]; ElementList: AbstractType [CoerceElementList, ConstantToRope, Size]; ComponentList: AbstractType [CoerceComponents, ConstantToRope, CheckAllNames]; Component: AbstractType [CoerceComponents, ConstantToRope, CheckAllNames]; NameList: AbstractType [CheckIfErrorNames, CanonicaliseFieldsFromNameList, CoerceComponentNameList, NameListToRope, EmptyWorkTableOfNames, TypeOfNameList]; number: AbstractType [GetCARDINAL, NumberToCard]; Program: AbstractType [MakeSymbolTable]; ReferencedProgramList: AbstractType [ReadInTable]; ReferencedProgram: AbstractType [ReadInTable]; DeclarationList: AbstractType [BuildTable, RecordNames]; Declaration: AbstractType [BuildTable, RecordNames]; Type: AbstractType [CanonicaliseType]; N.B. Type is a simple type, so no need to check if cName1 = "DEFAULT" Check that cType1 is enumerated type - Done N.B. NEED TO CHECK SUCCESSFUL !!!! - Done N.B. Type is a simple type, so no need to check if cName1 = "DEFAULT" CorrespondenceList: AbstractType [CanonicaliseCorrespondenceList, CheckCorrespondenceList]; Check that no id or Constant appears twice -Done INVARIANT: CorrespondenceList.value is expanded as CorrespondenceList.one. CandidateList: AbstractType [CanonicaliseCandidateList, EmptyWorkTableOfNames]; Check if all members are of enumeration & all members of enumeration are listed also ascertain that the enumeration is continous - Done INVARIANT: CandidateList.value is expanded as CandidateList.one. FieldList: AbstractType [CanonicaliseFieldList]; -- I want a FIELD type (ajd) INVARIANT: FieldList.value is expanded as FieldList.one. Constant: AbstractType [Coerce, GetCARDINAL, ConstantToRope]; N.B. Add Code to Check If All Names are Declared => CheckAllNames[ComponentList, typeCtype, tables]; - Done ElementList: AbstractType [CoerceElementList, ConstantToRope, Size]; ComponentList: AbstractType [CoerceComponents, ConstantToRope, CheckAllNames]; Component: AbstractType [CoerceComponents, ConstantToRope, CheckAllNames]; NameList: AbstractType [CheckIfErrorNames, CanonicaliseFieldsFromNameList, CoerceComponentNameList, NameListToRope, EmptyWorkTableOfNames, TypeOfNameList]; number: AbstractType [GetCARDINAL, NumberToCard]; Simple Tokens The Courier Program in Question: Type Declaration Constant RefConst (id.id) as well as id id ... id.id ʘ– "cedar" style˜code™Kšœ Ïmœ0™;K™+K™0K™(K™—KšÏn Ït˜K˜šžœŸœ˜K˜KšžœÂ˜Éšœ™K˜Kšœ%˜%K˜'K˜%K˜#Kšžœ˜!K˜—šœ™K™™K˜KšÏkœ ˜Kš œ ˜Kš œ ˜Kš œ ˜Kš œ ˜K˜—™K™Kšž œ ˜*Kšžœ ˜%Kšž œ˜$Kšž œ ˜,Kšžœ˜#Kšžœ˜Kš œ˜Kšžœ˜#Kšžœ˜ Kš œ ˜&Kšžœ˜ —K™™K˜š žœ œ œ œ  œ˜GKšœ,™,—Kšžœ œ œ  œ˜BKšžœ œ œ  œ ˜BKšžœ œ  œ˜KKšžœ œ  œ ˜5Kšžœ œ œ œ˜MKš žœ œ œ œ œ˜]Kšž œ œ  œ˜?Kšž œ œ  œ˜=——K˜K˜K˜—šž Ÿ œ˜K˜šœ"™"K˜Kšžœ œ  œ˜)Kšžœ œ  œ˜(KšÏbœ œ  œ˜'K˜—™K˜Kšžœ" œ˜:Kšžœ" œ˜8Kšžœ" œ˜6Kšžœ œ˜4K˜—™+K˜Kšžœ œ  œ˜1Kš ž œ œ œ  œ œ˜;Kšžœ œ œ œ œ œ  œ œ œ œ œ˜p—K˜™K˜Kšžœ@ œ˜XKšž œ% œ˜4K™—™K˜Kšžœ œ œ˜MKšž œ œ˜,Kšž œ œ œ6 œ œ œ œ˜€Kšžœ œ œ œ˜FK™—™K˜Kšžœ œ œ  œ œ  œ œ˜]Kšžœ% œÏc˜ZKšž œ" œ  œ¢˜XKšžœ( œ œ˜NKšžœ œ œ˜PKšž œ œ œ œ˜O—K™™K˜Kšžœ œ œ˜1Kšžœ œ œ  œ˜1Kšžœ œ œ  œ˜6—K˜™K™Kšžœ9˜GKšžœ,˜>Kšž œ œ œ  œ7˜rKšžœ œ/˜XKšžœ'˜6—K™™&K™Kšžœ*˜9Kšž œ  œ˜1Kšžœ  œ˜9K˜—™K™Kš žœ œ œ œ œ˜{Kšžœ œ œ œ˜DKšž œ œ œ  œ ˜JKšžœ œ œ  œ œ œ œ˜\Kšž œ œ  œ˜/—K™™#K™Kšžœ œ œ œ+ œ œ œ œ˜‹šžœ œ œ œ œ œ œ œ˜xK˜——™K™Kšžœ œ œ œ˜XKšžœ œ œ œ˜hKšž œ œ œ œ˜^K˜—™K™Kš žœ œ œ œ  œ œ˜‹Kšžœ œ œ  œ  œ œ œ œ˜Kš žœ œ œ œ œ˜|Kšžœ œ  œ˜˜>Kšœc˜cšœ^˜^KšœE˜EKšœ0˜0—šœd˜dKšœJ˜JKšœJ˜J—Kšœ˜K˜—šœ>˜>Kšœc˜cšœi˜iKšœk™kKšœ"˜"Kšœ5˜5Kšœ:˜:Kšœ:˜:—Kšœd˜dKšœ˜K˜—šœ:˜:Kšœh˜hšœh˜hKšœP˜PKšœ2˜2—šœ]˜]Kšœ&˜&Kšœb˜bKšœ:˜:—Kšœ˜K˜—šœ)˜)Kšœn˜nšœ;˜;Kšœ"˜"Kšœ:˜:Kšœ:˜:—KšœK˜KKšœ˜K˜—šœ)˜)Kšœd˜dKšœb˜bKšœQ˜QKšœ˜K˜—šœ0˜0šœ;˜;KšœZ˜Z—šœ;˜;šœ˜šœ(˜(Kšœ˜Kšœ5˜5——šœ;˜;šœ˜Kšœ(˜(˜šœ+˜+Kšœ9˜9—K˜————Kšœf˜fKšœ˜K˜—šœ8˜8Kšœl˜lšœ3˜3Kšœ,˜,Kšœ6˜6Kšœ˜—Kšœz˜zKšœ˜K˜—šœ0˜0Kšœ;˜;šœ3˜3Kšœ,˜,Kšœ6˜6—Kšœx˜xKšœ˜K˜—šœT˜Tšœ:˜:Kšœ-˜-Kšœ0˜0šœ˜Kšœ˜Kšœ3˜3—KšœZ˜ZKšœP˜P—šœF˜Fšœ6˜6Kšœ˜Kšœ4˜4—Kšœ-˜-KšœB˜BKšœ4˜4Kšœ[˜[KšœP˜P—šœl˜lKšœ[˜[KšœP˜P—Kšœ˜K˜—šœ.˜.Kšœc˜cKšœc˜cšœd˜dKšœ;¢ ˜[Kšœ0˜0—Kšœ˜K˜—šœ(˜(Kšœd˜dKšœb˜bKšœP˜PKšœ˜K˜—šœ-˜-KšœC˜CKšœf˜fKšœQ˜QKšœ˜—K˜—šž œ9™DK™šœ2˜2Kšœb˜bKšœE˜EšœP˜PKšœH˜H—Kšœ˜K˜—šœ@˜@šœq˜qKšœ:˜:—KšœX˜Xšœi˜iKšœ\˜\KšœH˜H—K˜—K™—šž œA™NK™šœ5˜5Kšœ`˜`Kšœj˜jKšœB˜BKšœ˜K˜—šœE˜Ešœe˜eKšœ?˜?—šœV˜VKšœS˜SKšœO˜O—Kšœ`˜`K˜—K™—šž œA™JK™šœž œ)˜6Kšœp˜pšœb˜bKšœJ˜JKšœI˜I—KšœI˜IK˜—K™—šžœ“™›K˜šœ)˜)Kšœ8˜8Kšœr˜rKšœT˜TKšœ+˜+Kšœ<˜