home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-07-13 | 47.9 KB | 1,613 lines |
- {"mass", MASS},
- {"measured", MEASURED},
- {"mx", MX},
- {"mxr90", MXR90},
- {"my", MY},
- {"myr90", MYR90},
- {"netlist", NETLIST},
- {"output", OUTPUT},
- {"pcblayout", PCBLAYOUT},
- {"power", POWER},
- {"r0", R0},
- {"r180", R180},
- {"r270", R270},
- {"r90", R90},
- {"required", REQUIRED},
- {"resistance", RESISTANCE},
- {"ripper", RIPPER},
- {"round", ROUND},
- {"schematic", SCHEMATIC},
- {"stranger", STRANGER},
- {"symbolic", SYMBOLIC},
- {"temperature", TEMPERATURE},
- {"tie", TIE},
- {"time", TIME},
- {"truncate", TRUNCATE},
- {"uppercenter", UPPERCENTER},
- {"upperleft", UPPERLEFT},
- {"upperright", UPPERRIGHT},
- {"voltage", VOLTAGE}
- };
- static int TokenDefSize = sizeof(TokenDef) / sizeof(Token);
- /*
- * Token enable definitions:
- *
- * There is one array for each set of tokens enabled by a
- * particular context (barf). Another array is used to bind
- * these arrays to a context.
- */
- static short e_CellType[] = {TIE,RIPPER,GENERIC};
- static short e_CornerType[] = {EXTEND,TRUNCATE,ROUND};
- static short e_Derivation[] = {CALCULATED,MEASURED,REQUIRED};
- static short e_Direction[] = {INPUT,OUTPUT,INOUT};
- static short e_EndType[] = {EXTEND,TRUNCATE,ROUND};
- static short e_Justify[] = {
- CENTERCENTER,CENTERLEFT,CENTERRIGHT,LOWERCENTER,LOWERLEFT,LOWERRIGHT,
- UPPERCENTER,UPPERLEFT,UPPERRIGHT
- };
- static short e_Orientation[] = {R0,R90,R180,R270,MX,MY,MXR90,MYR90};
- static short e_Unit[] = {
- DISTANCE,CAPACITANCE,CURRENT,RESISTANCE,TEMPERATURE,TIME,VOLTAGE,MASS,
- FREQUENCY,INDUCTANCE,ENERGY,POWER,CHARGE,CONDUCTANCE,FLUX,ANGLE
- };
- static short e_ViewType[] = {
- MASKLAYOUT,PCBLAYOUT,NETLIST,SCHEMATIC,SYMBOLIC,BEHAVIOR,LOGICMODEL,
- DOCUMENT,GRAPHIC,STRANGER
- };
- /*
- * Token tying table:
- *
- * This binds enabled tokens to a context.
- */
- typedef struct Tie {
- short *Enable; /* pointer to enable array */
- short Origin; /* '%token' value of context */
- short EnableSize; /* size of enabled array */
- } Tie;
- #define TE(e,o) {e,o,sizeof(e)/sizeof(short)}
- static Tie TieDef[] = {
- TE(e_CellType, CELLTYPE),
- TE(e_CornerType, CORNERTYPE),
- TE(e_Derivation, DERIVATION),
- TE(e_Direction, DIRECTION),
- TE(e_EndType, ENDTYPE),
- TE(e_Justify, JUSTIFY),
- TE(e_Orientation, ORIENTATION),
- TE(e_Unit, UNIT),
- TE(e_ViewType, VIEWTYPE)
- };
- static int TieDefSize = sizeof(TieDef) / sizeof(Tie);
- /*
- * Context definitions:
- *
- * This associates keyword strings with '%token' values. It
- * also creates a pretty much empty header for later building of
- * the context tree. Again they needn't be sorted, but strings
- * must be lower case.
- */
- typedef struct Context {
- char *Name; /* keyword name */
- short Code; /* '%token' value */
- short Flags; /* special operation flags */
- struct ContextCar *Context; /* contexts which can be moved to */
- struct TokenCar *Token; /* active tokens */
- struct Context *Next; /* hash table linkage */
- } Context;
- static Context ContextDef[] = {
- {"", NULL}, /* start context */
- {"acload", ACLOAD},
- {"after", AFTER},
- {"annotate", ANNOTATE},
- {"apply", APPLY},
- {"arc", ARC},
- {"array", ARRAY},
- {"arraymacro", ARRAYMACRO},
- {"arrayrelatedinfo", ARRAYRELATEDINFO},
- {"arraysite", ARRAYSITE},
- {"atleast", ATLEAST},
- {"atmost", ATMOST},
- {"author", AUTHOR},
- {"basearray", BASEARRAY},
- {"becomes", BECOMES},
- {"between", BETWEEN},
- {"boolean", BOOLEAN},
- {"booleandisplay", BOOLEANDISPLAY},
- {"booleanmap", BOOLEANMAP},
- {"borderpattern", BORDERPATTERN},
- {"borderwidth", BORDERWIDTH},
- {"boundingbox", BOUNDINGBOX},
- {"cell", CELL},
- {"cellref", CELLREF},
- {"celltype", CELLTYPE},
- {"change", CHANGE},
- {"circle", CIRCLE},
- {"color", COLOR},
- {"comment", COMMENT},
- {"commentgraphics", COMMENTGRAPHICS},
- {"compound", COMPOUND},
- {"connectlocation", CONNECTLOCATION},
- {"contents", CONTENTS},
- {"cornertype", CORNERTYPE},
- {"criticality", CRITICALITY},
- {"currentmap", CURRENTMAP},
- {"curve", CURVE},
- {"cycle", CYCLE},
- {"dataorigin", DATAORIGIN},
- {"dcfaninload", DCFANINLOAD},
- {"dcfanoutload", DCFANOUTLOAD},
- {"dcmaxfanin", DCMAXFANIN},
- {"dcmaxfanout", DCMAXFANOUT},
- {"delay", DELAY},
- {"delta", DELTA},
- {"derivation", DERIVATION},
- {"design", DESIGN},
- {"designator", DESIGNATOR},
- {"difference", DIFFERENCE},
- {"direction", DIRECTION},
- {"display", DISPLAY},
- {"dominates", DOMINATES},
- {"dot", DOT},
- {"duration", DURATION},
- {"e", E},
- {"edif", EDIF},
- {"ediflevel", EDIFLEVEL},
- {"edifversion", EDIFVERSION},
- {"enclosuredistance", ENCLOSUREDISTANCE},
- {"endtype", ENDTYPE},
- {"entry", ENTRY},
- {"exactly", EXACTLY},
- {"external", EXTERNAL},
- {"fabricate", FABRICATE},
- {"false", FALSE},
- {"figure", FIGURE},
- {"figurearea", FIGUREAREA},
- {"figuregroup", FIGUREGROUP},
- {"figuregroupobject", FIGUREGROUPOBJECT},
- {"figuregroupoverride", FIGUREGROUPOVERRIDE},
- {"figuregroupref", FIGUREGROUPREF},
- {"figureperimeter", FIGUREPERIMETER},
- {"figurewidth", FIGUREWIDTH},
- {"fillpattern", FILLPATTERN},
- {"follow", FOLLOW},
- {"forbiddenevent", FORBIDDENEVENT},
- {"globalportref", GLOBALPORTREF},
- {"greaterthan", GREATERTHAN},
- {"gridmap", GRIDMAP},
- {"ignore", IGNORE},
- {"includefiguregroup", INCLUDEFIGUREGROUP},
- {"initial", INITIAL},
- {"instance", INSTANCE},
- {"instancebackannotate", INSTANCEBACKANNOTATE},
- {"instancegroup", INSTANCEGROUP},
- {"instancemap", INSTANCEMAP},
- {"instanceref", INSTANCEREF},
- {"integer", INTEGER},
- {"integerdisplay", INTEGERDISPLAY},
- {"interface", INTERFACE},
- {"interfiguregroupspacing", INTERFIGUREGROUPSPACING},
- {"intersection", INTERSECTION},
- {"intrafiguregroupspacing", INTRAFIGUREGROUPSPACING},
- {"inverse", INVERSE},
- {"isolated", ISOLATED},
- {"joined", JOINED},
- {"justify", JUSTIFY},
- {"keyworddisplay", KEYWORDDISPLAY},
- {"keywordlevel", KEYWORDLEVEL},
- {"keywordmap", KEYWORDMAP},
- {"lessthan", LESSTHAN},
- {"library", LIBRARY},
- {"libraryref", LIBRARYREF},
- {"listofnets", LISTOFNETS},
- {"listofports", LISTOFPORTS},
- {"loaddelay", LOADDELAY},
- {"logicassign", LOGICASSIGN},
- {"logicinput", LOGICINPUT},
- {"logiclist", LOGICLIST},
- {"logicmapinput", LOGICMAPINPUT},
- {"logicmapoutput", LOGICMAPOUTPUT},
- {"logiconeof", LOGICONEOF},
- {"logicoutput", LOGICOUTPUT},
- {"logicport", LOGICPORT},
- {"logicref", LOGICREF},
- {"logicvalue", LOGICVALUE},
- {"logicwaveform", LOGICWAVEFORM},
- {"maintain", MAINTAIN},
- {"match", MATCH},
- {"member", MEMBER},
- {"minomax", MINOMAX},
- {"minomaxdisplay", MINOMAXDISPLAY},
- {"mnm", MNM},
- {"multiplevalueset", MULTIPLEVALUESET},
- {"mustjoin", MUSTJOIN},
- {"name", NAME},
- {"net", NET},
- {"netbackannotate", NETBACKANNOTATE},
- {"netbundle", NETBUNDLE},
- {"netdelay", NETDELAY},
- {"netgroup", NETGROUP},
- {"netmap", NETMAP},
- {"netref", NETREF},
- {"nochange", NOCHANGE},
- {"nonpermutable", NONPERMUTABLE},
- {"notallowed", NOTALLOWED},
- {"notchspacing", NOTCHSPACING},
- {"number", NUMBER},
- {"numberdefinition", NUMBERDEFINITION},
- {"numberdisplay", NUMBERDISPLAY},
- {"offpageconnector", OFFPAGECONNECTOR},
- {"offsetevent", OFFSETEVENT},
- {"openshape", OPENSHAPE},
- {"orientation", ORIENTATION},
- {"origin", ORIGIN},
- {"overhangdistance", OVERHANGDISTANCE},
- {"overlapdistance", OVERLAPDISTANCE},
- {"oversize", OVERSIZE},
- {"owner", OWNER},
- {"page", PAGE},
- {"pagesize", PAGESIZE},
- {"parameter", PARAMETER},
- {"parameterassign", PARAMETERASSIGN},
- {"parameterdisplay", PARAMETERDISPLAY},
- {"path", PATH},
- {"pathdelay", PATHDELAY},
- {"pathwidth", PATHWIDTH},
- {"permutable", PERMUTABLE},
- {"physicaldesignrule", PHYSICALDESIGNRULE},
- {"plug", PLUG},
- {"point", POINT},
- {"pointdisplay", POINTDISPLAY},
- {"pointlist", POINTLIST},
- {"polygon", POLYGON},
- {"port", PORT},
- {"portbackannotate", PORTBACKANNOTATE},
- {"portbundle", PORTBUNDLE},
- {"portdelay", PORTDELAY},
- {"portgroup", PORTGROUP},
- {"portimplementation", PORTIMPLEMENTATION},
- {"portinstance", PORTINSTANCE},
- {"portlist", PORTLIST},
- {"portlistalias", PORTLISTALIAS},
- {"portmap", PORTMAP},
- {"portref", PORTREF},
- {"program", PROGRAM},
- {"property", PROPERTY},
- {"propertydisplay", PROPERTYDISPLAY},
- {"protectionframe", PROTECTIONFRAME},
- {"pt", PT},
- {"rangevector", RANGEVECTOR},
- {"rectangle", RECTANGLE},
- {"rectanglesize", RECTANGLESIZE},
- {"rename", RENAME},
- {"resolves", RESOLVES},
- {"scale", SCALE},
- {"scalex", SCALEX},
- {"scaley", SCALEY},
- {"section", SECTION},
- {"shape", SHAPE},
- {"simulate", SIMULATE},
- {"simulationinfo", SIMULATIONINFO},
- {"singlevalueset", SINGLEVALUESET},
- {"site", SITE},
- {"socket", SOCKET},
- {"socketset", SOCKETSET},
- {"status", STATUS},
- {"steady", STEADY},
- {"string", STRING},
- {"stringdisplay", STRINGDISPLAY},
- {"strong", STRONG},
- {"symbol", SYMBOL},
- {"symmetry", SYMMETRY},
- {"table", TABLE},
- {"tabledefault", TABLEDEFAULT},
- {"technology", TECHNOLOGY},
- {"textheight", TEXTHEIGHT},
- {"timeinterval", TIMEINTERVAL},
- {"timestamp", TIMESTAMP},
- {"timing", TIMING},
- {"transform", TRANSFORM},
- {"transition", TRANSITION},
- {"trigger", TRIGGER},
- {"true", TRUE},
- {"unconstrained", UNCONSTRAINED},
- {"undefined", UNDEFINED},
- {"union", UNION},
- {"unit", UNIT},
- {"unused", UNUSED},
- {"userdata", USERDATA},
- {"version", VERSION},
- {"view", VIEW},
- {"viewlist", VIEWLIST},
- {"viewmap", VIEWMAP},
- {"viewref", VIEWREF},
- {"viewtype", VIEWTYPE},
- {"visible", VISIBLE},
- {"voltagemap", VOLTAGEMAP},
- {"wavevalue", WAVEVALUE},
- {"weak", WEAK},
- {"weakjoined", WEAKJOINED},
- {"when", WHEN},
- {"written", WRITTEN}
- };
- static int ContextDefSize = sizeof(ContextDef) / sizeof(Context);
- /*
- * Context follower tables:
- *
- * This is pretty ugly, an array is defined for each context
- * which has following context levels. Yet another table is used
- * to bind these arrays to the originating contexts.
- * Arrays are declared as:
- *
- * static short f_<Context name>[] = { ... };
- *
- * The array entries are the '%token' values for all keywords which
- * can be reached from the <Context name> context. Like I said, ugly,
- * but it works.
- * A negative entry means that the follow can only occur once within
- * the specified context.
- */
- static short f_NULL[] = {EDIF};
- static short f_Edif[] = {
- NAME,RENAME,EDIFVERSION,EDIFLEVEL,KEYWORDMAP,-STATUS,EXTERNAL,LIBRARY,
- DESIGN,COMMENT,USERDATA
- };
- static short f_AcLoad[] = {MNM,E,MINOMAXDISPLAY};
- static short f_After[] = {MNM,E,FOLLOW,MAINTAIN,LOGICASSIGN,COMMENT,USERDATA};
- static short f_Annotate[] = {STRINGDISPLAY};
- static short f_Apply[] = {CYCLE,LOGICINPUT,LOGICOUTPUT,COMMENT,USERDATA};
- static short f_Arc[] = {PT};
- static short f_Array[] = {NAME,RENAME};
- static short f_ArrayMacro[] = {PLUG};
- static short f_ArrayRelatedInfo[] = {
- BASEARRAY,ARRAYSITE,ARRAYMACRO,COMMENT,USERDATA
- };
- static short f_ArraySite[] = {SOCKET};
- static short f_AtLeast[] = {E};
- static short f_AtMost[] = {E};
- static short f_Becomes[] = {NAME,LOGICLIST,LOGICONEOF};
- static short f_Between[] = {ATLEAST,GREATERTHAN,ATMOST,LESSTHAN};
- static short f_Boolean[] = {FALSE,TRUE,BOOLEANDISPLAY,BOOLEAN};
- static short f_BooleanDisplay[] = {FALSE,TRUE,DISPLAY};
- static short f_BooleanMap[] = {FALSE,TRUE};
- static short f_BorderPattern[] = {BOOLEAN};
- static short f_BoundingBox[] = {RECTANGLE};
- static short f_Cell[] = {
- NAME,CELLTYPE,-STATUS,-VIEWMAP,VIEW,COMMENT,USERDATA,PROPERTY
- };
- static short f_CellRef[] = {NAME,LIBRARYREF};
- static short f_Change[] = {NAME,PORTREF,PORTLIST,BECOMES,TRANSITION};
- static short f_Circle[] = {PT,PROPERTY};
- static short f_Color[] = {E};
- static short f_CommentGraphics[] = {
- ANNOTATE,FIGURE,INSTANCE,-BOUNDINGBOX,PROPERTY,COMMENT,USERDATA
- };
- static short f_Compound[] = {NAME};
- static short f_ConnectLocation[] = {FIGURE};
- static short f_Contents[] = {
- INSTANCE,OFFPAGECONNECTOR,FIGURE,SECTION,NET,NETBUNDLE,PAGE,
- COMMENTGRAPHICS,PORTIMPLEMENTATION,TIMING,SIMULATE,WHEN,FOLLOW,
- LOGICPORT,-BOUNDINGBOX,COMMENT,USERDATA
- };
- static short f_Criticality[] = {INTEGERDISPLAY};
- static short f_CurrentMap[] = {MNM,E};
- static short f_Curve[] = {ARC,PT};
- static short f_Cycle[] = {DURATION};
- static short f_DataOrigin[] = {VERSION};
- static short f_DcFanInLoad[] = {E,NUMBERDISPLAY};
- static short f_DcFanOutLoad[] = {E,NUMBERDISPLAY};
- static short f_DcMaxFanIn[] = {E,NUMBERDISPLAY};
- static short f_DcMaxFanOut[] = {E,NUMBERDISPLAY};
- static short f_Delay[] = {MNM,E};
- static short f_Delta[] = {PT};
- static short f_Design[] = {
- NAME,RENAME,CELLREF,STATUS,COMMENT,PROPERTY,USERDATA
- };
- static short f_Designator[] = {STRINGDISPLAY};
- static short f_Difference[] = {
- FIGUREGROUPREF,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE
- };
- static short f_Display[] = {
- NAME,FIGUREGROUPOVERRIDE,JUSTIFY,ORIENTATION,ORIGIN
- };
- static short f_Dominates[] = {NAME};
- static short f_Dot[] = {PT,PROPERTY};
- static short f_Duration[] = {E};
- static short f_EnclosureDistance[] = {
- NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,
- EXACTLY,BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
- };
- static short f_Entry[] = {
- MATCH,CHANGE,STEADY,LOGICREF,PORTREF,NOCHANGE,TABLE,DELAY,LOADDELAY
- };
- static short f_Exactly[] = {E};
- static short f_External[] = {
- NAME,RENAME,EDIFLEVEL,TECHNOLOGY,-STATUS,CELL,COMMENT,USERDATA
- };
- static short f_Fabricate[] = {NAME,RENAME};
- static short f_Figure[] = {
- NAME,FIGUREGROUPOVERRIDE,CIRCLE,DOT,OPENSHAPE,PATH,POLYGON,RECTANGLE,
- SHAPE,COMMENT,USERDATA
- };
- static short f_FigureArea[] = {
- NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,
- EXACTLY,BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
- };
- static short f_FigureGroup[] = {
- NAME,RENAME,-CORNERTYPE,-ENDTYPE,-PATHWIDTH,-BORDERWIDTH,-COLOR,
- -FILLPATTERN,-BORDERPATTERN,-TEXTHEIGHT,-VISIBLE,INCLUDEFIGUREGROUP,
- COMMENT,PROPERTY,USERDATA
- };
- static short f_FigureGroupObject[] = {
- NAME,FIGUREGROUPOBJECT,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE
- };
- static short f_FigureGroupOverride[] = {
- NAME,-CORNERTYPE,-ENDTYPE,-PATHWIDTH,-BORDERWIDTH,-COLOR,-FILLPATTERN,
- -TEXTHEIGHT,-BORDERPATTERN,VISIBLE,COMMENT,PROPERTY,USERDATA
- };
- static short f_FigureGroupRef[] = {NAME,LIBRARYREF};
- static short f_FigurePerimeter[] = {
- NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
- BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
- };
- static short f_FigureWidth[] = {
- NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
- BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
- };
- static short f_FillPattern[] = {BOOLEAN};
- static short f_Follow[] = {NAME,PORTREF,TABLE,DELAY,LOADDELAY};
- static short f_ForbiddenEvent[] = {TIMEINTERVAL,EVENT};
- static short f_GlobalPortRef[] = {NAME};
- static short f_GreaterThan[] = {E};
- static short f_GridMap[] = {E};
- static short f_IncludeFigureGroup[] = {
- FIGUREGROUPREF,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE
- };
- static short f_Instance[] = {
- NAME,RENAME,ARRAY,VIEWREF,VIEWLIST,-TRANSFORM,PARAMETERASSIGN,PORTINSTANCE,
- TIMING,-DESIGNATOR,PROPERTY,COMMENT,USERDATA
- };
- static short f_InstanceBackAnnotate[] = {
- INSTANCEREF,-DESIGNATOR,TIMING,PROPERTY,COMMENT
- };
- static short f_InstanceGroup[] = {INSTANCEREF};
- static short f_InstanceMap[] = {
- INSTANCEREF,INSTANCEGROUP,COMMENT,USERDATA
- };
- static short f_InstanceRef[] = {NAME,MEMBER,INSTANCEREF,VIEWREF};
- static short f_Integer[] = {INTEGERDISPLAY,INTEGER};
- static short f_IntegerDisplay[] = {DISPLAY};
- static short f_Interface[] = {
- PORT,PORTBUNDLE,-SYMBOL,-PROTECTIONFRAME,-ARRAYRELATEDINFO,PARAMETER,
- JOINED,MUSTJOIN,WEAKJOINED,PERMUTABLE,TIMING,SIMULATE,-DESIGNATOR,PROPERTY,
- COMMENT,USERDATA
- };
- static short f_InterFigureGroupSpacing[] = {
- NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
- BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
- };
- static short f_Intersection[] = {
- FIGUREGROUPREF,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE
- };
- static short f_IntraFigureGroupSpacing[] = {
- NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
- BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
- };
- static short f_Inverse[] = {
- FIGUREGROUPREF,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE
- };
- static short f_Joined[] = {PORTREF,PORTLIST,GLOBALPORTREF};
- static short f_KeywordDisplay[] = {DISPLAY};
- static short f_KeywordMap[] = {KEYWORDLEVEL,COMMENT};
- static short f_LessThan[] = {E};
- static short f_Library[] = {
- NAME,RENAME,EDIFLEVEL,TECHNOLOGY,-STATUS,CELL,COMMENT,USERDATA
- };
- static short f_LibraryRef[] = {NAME};
- static short f_ListOfNets[] = {NET};
- static short f_ListOfPorts[] = {PORT,PORTBUNDLE};
- static short f_LoadDelay[] = {MNM,E,MINOMAXDISPLAY};
- static short f_LogicAssign[] = {NAME,PORTREF,LOGICREF,TABLE,DELAY,LOADDELAY};
- static short f_LogicInput[] = {PORTLIST,PORTREF,NAME,LOGICWAVEFORM};
- static short f_LogicList[] = {NAME,LOGICONEOF,IGNORE};
- static short f_LogicMapInput[] = {LOGICREF};
- static short f_LogicMapOutput[] = {LOGICREF};
- static short f_LogicOneOf[] = {NAME,LOGICLIST};
- static short f_LogicOutput[] = {PORTLIST,PORTREF,NAME,LOGICWAVEFORM};
- static short f_LogicPort[] = {NAME,RENAME,PROPERTY,COMMENT,USERDATA};
- static short f_LogicRef[] = {NAME,LIBRARYREF};
- static short f_LogicValue[] = {
- NAME,RENAME,-VOLTAGEMAP,-CURRENTMAP,-BOOLEANMAP,-COMPOUND,-WEAK,-STRONG,
- -DOMINATES,-LOGICMAPOUTPUT,-LOGICMAPINPUT,-ISOLATED,RESOLVES,PROPERTY,
- COMMENT,USERDATA
- };
- static short f_LogicWaveform[] = {NAME,LOGICLIST,LOGICONEOF,IGNORE};
- static short f_Maintain[] = {NAME,PORTREF,DELAY,LOADDELAY};
- static short f_Match[] = {NAME,PORTREF,PORTLIST,LOGICLIST,LOGICONEOF};
- static short f_Member[] = {NAME};
- static short f_MiNoMax[] = {MNM,E,MINOMAXDISPLAY,MINOMAX};
- static short f_MiNoMaxDisplay[] = {MNM,E,DISPLAY};
- static short f_Mnm[] = {E,UNDEFINED,UNCONSTRAINED};
- static short f_MultipleValueSet[] = {RANGEVECTOR};
- static short f_MustJoin[] = {PORTREF,PORTLIST,WEAKJOINED,JOINED};
- static short f_Name[] = {DISPLAY};
- static short f_Net[] = {
- NAME,RENAME,-CRITICALITY,NETDELAY,FIGURE,NET,INSTANCE,COMMENTGRAPHICS,
- PROPERTY,COMMENT,USERDATA,JOINED,ARRAY
- };
- static short f_NetBackAnnotate[] = {
- NETREF,NETDELAY,-CRITICALITY,PROPERTY,COMMENT
- };
- static short f_NetBundle[] = {
- NAME,RENAME,ARRAY,LISTOFNETS,FIGURE,COMMENTGRAPHICS,PROPERTY,COMMENT,
- USERDATA
- };
- static short f_NetDelay[] = {DERIVATION,DELAY,TRANSITION,BECOMES};
- static short f_NetGroup[] = {NAME,MEMBER,NETREF};
- static short f_NetMap[] = {NETREF,NETGROUP,COMMENT,USERDATA};
- static short f_NetRef[] = {NAME,MEMBER,NETREF,INSTANCEREF,VIEWREF};
- static short f_NonPermutable[] = {PORTREF,PERMUTABLE};
- static short f_NotAllowed[] = {
- NAME,RENAME,FIGUREGROUPOBJECT,COMMENT,USERDATA
- };
- static short f_NotchSpacing[] = {
- NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
- BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
- };
- static short f_Number[] = {E,NUMBERDISPLAY,NUMBER};
- static short f_NumberDefinition[] = {SCALE,-GRIDMAP,COMMENT};
- static short f_NumberDisplay[] = {E,DISPLAY};
- static short f_OffPageConnector[] = {
- NAME,RENAME,-UNUSED,PROPERTY,COMMENT,USERDATA
- };
- static short f_OffsetEvent[] = {EVENT,E};
- static short f_OpenShape[] = {CURVE,PROPERTY};
- static short f_Origin[] = {PT};
- static short f_OverhangDistance[] = {
- NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
- BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
- };
- static short f_OverlapDistance[] = {
- NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
- BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
- };
- static short f_Oversize[] = {
- FIGUREGROUPREF,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE,CORNERTYPE
- };
- static short f_Page[] = {
- NAME,RENAME,ARRAY,INSTANCE,NET,NETBUNDLE,COMMENTGRAPHICS,PORTIMPLEMENTATION,
- -PAGESIZE,-BOUNDINGBOX,COMMENT,USERDATA
- };
- static short f_PageSize[] = {RECTANGLE};
- static short f_Parameter[] = {
- NAME,RENAME,ARRAY,BOOLEAN,INTEGER,MINOMAX,NUMBER,POINT,STRING
- };
- static short f_ParameterAssign[] = {
- NAME,MEMBER,BOOLEAN,INTEGER,MINOMAX,NUMBER,POINT,STRING
- };
- static short f_ParameterDisplay[] = {NAME,MEMBER,DISPLAY};
- static short f_Path[] = {POINTLIST,PROPERTY};
- static short f_PathDelay[] = {DELAY,EVENT};
- static short f_Permutable[] = {PORTREF,PERMUTABLE,NONPERMUTABLE};
- static short f_PhysicalDesignRule[] = {
- FIGUREWIDTH,FIGUREAREA,RECTANGLESIZE,FIGUREPERIMETER,OVERLAPDISTANCE,
- OVERHANGDISTANCE,ENCLOSUREDISTANCE,INTERFIGUREGROUPSPACING,NOTCHSPACING,
- INTRAFIGUREGROUPSPACING,NOTALLOWED,FIGUREGROUP,COMMENT,USERDATA
- };
- static short f_Plug[] = {SOCKETSET};
- static short f_Point[] = {PT,POINTDISPLAY,POINT};
- static short f_PointDisplay[] = {PT,DISPLAY};
- static short f_PointList[] = {PT};
- static short f_Polygon[] = {POINTLIST,PROPERTY};
- static short f_Port[] = {
- NAME,RENAME,ARRAY,-DIRECTION,-UNUSED,PORTDELAY,-DESIGNATOR,-DCFANINLOAD,
- -DCFANOUTLOAD,-DCMAXFANIN,-DCMAXFANOUT,-ACLOAD,PROPERTY,COMMENT,USERDATA
- };
- static short f_PortBackAnnotate[] = {
- PORTREF,-DESIGNATOR,PORTDELAY,-DCFANINLOAD,-DCFANOUTLOAD,-DCMAXFANIN,
- -DCMAXFANOUT,-ACLOAD,PROPERTY,COMMENT
- };
- static short f_PortBundle[] = {
- NAME,RENAME,ARRAY,LISTOFPORTS,PROPERTY,COMMENT,USERDATA
- };
- static short f_PortDelay[] = {DERIVATION,DELAY,LOADDELAY,TRANSITION,BECOMES};
- static short f_PortGroup[] = {NAME,MEMBER,PORTREF};
- static short f_PortImplementation[] = {
- PORTREF,NAME,MEMBER,-CONNECTLOCATION,FIGURE,INSTANCE,COMMENTGRAPHICS,
- PROPERTYDISPLAY,KEYWORDDISPLAY,PROPERTY,USERDATA,COMMENT
- };
- static short f_PortInstance[] = {
- PORTREF,NAME,MEMBER,-UNUSED,PORTDELAY,-DESIGNATOR,-DCFANINLOAD,-DCFANOUTLOAD,
- -DCMAXFANIN,-DCMAXFANOUT,-ACLOAD,PROPERTY,COMMENT,USERDATA
- };
- static short f_PortList[] = {PORTREF,NAME,MEMBER};
- static short f_PortListAlias[] = {NAME,RENAME,ARRAY,PORTLIST};
- static short f_PortMap[] = {PORTREF,PORTGROUP,COMMENT,USERDATA};
- static short f_PortRef[] = {NAME,MEMBER,PORTREF,INSTANCEREF,VIEWREF};
- static short f_Program[] = {VERSION};
- static short f_Property[] = {
- NAME,RENAME,BOOLEAN,INTEGER,MINOMAX,NUMBER,POINT,STRING,-OWNER,-UNIT,
- PROPERTY,COMMENT
- };
- static short f_PropertyDisplay[] = {NAME,DISPLAY};
- static short f_ProtectionFrame[] = {
- PORTIMPLEMENTATION,FIGURE,INSTANCE,COMMENTGRAPHICS,-BOUNDINGBOX,
- PROPERTYDISPLAY,KEYWORDDISPLAY,PARAMETERDISPLAY,PROPERTY,COMMENT,USERDATA
- };
- static short f_RangeVector[] = {
- LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,BETWEEN,SINGLEVALUESET
- };
- static short f_Rectangle[] = {PT,PROPERTY};
- static short f_RectangleSize[] = {
- NAME,RENAME,FIGUREGROUPOBJECT,RANGEVECTOR,MULTIPLEVALUESET,COMMENT,USERDATA
- };
- static short f_Rename[] = {NAME,STRINGDISPLAY};
- static short f_Resolves[] = {NAME};
- static short f_Scale[] = {E,UNIT};
- static short f_Section[] = {SECTION,INSTANCE};
- static short f_Shape[] = {CURVE,PROPERTY};
- static short f_Simulate[] = {
- NAME,PORTLISTALIAS,WAVEVALUE,APPLY,COMMENT,USERDATA
- };
- static short f_SimulationInfo[] = {LOGICVALUE,COMMENT,USERDATA};
- static short f_SingleValueSet[] = {
- LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,BETWEEN
- };
- static short f_Site[] = {VIEWREF,TRANSFORM};
- static short f_Socket[] = {SYMMETRY};
- static short f_SocketSet[] = {SYMMETRY,SITE};
- static short f_Status[] = {WRITTEN,COMMENT,USERDATA};
- static short f_Steady[] = {
- NAME,MEMBER,PORTREF,PORTLIST,DURATION,TRANSITION,BECOMES
- };
- static short f_String[] = {STRINGDISPLAY,STRING};
- static short f_StringDisplay[] = {DISPLAY};
- static short f_Strong[] = {NAME};
- static short f_Symbol[] = {
- PORTIMPLEMENTATION,FIGURE,INSTANCE,COMMENTGRAPHICS,ANNOTATE,-PAGESIZE,
- -BOUNDINGBOX,PROPERTYDISPLAY,KEYWORDDISPLAY,PARAMETERDISPLAY,PROPERTY,
- COMMENT,USERDATA
- };
- static short f_Symmetry[] = {TRANSFORM};
- static short f_Table[] = {ENTRY,TABLEDEFAULT};
- static short f_TableDefault[] = {
- LOGICREF,PORTREF,NOCHANGE,TABLE,DELAY,LOADDELAY
- };
- static short f_Technology[] = {
- NUMBERDEFINITION,FIGUREGROUP,FABRICATE,-SIMULATIONINFO,COMMENT,USERDATA,
- -PHYSICALDESIGNRULE
- };
- static short f_TimeInterval[] = {EVENT,OFFSETEVENT,DURATION};
- static short f_Timing[] = {
- DERIVATION,PATHDELAY,FORBIDDENEVENT,COMMENT,USERDATA
- };
- static short f_Transform[] = {SCALEX,SCALEY,DELTA,ORIENTATION,ORIGIN};
- static short f_Transition[] = {NAME,LOGICLIST,LOGICONEOF};
- static short f_Trigger[] = {CHANGE,STEADY,INITIAL};
- static short f_Union[] = {
- FIGUREGROUPREF,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE
- };
- static short f_View[] = {
- NAME,RENAME,VIEWTYPE,INTERFACE,-STATUS,-CONTENTS,COMMENT,PROPERTY,USERDATA
- };
- static short f_ViewList[] = {VIEWREF,VIEWLIST};
- static short f_ViewMap[] = {
- PORTMAP,PORTBACKANNOTATE,INSTANCEMAP,INSTANCEBACKANNOTATE,NETMAP,
- NETBACKANNOTATE,COMMENT,USERDATA
- };
- static short f_ViewRef[] = {NAME,CELLREF};
- static short f_Visible[] = {FALSE,TRUE};
- static short f_VoltageMap[] = {MNM,E};
- static short f_WaveValue[] = {NAME,RENAME,E,LOGICWAVEFORM};
- static short f_Weak[] = {NAME};
- static short f_WeakJoined[] = {PORTREF,PORTLIST,JOINED};
- static short f_When[] = {
- TRIGGER,AFTER,FOLLOW,MAINTAIN,LOGICASSIGN,COMMENT,USERDATA
- };
- static short f_Written[] = {
- TIMESTAMP,AUTHOR,PROGRAM,DATAORIGIN,PROPERTY,COMMENT,USERDATA
- };
- /*
- * Context binding table:
- *
- * This binds context follower arrays to their originating context.
- */
- typedef struct Binder {
- short *Follower; /* pointer to follower array */
- short Origin; /* '%token' value of origin */
- short FollowerSize; /* size of follower array */
- } Binder;
- #define BE(f,o) {f,o,sizeof(f)/sizeof(short)}
- static Binder BinderDef[] = {
- BE(f_NULL, NULL),
- BE(f_Edif, EDIF),
- BE(f_AcLoad, ACLOAD),
- BE(f_After, AFTER),
- BE(f_Annotate, ANNOTATE),
- BE(f_Apply, APPLY),
- BE(f_Arc, ARC),
- BE(f_Array, ARRAY),
- BE(f_ArrayMacro, ARRAYMACRO),
- BE(f_ArrayRelatedInfo, ARRAYRELATEDINFO),
- BE(f_ArraySite, ARRAYSITE),
- BE(f_AtLeast, ATLEAST),
- BE(f_AtMost, ATMOST),
- BE(f_Becomes, BECOMES),
- BE(f_Boolean, BOOLEAN),
- BE(f_BooleanDisplay, BOOLEANDISPLAY),
- BE(f_BooleanMap, BOOLEANMAP),
- BE(f_BorderPattern, BORDERPATTERN),
- BE(f_BoundingBox, BOUNDINGBOX),
- BE(f_Cell, CELL),
- BE(f_CellRef, CELLREF),
- BE(f_Change, CHANGE),
- BE(f_Circle, CIRCLE),
- BE(f_Color, COLOR),
- BE(f_CommentGraphics, COMMENTGRAPHICS),
- BE(f_Compound, COMPOUND),
- BE(f_ConnectLocation, CONNECTLOCATION),
- BE(f_Contents, CONTENTS),
- BE(f_Criticality, CRITICALITY),
- BE(f_CurrentMap, CURRENTMAP),
- BE(f_Curve, CURVE),
- BE(f_Cycle, CYCLE),
- BE(f_DataOrigin, DATAORIGIN),
- BE(f_DcFanInLoad, DCFANINLOAD),
- BE(f_DcFanOutLoad, DCFANOUTLOAD),
- BE(f_DcMaxFanIn, DCMAXFANIN),
- BE(f_DcMaxFanOut, DCMAXFANOUT),
- BE(f_Delay, DELAY),
- BE(f_Delta, DELTA),
- BE(f_Design, DESIGN),
- BE(f_Designator, DESIGNATOR),
- BE(f_Difference, DIFFERENCE),
- BE(f_Display, DISPLAY),
- BE(f_Dominates, DOMINATES),
- BE(f_Dot, DOT),
- BE(f_Duration, DURATION),
- BE(f_EnclosureDistance, ENCLOSUREDISTANCE),
- BE(f_Entry, ENTRY),
- BE(f_Exactly, EXACTLY),
- BE(f_External, EXTERNAL),
- BE(f_Fabricate, FABRICATE),
- BE(f_Figure, FIGURE),
- BE(f_FigureArea, FIGUREAREA),
- BE(f_FigureGroup, FIGUREGROUP),
- BE(f_FigureGroupObject, FIGUREGROUPOBJECT),
- BE(f_FigureGroupOverride, FIGUREGROUPOVERRIDE),
- BE(f_FigureGroupRef, FIGUREGROUPREF),
- BE(f_FigurePerimeter, FIGUREPERIMETER),
- BE(f_FigureWidth, FIGUREWIDTH),
- BE(f_FillPattern, FILLPATTERN),
- BE(f_Follow, FOLLOW),
- BE(f_ForbiddenEvent, FORBIDDENEVENT),
- BE(f_GlobalPortRef, GLOBALPORTREF),
- BE(f_GreaterThan, GREATERTHAN),
- BE(f_GridMap, GRIDMAP),
- BE(f_IncludeFigureGroup, INCLUDEFIGUREGROUP),
- BE(f_Instance, INSTANCE),
- BE(f_InstanceBackAnnotate, INSTANCEBACKANNOTATE),
- BE(f_InstanceGroup, INSTANCEGROUP),
- BE(f_InstanceMap, INSTANCEMAP),
- BE(f_InstanceRef, INSTANCEREF),
- BE(f_Integer, INTEGER),
- BE(f_IntegerDisplay, INTEGERDISPLAY),
- BE(f_InterFigureGroupSpacing, INTERFIGUREGROUPSPACING),
- BE(f_Interface, INTERFACE),
- BE(f_Intersection, INTERSECTION),
- BE(f_IntraFigureGroupSpacing, INTRAFIGUREGROUPSPACING),
- BE(f_Inverse, INVERSE),
- BE(f_Joined, JOINED),
- BE(f_KeywordDisplay, KEYWORDDISPLAY),
- BE(f_KeywordMap, KEYWORDMAP),
- BE(f_LessThan, LESSTHAN),
- BE(f_Library, LIBRARY),
- BE(f_LibraryRef, LIBRARYREF),
- BE(f_ListOfNets, LISTOFNETS),
- BE(f_ListOfPorts, LISTOFPORTS),
- BE(f_LoadDelay, LOADDELAY),
- BE(f_LogicAssign, LOGICASSIGN),
- BE(f_LogicInput, LOGICINPUT),
- BE(f_LogicList, LOGICLIST),
- BE(f_LogicMapInput, LOGICMAPINPUT),
- BE(f_LogicMapOutput, LOGICMAPOUTPUT),
- BE(f_LogicOneOf, LOGICONEOF),
- BE(f_LogicOutput, LOGICOUTPUT),
- BE(f_LogicPort, LOGICPORT),
- BE(f_LogicRef, LOGICREF),
- BE(f_LogicValue, LOGICVALUE),
- BE(f_LogicWaveform, LOGICWAVEFORM),
- BE(f_Maintain, MAINTAIN),
- BE(f_Match, MATCH),
- BE(f_Member, MEMBER),
- BE(f_MiNoMax, MINOMAX),
- BE(f_MiNoMaxDisplay, MINOMAXDISPLAY),
- BE(f_Mnm, MNM),
- BE(f_MultipleValueSet, MULTIPLEVALUESET),
- BE(f_MustJoin, MUSTJOIN),
- BE(f_Name, NAME),
- BE(f_Net, NET),
- BE(f_NetBackAnnotate, NETBACKANNOTATE),
- BE(f_NetBundle, NETBUNDLE),
- BE(f_NetDelay, NETDELAY),
- BE(f_NetGroup, NETGROUP),
- BE(f_NetMap, NETMAP),
- BE(f_NetRef, NETREF),
- BE(f_NonPermutable, NONPERMUTABLE),
- BE(f_NotAllowed, NOTALLOWED),
- BE(f_NotchSpacing, NOTCHSPACING),
- BE(f_Number, NUMBER),
- BE(f_NumberDefinition, NUMBERDEFINITION),
- BE(f_NumberDisplay, NUMBERDISPLAY),
- BE(f_OffPageConnector, OFFPAGECONNECTOR),
- BE(f_OffsetEvent, OFFSETEVENT),
- BE(f_OpenShape, OPENSHAPE),
- BE(f_Origin, ORIGIN),
- BE(f_OverhangDistance, OVERHANGDISTANCE),
- BE(f_OverlapDistance, OVERLAPDISTANCE),
- BE(f_Oversize, OVERSIZE),
- BE(f_Page, PAGE),
- BE(f_PageSize, PAGESIZE),
- BE(f_Parameter, PARAMETER),
- BE(f_ParameterAssign, PARAMETERASSIGN),
- BE(f_ParameterDisplay, PARAMETERDISPLAY),
- BE(f_Path, PATH),
- BE(f_PathDelay, PATHDELAY),
- BE(f_Permutable, PERMUTABLE),
- BE(f_PhysicalDesignRule, PHYSICALDESIGNRULE),
- BE(f_Plug, PLUG),
- BE(f_Point, POINT),
- BE(f_PointDisplay, POINTDISPLAY),
- BE(f_PointList, POINTLIST),
- BE(f_Polygon, POLYGON),
- BE(f_Port, PORT),
- BE(f_PortBackAnnotate, PORTBACKANNOTATE),
- BE(f_PortBundle, PORTBUNDLE),
- BE(f_PortDelay, PORTDELAY),
- BE(f_PortGroup, PORTGROUP),
- BE(f_PortImplementation, PORTIMPLEMENTATION),
- BE(f_PortInstance, PORTINSTANCE),
- BE(f_PortList, PORTLIST),
- BE(f_PortListAlias, PORTLISTALIAS),
- BE(f_PortMap, PORTMAP),
- BE(f_PortRef, PORTREF),
- BE(f_Program, PROGRAM),
- BE(f_Property, PROPERTY),
- BE(f_PropertyDisplay, PROPERTYDISPLAY),
- BE(f_ProtectionFrame, PROTECTIONFRAME),
- BE(f_RangeVector, RANGEVECTOR),
- BE(f_Rectangle, RECTANGLE),
- BE(f_RectangleSize, RECTANGLESIZE),
- BE(f_Rename, RENAME),
- BE(f_Resolves, RESOLVES),
- BE(f_Scale, SCALE),
- BE(f_Section, SECTION),
- BE(f_Shape, SHAPE),
- BE(f_Simulate, SIMULATE),
- BE(f_SimulationInfo, SIMULATIONINFO),
- BE(f_SingleValueSet, SINGLEVALUESET),
- BE(f_Site, SITE),
- BE(f_Socket, SOCKET),
- BE(f_SocketSet, SOCKETSET),
- BE(f_Status, STATUS),
- BE(f_Steady, STEADY),
- BE(f_String, STRING),
- BE(f_StringDisplay, STRINGDISPLAY),
- BE(f_Strong, STRONG),
- BE(f_Symbol, SYMBOL),
- BE(f_Symmetry, SYMMETRY),
- BE(f_Table, TABLE),
- BE(f_TableDefault, TABLEDEFAULT),
- BE(f_Technology, TECHNOLOGY),
- BE(f_TimeInterval, TIMEINTERVAL),
- BE(f_Timing, TIMING),
- BE(f_Transform, TRANSFORM),
- BE(f_Transition, TRANSITION),
- BE(f_Trigger, TRIGGER),
- BE(f_Union, UNION),
- BE(f_View, VIEW),
- BE(f_ViewList, VIEWLIST),
- BE(f_ViewMap, VIEWMAP),
- BE(f_ViewRef, VIEWREF),
- BE(f_Visible, VISIBLE),
- BE(f_VoltageMap, VOLTAGEMAP),
- BE(f_WaveValue, WAVEVALUE),
- BE(f_Weak, WEAK),
- BE(f_WeakJoined, WEAKJOINED),
- BE(f_When, WHEN),
- BE(f_Written, WRITTEN)
- };
- static int BinderDefSize = sizeof(BinderDef) / sizeof(Binder);
- /*
- * Keyword table:
- *
- * This hash table holds all strings which may have to be matched
- * to. WARNING: it is assumed that there is no overlap of the 'token'
- * and 'context' strings.
- */
- typedef struct Keyword {
- struct Keyword *Next; /* pointer to next entry */
- char *String; /* pointer to associated string */
- } Keyword;
- #define KEYWORD_HASH 127 /* hash table size */
- static Keyword *KeywordTable[KEYWORD_HASH];
- /*
- * Enter keyword:
- *
- * The passed string is entered into the keyword hash table.
- */
- static EnterKeyword(str)
- char *str;
- {
- /*
- * Locals.
- */
- register Keyword *key;
- register unsigned int hsh;
- register char *cp;
- /*
- * Create the hash code, and add an entry to the table.
- */
- for (hsh = 0, cp = str; *cp; hsh += hsh + *cp++);
- hsh %= KEYWORD_HASH;
- key = (Keyword *) Malloc(sizeof(Keyword));
- key->Next = KeywordTable[hsh];
- (KeywordTable[hsh] = key)->String = str;
- }
- /*
- * Find keyword:
- *
- * The passed string is located within the keyword table. If an
- * entry exists, then the value of the keyword string is returned. This
- * is real useful for doing string comparisons by pointer value later.
- * If there is no match, a NULL is returned.
- */
- static char *FindKeyword(str)
- char *str;
- {
- /*
- * Locals.
- */
- register Keyword *wlk,*owk;
- register unsigned int hsh;
- register char *cp;
- char lower[IDENT_LENGTH + 1];
- /*
- * Create a lower case copy of the string.
- */
- for (cp = lower; *str;)
- if (isupper(*str))
- *cp++ = tolower(*str++);
- else
- *cp++ = *str++;
- *cp = '\0';
- /*
- * Search the hash table for a match.
- */
- for (hsh = 0, cp = lower; *cp; hsh += hsh + *cp++);
- hsh %= KEYWORD_HASH;
- for (owk = NULL, wlk = KeywordTable[hsh]; wlk; wlk = (owk = wlk)->Next)
- if (!strcmp(wlk->String,lower)){
- /*
- * Readjust the LRU.
- */
- if (owk){
- owk->Next = wlk->Next;
- wlk->Next = KeywordTable[hsh];
- KeywordTable[hsh] = wlk;
- }
- return (wlk->String);
- }
- return (NULL);
- }
- /*
- * Token hash table.
- */
- #define TOKEN_HASH 51
- static Token *TokenHash[TOKEN_HASH];
- /*
- * Find token:
- *
- * A pointer to the token of the passed code is returned. If
- * no such beastie is present a NULL is returned instead.
- */
- static Token *FindToken(cod)
- register int cod;
- {
- /*
- * Locals.
- */
- register Token *wlk,*owk;
- register unsigned int hsh;
- /*
- * Search the hash table for a matching token.
- */
- hsh = cod % TOKEN_HASH;
- for (owk = NULL, wlk = TokenHash[hsh]; wlk; wlk = (owk = wlk)->Next)
- if (cod == wlk->Code){
- if (owk){
- owk->Next = wlk->Next;
- wlk->Next = TokenHash[hsh];
- TokenHash[hsh] = wlk;
- }
- break;
- }
- return (wlk);
- }
- /*
- * Context hash table.
- */
- #define CONTEXT_HASH 127
- static Context *ContextHash[CONTEXT_HASH];
- /*
- * Find context:
- *
- * A pointer to the context of the passed code is returned. If
- * no such beastie is present a NULL is returned instead.
- */
- static Context *FindContext(cod)
- register int cod;
- {
- /*
- * Locals.
- */
- register Context *wlk,*owk;
- register unsigned int hsh;
- /*
- * Search the hash table for a matching context.
- */
- hsh = cod % CONTEXT_HASH;
- for (owk = NULL, wlk = ContextHash[hsh]; wlk; wlk = (owk = wlk)->Next)
- if (cod == wlk->Code){
- if (owk){
- owk->Next = wlk->Next;
- wlk->Next = ContextHash[hsh];
- ContextHash[hsh] = wlk;
- }
- break;
- }
- return (wlk);
- }
- /*
- * Token stacking variables.
- */
- #ifdef DEBUG
- #define TS_DEPTH 8
- #define TS_MASK (TS_DEPTH - 1)
- static unsigned int TSP = 0; /* token stack pointer */
- static char *TokenStack[TS_DEPTH]; /* token name strings */
- static short TokenType[TS_DEPTH]; /* token types */
- /*
- * Stack:
- *
- * Add a token to the debug stack. The passed string and type are
- * what is to be pushed.
- */
- static Stack(str,typ)
- char *str;
- int typ;
- {
- /*
- * Free any previous string, then push.
- */
- if (TokenStack[TSP & TS_MASK])
- Free(TokenStack[TSP & TS_MASK]);
- TokenStack[TSP & TS_MASK] = strcpy(Malloc(strlen(str) + 1),str);
- TokenType[TSP & TS_MASK] = typ;
- TSP += 1;
- }
- /*
- * Dump stack:
- *
- * This displays the last set of accumulated tokens.
- */
- static DumpStack()
- {
- /*
- * Locals.
- */
- register int i;
- register Context *cxt;
- register Token *tok;
- register char *nam;
- /*
- * Run through the list displaying the oldest first.
- */
- fprintf(Error,"\n\n");
- for (i = 0; i < TS_DEPTH; i += 1)
- if (TokenStack[(TSP + i) & TS_MASK]){
- /*
- * Get the type name string.
- */
- if (cxt = FindContext(TokenType[(TSP + i) & TS_MASK]))
- nam = cxt->Name;
- else if (tok = FindToken(TokenType[(TSP + i) & TS_MASK]))
- nam = tok->Name;
- else switch (TokenType[(TSP + i) & TS_MASK]){
- case IDENT: nam = "IDENT"; break;
- case INT: nam = "INT"; break;
- case KEYWORD: nam = "KEYWORD"; break;
- case STR: nam = "STR"; break;
- default: nam = "?"; break;
- }
- /*
- * Now print the token state.
- */
- fprintf(Error,"%2d %-16.16s '%s'\n",TS_DEPTH - i,nam,
- TokenStack[(TSP + i) & TS_MASK]);
- }
- fprintf(Error,"\n");
- }
- #else
- #define Stack(s,t)
- #endif DEBUG
- /*
- * yyerror:
- *
- * Standard error reporter, it prints out the passed string
- * preceeded by the current filename and line number.
- */
- static yyerror(ers)
- char *ers;
- {
- #ifdef DEBUG
- DumpStack();
- #endif DEBUG
- fprintf(Error,"%s, line %d: %s\n",InFile,LineNumber,ers);
- }
- /*
- * String bucket definitions.
- */
- #define BUCKET_SIZE 64
- typedef struct Bucket {
- struct Bucket *Next; /* pointer to next bucket */
- int Index; /* pointer to next free slot */
- char Data[BUCKET_SIZE]; /* string data */
- } Bucket;
- static Bucket *CurrentBucket = NULL; /* string bucket list */
- static int StringSize = 0; /* current string length */
- /*
- * Push string:
- *
- * This adds the passed charater to the current string bucket.
- */
- static PushString(chr)
- char chr;
- {
- /*
- * Locals.
- */
- register Bucket *bck;
- /*
- * Make sure there is room for the push.
- */
- if ((bck = CurrentBucket)->Index >= BUCKET_SIZE){
- bck = (Bucket *) Malloc(sizeof(Bucket));
- bck->Next = CurrentBucket;
- (CurrentBucket = bck)->Index = 0;
- }
- /*
- * Push the character.
- */
- bck->Data[bck->Index++] = chr;
- StringSize += 1;
- }
- /*
- * Form string:
- *
- * This converts the current string bucket into a real live string,
- * whose pointer is returned.
- */
- static char *FormString()
- {
- /*
- * Locals.
- */
- register Bucket *bck;
- register char *cp;
- /*
- * Allocate space for the string, set the pointer at the end.
- */
- cp = (char *) Malloc(StringSize + 1);
- cp += StringSize;
- *cp-- = '\0';
- /*
- * Yank characters out of the bucket.
- */
- for (bck = CurrentBucket; bck->Index || bck->Next;){
- if (!bck->Index){
- CurrentBucket = bck->Next;
- Free(bck);
- bck = CurrentBucket;
- }
- *cp-- = bck->Data[--bck->Index];
- }
- return (cp + 1);
- }
- /*
- * Parse EDIF:
- *
- * This builds the context tree and then calls the real parser.
- * It is passed two file streams, the first is where the input comes
- * from; the second is where error messages get printed.
- */
- ParseEDIF(inp,err)
- FILE *inp,*err;
- {
- /*
- * Locals.
- */
- register int i;
- static int ContextDefined = 1;
- /*
- * Set up the file state to something useful.
- */
- Input = inp;
- Error = err;
- LineNumber = 1;
- /*
- * Define both the enabled token and context strings.
- */
- if (ContextDefined){
- for (i = TokenDefSize; i--; EnterKeyword(TokenDef[i].Name)){
- register unsigned int hsh;
- hsh = TokenDef[i].Code % TOKEN_HASH;
- TokenDef[i].Next = TokenHash[hsh];
- TokenHash[hsh] = &TokenDef[i];
- }
- for (i = ContextDefSize; i--; EnterKeyword(ContextDef[i].Name)){
- register unsigned int hsh;
- hsh = ContextDef[i].Code % CONTEXT_HASH;
- ContextDef[i].Next = ContextHash[hsh];
- ContextHash[hsh] = &ContextDef[i];
- }
- /*
- * Build the context tree.
- */
- for (i = BinderDefSize; i--;){
- register Context *cxt;
- register int j;
- /*
- * Define the current context to have carriers bound to it.
- */
- cxt = FindContext(BinderDef[i].Origin);
- for (j = BinderDef[i].FollowerSize; j--;){
- register ContextCar *cc;
- /*
- * Add carriers to the current context.
- */
- cc = (ContextCar *) Malloc(sizeof(ContextCar));
- cc->Next = cxt->Context;
- (cxt->Context = cc)->Context =
- FindContext(ABS(BinderDef[i].Follower[j]));
- cc->u.Single = BinderDef[i].Follower[j] < 0;
- }
- }
- /*
- * Build the token tree.
- */
- for (i = TieDefSize; i--;){
- register Context *cxt;
- register int j;
- /*
- * Define the current context to have carriers bound to it.
- */
- cxt = FindContext(TieDef[i].Origin);
- for (j = TieDef[i].EnableSize; j--;){
- register TokenCar *tc;
- /*
- * Add carriers to the current context.
- */
- tc = (TokenCar *) Malloc(sizeof(TokenCar));
- tc->Next = cxt->Token;
- (cxt->Token = tc)->Token = FindToken(TieDef[i].Enable[j]);
- }
- }
- /*
- * Put a bogus context on the stack which has 'EDIF' as its
- * follower.
- */
- CSP = (ContextCar *) Malloc(sizeof(ContextCar));
- CSP->Next = NULL;
- CSP->Context = FindContext(NULL);
- CSP->u.Used = NULL;
- ContextDefined = 0;
- }
- /*
- * Create an initial, empty string bucket.
- */
- CurrentBucket = (Bucket *) Malloc(sizeof(Bucket));
- CurrentBucket->Next = 0;
- CurrentBucket->Index = 0;
- /*
- * Fill the token stack with NULLs if debugging is enabled.
- */
- #ifdef DEBUG
- for (i = TS_DEPTH; i--; TokenStack[i] = NULL)
- if (TokenStack[i])
- Free(TokenStack[i]);
- TSP = 0;
- #endif DEBUG
- /*
- * Go parse things!
- */
- yyparse();
- }
- /*
- * Match token:
- *
- * The passed string is looked up in the current context's token
- * list to see if it is enabled. If so the token value is returned,
- * if not then zero.
- */
- static int MatchToken(str)
- register char *str;
- {
- /*
- * Locals.
- */
- register TokenCar *wlk,*owk;
- /*
- * Convert the string to the proper form, then search the token
- * carrier list for a match.
- */
- str = FindKeyword(str);
- for (owk = NULL, wlk = CSP->Context->Token; wlk; wlk = (owk = wlk)->Next)
- if (str == wlk->Token->Name){
- if (owk){
- owk->Next = wlk->Next;
- wlk->Next = CSP->Context->Token;
- CSP->Context->Token = wlk;
- }
- return (wlk->Token->Code);
- }
- return (0);
- }
- /*
- * Match context:
- *
- * If the passed keyword string is within the current context, the
- * new context is pushed and token value is returned. A zero otherwise.
- */
- static int MatchContext(str)
- register char *str;
- {
- /*
- * Locals.
- */
- register ContextCar *wlk,*owk;
- /*
- * See if the context is present.
- */
- str = FindKeyword(str);
- for (owk = NULL, wlk = CSP->Context->Context; wlk; wlk = (owk = wlk)->Next)
- if (str == wlk->Context->Name){
- if (owk){
- owk->Next = wlk->Next;
- wlk->Next = CSP->Context->Context;
- CSP->Context->Context = wlk;
- }
- /*
- * If a single context, make sure it isn't already used.
- */
- if (wlk->u.Single){
- register UsedCar *usc;
- for (usc = CSP->u.Used; usc; usc = usc->Next)
- if (usc->Code == wlk->Context->Code)
- break;
- if (usc){
- sprintf(CharBuf,"'%s' is used more than once within '%s'",
- str,CSP->Context->Name);
- yyerror(CharBuf);
- } else {
- usc = (UsedCar *) Malloc(sizeof(UsedCar));
- usc->Next = CSP->u.Used;
- (CSP->u.Used = usc)->Code = wlk->Context->Code;
- }
- }
- /*
- * Push the new context.
- */
- owk = (ContextCar *) Malloc(sizeof(ContextCar));
- owk->Next = CSP;
- (CSP = owk)->Context = wlk->Context;
- owk->u.Used = NULL;
- return (wlk->Context->Code);
- }
- return (0);
- }
- /*
- * PopC:
- *
- * This pops the current context.
- */
- static PopC()
- {
- /*
- * Locals.
- */
- register UsedCar *usc;
- register ContextCar *csp;
- /*
- * Release single markers and pop context.
- */
- while (usc = CSP->u.Used){
- CSP->u.Used = usc->Next;
- Free(usc);
- }
- csp = CSP->Next;
- Free(CSP);
- CSP = csp;
- }
- /*
- * Lexical analyzer states.
- */
- #define L_START 0
- #define L_INT 1
- #define L_IDENT 2
- #define L_KEYWORD 3
- #define L_STRING 4
- #define L_KEYWORD2 5
- #define L_ASCIICHAR 6
- #define L_ASCIICHAR2 7
- /*
- * yylex:
- *
- * This is the lexical analyzer called by the YACC/BISON parser.
- * It returns a pretty restricted set of token types and does the
- * context movement when acceptable keywords are found. The token
- * value returned is a NULL terminated string to allocated storage
- * (ie - it should get released some time) with some restrictions.
- * The token value for integers is strips a leading '+' if present.
- * String token values have the leading and trailing '"'-s stripped.
- * '%' conversion characters in string values are passed converted.
- * The '(' and ')' characters do not have a token value.
- */
- static int yylex()
- {
- /*
- * Locals.
- */
- register int c,s,l;
- /*
- * Keep on sucking up characters until we find something which
- * explicitly forces us out of this function.
- */
- for (s = L_START, l = 0; 1;){
- yytext[l++] = c = Getc(Input);
- switch (s){
- /*
- * Starting state, look for something resembling a token.
- */
- case L_START:
- if (isdigit(c) || c == '-')
- s = L_INT;
- else if (isalpha(c) || c == '&')
- s = L_IDENT;
- else if (isspace(c)){
- if (c == '\n')
- LineNumber += 1;
- l = 0;
- } else if (c == '('){
- l = 0;
- s = L_KEYWORD;
- } else if (c == '"')
- s = L_STRING;
- else if (c == '+'){
- l = 0; /* strip '+' */
- s = L_INT;
- } else if (c == EOF)
- return ('\0');
- else {
- yytext[1] = '\0';
- Stack(yytext,c);
- return (c);
- }
- break;
- /*
- * Suck up the integer digits.
- */
- case L_INT:
- if (isdigit(c))
- break;
- Ungetc(c);
- yytext[--l] = '\0';
- yylval.s = strcpy(Malloc(l + 1),yytext);
- Stack(yytext,INT);
- return (INT);
- /*
- * Grab an identifier, see if the current context enables
- * it with a specific token value.
- */
- case L_IDENT:
- if (isalpha(c) || isdigit(c) || c == '_')
- break;
- Ungetc(c);
- yytext[--l] = '\0';
- if (CSP->Context->Token && (c = MatchToken(yytext))){
- Stack(yytext,c);
- return (c);
- }
- yylval.s = strcpy(Malloc(l + 1),yytext);
- Stack(yytext,IDENT);
- return (IDENT);
- /*
- * Scan until you find the start of an identifier, discard
- * any whitespace found. On no identifier, return a '('.
- */
- case L_KEYWORD:
- if (isalpha(c) || c == '&'){
- s = L_KEYWORD2;
- break;
- } else if (isspace(c)){
- l = 0;
- break;
- }
- Ungetc(c);
- Stack("(",'(');
- return ('(');
- /*
- * Suck up the keyword identifier, if it matches the set of
- * allowable contexts then return its token value and push
- * the context, otherwise just return the identifier string.
- */
- case L_KEYWORD2:
- if (isalpha(c) || isdigit(c) || c == '_')
- break;
- Ungetc(c);
- yytext[--l] = '\0';
- if (c = MatchContext(yytext)){
- Stack(yytext,c);
- return (c);
- }
- yylval.s = strcpy(Malloc(l + 1),yytext);
- Stack(yytext,KEYWORD);
- return (KEYWORD);
- /*
- * Suck up string characters but once resolved they should
- * be deposited in the string bucket because they can be
- * arbitrarily long.
- */
- case L_STRING:
- if (c == '\n')
- LineNumber += 1;
- else if (c == '\r')
- ;
- else if (c == '"' || c == EOF){
- yylval.s = FormString();
- Stack(yylval.s,STR);
- return (STR);
- } else if (c == '%')
- s = L_ASCIICHAR;
- else
- PushString(c);
- l = 0;
- break;
- /*
- * Skip white space and look for integers to be pushed
- * as characters.
- */
- case L_ASCIICHAR:
- if (isdigit(c)){
- s = L_ASCIICHAR2;
- break;
- } else if (c == '%' || c == EOF)
- s = L_STRING;
- else if (c == '\n')
- LineNumber += 1;
- l = 0;
- break;
- /*
- * Convert the accumulated integer into a char and push.
- */
- case L_ASCIICHAR2:
- if (isdigit(c))
- break;
- Ungetc(c);
- yytext[--l] = '\0';
- PushString(atoi(yytext));
- s = L_ASCIICHAR;
- l = 0;
- break;
- }
- }
- }
-