<> <> <> DIRECTORY Asserting, Atom, BasicTime, Convert, EDIFAndCore, EDIFAndCorePrivate, HashTable, IO, Rope; EDIFCelling: CEDAR PROGRAM IMPORTS Asserting, Atom, EDIFAndCore, EDIFAndCorePrivate, HashTable, IO, Rope EXPORTS EDIFAndCorePrivate = {OPEN EDIFAndCore, EDIFAndCorePrivate; ParseCell: PUBLIC PROC [ec: EDIFConversion, lexed: LORA, context: ROPE] RETURNS [ct: CoreCellType] = { me: ROPE _ Rope.Cat["a cell definition in ", context]; cc: CellConversion = NEW [CellConversionPrivate _ [ ec: ec, views: HashTable.Create[equal: HashTable.RopeEqualModCase, hash: HashTable.HashRopeModCase] ]]; stdTail: StdTail _ []; nameATOM: ATOM; name: ROPE; CheckLength[lexed, me, 2]; CheckHead[lexed, $cell, me]; nameATOM _ ToATOM[lexed.rest.first, me.Concat[" doesn't have a sensible name"]]; name _ Atom.GetPName[nameATOM]; me _ Rope.Cat["cell ", name, " in ", context]; FOR lexed _ lexed.rest.rest, lexed.rest WHILE lexed # NIL DO innerMe: ROPE = Rope.Cat["statement in ", me]; part: LORA = ToLORA[lexed.first, me.Cat[" contains a non-statement"]]; key: ATOM; CheckLength[part, innerMe, 1]; key _ ToATOM[part.first, innerMe.Cat[" doesn't begin with a keyword"]]; SELECT LcA[key] FROM $status => { IF cc.status # NIL THEN Error[Rope.Cat["Multiple status specifications in ", me]]; cc.status _ ParseStatus[part, me]; }; $viewmap => { IF cc.viewMap # NIL THEN Error[Rope.Cat["Multiple view maps in ", me]]; cc.viewMap _ ParseViewMap[ec, part, me]; }; $view => { ParseView[cc, part, me]; }; $comment => { c: Comment = ParseComment[part, me]; [cc.comments, stdTail.c] _ CAppend[cc.comments, stdTail.c, c]; }; $userdata => { ue: UserExtension = ParseUserExtension[part, me]; [cc.ues, stdTail.ues] _ UEAppend[cc.ues, stdTail.ues, ue]; }; ENDCASE => Error[IO.PutFR["%g statement found in %g", [atom[key]], [rope[me]] ]]; ENDLOOP; ec _ ec; }; ParseView: PROC [cc: CellConversion, lexed: LORA, context: ROPE] = { me: ROPE _ Rope.Cat["a view of ", context]; stdTail: StdTail _ []; typeATOM, nameATOM: ATOM; type: ViewType; name: ROPE; v: View; CheckLength[lexed, me, 3]; CheckHead[lexed, $view, me]; typeATOM _ ToATOM[lexed.rest.first, me.Concat[" doesn't have a sensible ViewType"]]; type _ SELECT LcA[typeATOM] FROM $masklayout => MaskLayout, $netlist => Netlist, $schematic => Schematic, $symbolic => Symbolic, $behavior => Behavior, $document => Document, $stranger => Stranger, ENDCASE => Error[me.Concat[" doesn't have a sensible ViewType"]]; nameATOM _ ToATOM[lexed.rest.rest.first, me.Concat[" doesn't have a sensible name"]]; name _ Atom.GetPName[nameATOM]; me _ Rope.Cat["cell ", name, " in ", context]; v _ NEW [ViewPrivate _ [ type: type, name: name ]]; FOR lexed _ lexed.rest.rest.rest, lexed.rest WHILE lexed # NIL DO innerMe: ROPE = Rope.Cat["statement in ", me]; part: LORA = ToLORA[lexed.first, me.Cat[" contains a non-statement"]]; key: ATOM; CheckLength[part, innerMe, 1]; key _ ToATOM[part.first, innerMe.Cat[" doesn't begin with a keyword"]]; SELECT LcA[key] FROM $status => { IF v.status # NIL THEN Error[Rope.Cat["Multiple status specifications in ", me]]; v.status _ ParseStatus[part, me]; }; $interface => { IF v.interfaceSeen THEN Error[Rope.Cat["Multiple interfaces to ", me]]; v.interfaceSeen _ TRUE; Handle[cc, v, part, Interface, me]; }; $contents => { IF v.contentsSeen THEN Error[Rope.Cat["Multiple contents to ", me]]; v.contentsSeen _ TRUE; Handle[cc, v, part, Contents, me]; }; $comment => { c: Comment = ParseComment[part, me]; [v.comments, stdTail.c] _ CAppend[v.comments, stdTail.c, c]; }; $userdata => { ue: UserExtension = ParseUserExtension[part, me]; [v.ues, stdTail.ues] _ UEAppend[v.ues, stdTail.ues, ue]; }; ENDCASE => Error[IO.PutFR["%g statement found in %g", [atom[key]], [rope[me]] ]]; ENDLOOP; cc _ cc; }; Handle: PROC [cc: CellConversion, v: View, lexed: LORA, pub: Publicity, context: ROPE] = { me: ROPE = Rope.Cat[ SELECT pub FROM Interface => "interface of ", Contents => "Contents of ", ENDCASE => ERROR, context]; FOR lexed _ lexed.rest, lexed.rest WHILE lexed # NIL DO innerMe: ROPE = Rope.Cat["statement in ", me]; part: LORA = ToLORA[lexed.first, me.Cat[" contains a non-statement"]]; converter: Converter; key: ATOM; CheckLength[part, innerMe, 1]; key _ ToATOM[part.first, innerMe.Cat[" doesn't begin with a keyword"]]; converter _ GetConverter[key, pub]; SELECT converter FROM =NIL => Error[IO.PutFR["%g statement found in %g", [atom[key]], [rope[me]] ]]; #NIL => converter.Convert[converter.converterData, cc, v, part, pub, context]; ENDCASE => ERROR; ENDLOOP; cc _ cc; }; GetConverter: PROC [key: ATOM, pub: Publicity] RETURNS [c: Converter] = { c _ NARROW[Atom.GetProp[key, converterKeys[pub]]]; }; SetConverter: PUBLIC PROC [key: ATOM, pub: Publicity, c: Converter] = { Atom.PutProp[key, converterKeys[pub], c]; }; converterKeys: ARRAY Publicity OF ATOM = [ Interface: $EDIFCellingInterfacePartHandler, Contents: $EDIFCellingContentsPartHandler]; ConvertComment: PROC [converterData: REF ANY, cc: CellConversion, v: View, part: LORA, pub: Publicity, context: ROPE] = { c: Comment = ParseComment[part, context]; [v.std[pub].head.comments, v.std[pub].tail.comments] _ CAppend[v.std[pub].head.comments, v.std[pub].tail.comments, c]; }; ConvertUserExtension: PROC [converterData: REF ANY, cc: CellConversion, v: View, part: LORA, pub: Publicity, context: ROPE] = { ue: UserExtension = ParseUserExtension[part, context]; [v.std[pub].head.ues, v.std[pub].tail.ues] _ UEAppend[v.std[pub].head.ues, v.std[pub].tail.ues, ue]; }; boredomKey: ATOM = $EDIFCellingViewBoringParts; boredomKeys: ARRAY Publicity OF ATOM = [ Interface: $EDIFCellingInterfaceBoringParts, Contents: $EDIFCellingContentsBoringParts]; ConvertUninteresting: PROC [converterData: REF ANY, cc: CellConversion, v: View, part: LORA, pub: Publicity, context: ROPE] = { v.assns[pub] _ Asserting.Assert[ reln: boredomKey, terms: part, inAdditionTo: v.assns[pub] ]; }; RegisterDisinterest: PROC [key: ATOM] = { FOR pub: Publicity IN Publicity DO SetConverter[key, pub, NEW [ConverterPrivate _ [ConvertUninteresting]]]; SetConverter[key, pub, NEW [ConverterPrivate _ [ConvertUninteresting]]]; ENDLOOP; }; Start: PROC = { FOR pub: Publicity IN Publicity DO SetConverter[$comment, pub, NEW [ConverterPrivate _ [ConvertComment]]]; SetConverter[$userdata, pub, NEW [ConverterPrivate _ [ConvertUserExtension]]]; ENDLOOP; RegisterDisinterest[$annotate]; RegisterDisinterest[$arrayrelatedinfo]; RegisterDisinterest[$body]; RegisterDisinterest[$criticalsignal]; RegisterDisinterest[$figuregroup]; RegisterDisinterest[$logicmodel]; RegisterDisinterest[$measured]; RegisterDisinterest[$portimplementation]; RegisterDisinterest[$required]; RegisterDisinterest[$section]; RegisterDisinterest[$simulate]; RegisterDisinterest[$timing]; RegisterDisinterest[$wire]; }; }.