home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8712 / edif / 2 / edif.y.2 < prev   
Encoding:
Text File  |  1990-07-13  |  47.9 KB  |  1,613 lines

  1.   {"mass",        MASS},
  2.   {"measured",        MEASURED},
  3.   {"mx",        MX},
  4.   {"mxr90",        MXR90},
  5.   {"my",        MY},
  6.   {"myr90",        MYR90},
  7.   {"netlist",        NETLIST},
  8.   {"output",        OUTPUT},
  9.   {"pcblayout",        PCBLAYOUT},
  10.   {"power",        POWER},
  11.   {"r0",        R0},
  12.   {"r180",        R180},
  13.   {"r270",        R270},
  14.   {"r90",        R90},
  15.   {"required",        REQUIRED},
  16.   {"resistance",    RESISTANCE},
  17.   {"ripper",        RIPPER},
  18.   {"round",        ROUND},
  19.   {"schematic",        SCHEMATIC},
  20.   {"stranger",        STRANGER},
  21.   {"symbolic",        SYMBOLIC},
  22.   {"temperature",    TEMPERATURE},
  23.   {"tie",        TIE},
  24.   {"time",        TIME},
  25.   {"truncate",        TRUNCATE},
  26.   {"uppercenter",    UPPERCENTER},
  27.   {"upperleft",        UPPERLEFT},
  28.   {"upperright",    UPPERRIGHT},
  29.   {"voltage",        VOLTAGE}
  30. };
  31. static int TokenDefSize = sizeof(TokenDef) / sizeof(Token);
  32. /*
  33.  *    Token enable definitions:
  34.  *
  35.  *      There is one array for each set of tokens enabled by a
  36.  *    particular context (barf). Another array is used to bind
  37.  *    these arrays to a context.
  38.  */
  39. static short e_CellType[] = {TIE,RIPPER,GENERIC};
  40. static short e_CornerType[] = {EXTEND,TRUNCATE,ROUND};
  41. static short e_Derivation[] = {CALCULATED,MEASURED,REQUIRED};
  42. static short e_Direction[] = {INPUT,OUTPUT,INOUT};
  43. static short e_EndType[] = {EXTEND,TRUNCATE,ROUND};
  44. static short e_Justify[] = {
  45.   CENTERCENTER,CENTERLEFT,CENTERRIGHT,LOWERCENTER,LOWERLEFT,LOWERRIGHT,
  46.   UPPERCENTER,UPPERLEFT,UPPERRIGHT
  47. };
  48. static short e_Orientation[] = {R0,R90,R180,R270,MX,MY,MXR90,MYR90};
  49. static short e_Unit[] = {
  50.   DISTANCE,CAPACITANCE,CURRENT,RESISTANCE,TEMPERATURE,TIME,VOLTAGE,MASS,
  51.   FREQUENCY,INDUCTANCE,ENERGY,POWER,CHARGE,CONDUCTANCE,FLUX,ANGLE
  52. };
  53. static short e_ViewType[] = {
  54.   MASKLAYOUT,PCBLAYOUT,NETLIST,SCHEMATIC,SYMBOLIC,BEHAVIOR,LOGICMODEL,
  55.   DOCUMENT,GRAPHIC,STRANGER
  56. };
  57. /*
  58.  *    Token tying table:
  59.  *
  60.  *      This binds enabled tokens to a context.
  61.  */
  62. typedef struct Tie {
  63.   short *Enable;        /* pointer to enable array */
  64.   short Origin;            /* '%token' value of context */
  65.   short EnableSize;        /* size of enabled array */
  66. } Tie;
  67. #define    TE(e,o)            {e,o,sizeof(e)/sizeof(short)}
  68. static Tie TieDef[] = {
  69.   TE(e_CellType,    CELLTYPE),
  70.   TE(e_CornerType,    CORNERTYPE),
  71.   TE(e_Derivation,    DERIVATION),
  72.   TE(e_Direction,    DIRECTION),
  73.   TE(e_EndType,        ENDTYPE),
  74.   TE(e_Justify,        JUSTIFY),
  75.   TE(e_Orientation,    ORIENTATION),
  76.   TE(e_Unit,        UNIT),
  77.   TE(e_ViewType,    VIEWTYPE)
  78. };
  79. static int TieDefSize = sizeof(TieDef) / sizeof(Tie);
  80. /*
  81.  *    Context definitions:
  82.  *
  83.  *      This associates keyword strings with '%token' values. It
  84.  *    also creates a pretty much empty header for later building of
  85.  *    the context tree. Again they needn't be sorted, but strings
  86.  *    must be lower case.
  87.  */
  88. typedef struct Context {
  89.   char *Name;            /* keyword name */
  90.   short Code;            /* '%token' value */
  91.   short Flags;            /* special operation flags */
  92.   struct ContextCar *Context;    /* contexts which can be moved to */
  93.   struct TokenCar *Token;    /* active tokens */
  94.   struct Context *Next;        /* hash table linkage */
  95. } Context;
  96. static Context ContextDef[] = {
  97.   {"",                NULL},        /* start context */
  98.   {"acload",            ACLOAD},
  99.   {"after",            AFTER},
  100.   {"annotate",            ANNOTATE},
  101.   {"apply",            APPLY},
  102.   {"arc",            ARC},
  103.   {"array",            ARRAY},
  104.   {"arraymacro",        ARRAYMACRO},
  105.   {"arrayrelatedinfo",        ARRAYRELATEDINFO},
  106.   {"arraysite",            ARRAYSITE},
  107.   {"atleast",            ATLEAST},
  108.   {"atmost",            ATMOST},
  109.   {"author",            AUTHOR},
  110.   {"basearray",            BASEARRAY},
  111.   {"becomes",            BECOMES},
  112.   {"between",            BETWEEN},
  113.   {"boolean",            BOOLEAN},
  114.   {"booleandisplay",        BOOLEANDISPLAY},
  115.   {"booleanmap",        BOOLEANMAP},
  116.   {"borderpattern",        BORDERPATTERN},
  117.   {"borderwidth",        BORDERWIDTH},
  118.   {"boundingbox",        BOUNDINGBOX},
  119.   {"cell",            CELL},
  120.   {"cellref",            CELLREF},
  121.   {"celltype",            CELLTYPE},
  122.   {"change",            CHANGE},
  123.   {"circle",            CIRCLE},
  124.   {"color",            COLOR},
  125.   {"comment",            COMMENT},
  126.   {"commentgraphics",        COMMENTGRAPHICS},
  127.   {"compound",            COMPOUND},
  128.   {"connectlocation",        CONNECTLOCATION},
  129.   {"contents",            CONTENTS},
  130.   {"cornertype",        CORNERTYPE},
  131.   {"criticality",        CRITICALITY},
  132.   {"currentmap",        CURRENTMAP},
  133.   {"curve",            CURVE},
  134.   {"cycle",            CYCLE},
  135.   {"dataorigin",        DATAORIGIN},
  136.   {"dcfaninload",        DCFANINLOAD},
  137.   {"dcfanoutload",        DCFANOUTLOAD},
  138.   {"dcmaxfanin",        DCMAXFANIN},
  139.   {"dcmaxfanout",        DCMAXFANOUT},
  140.   {"delay",            DELAY},
  141.   {"delta",            DELTA},
  142.   {"derivation",        DERIVATION},
  143.   {"design",            DESIGN},
  144.   {"designator",        DESIGNATOR},
  145.   {"difference",        DIFFERENCE},
  146.   {"direction",            DIRECTION},
  147.   {"display",            DISPLAY},
  148.   {"dominates",            DOMINATES},
  149.   {"dot",            DOT},
  150.   {"duration",            DURATION},
  151.   {"e",                E},
  152.   {"edif",            EDIF},
  153.   {"ediflevel",            EDIFLEVEL},
  154.   {"edifversion",        EDIFVERSION},
  155.   {"enclosuredistance",        ENCLOSUREDISTANCE},
  156.   {"endtype",            ENDTYPE},
  157.   {"entry",            ENTRY},
  158.   {"exactly",            EXACTLY},
  159.   {"external",            EXTERNAL},
  160.   {"fabricate",            FABRICATE},
  161.   {"false",            FALSE},
  162.   {"figure",            FIGURE},
  163.   {"figurearea",        FIGUREAREA},
  164.   {"figuregroup",        FIGUREGROUP},
  165.   {"figuregroupobject",        FIGUREGROUPOBJECT},
  166.   {"figuregroupoverride",    FIGUREGROUPOVERRIDE},
  167.   {"figuregroupref",        FIGUREGROUPREF},
  168.   {"figureperimeter",        FIGUREPERIMETER},
  169.   {"figurewidth",        FIGUREWIDTH},
  170.   {"fillpattern",        FILLPATTERN},
  171.   {"follow",            FOLLOW},
  172.   {"forbiddenevent",        FORBIDDENEVENT},
  173.   {"globalportref",        GLOBALPORTREF},
  174.   {"greaterthan",        GREATERTHAN},
  175.   {"gridmap",            GRIDMAP},
  176.   {"ignore",            IGNORE},
  177.   {"includefiguregroup",    INCLUDEFIGUREGROUP},
  178.   {"initial",            INITIAL},
  179.   {"instance",            INSTANCE},
  180.   {"instancebackannotate",    INSTANCEBACKANNOTATE},
  181.   {"instancegroup",        INSTANCEGROUP},
  182.   {"instancemap",        INSTANCEMAP},
  183.   {"instanceref",        INSTANCEREF},
  184.   {"integer",            INTEGER},
  185.   {"integerdisplay",        INTEGERDISPLAY},
  186.   {"interface",            INTERFACE},
  187.   {"interfiguregroupspacing",    INTERFIGUREGROUPSPACING},
  188.   {"intersection",        INTERSECTION},
  189.   {"intrafiguregroupspacing",    INTRAFIGUREGROUPSPACING},
  190.   {"inverse",            INVERSE},
  191.   {"isolated",            ISOLATED},
  192.   {"joined",            JOINED},
  193.   {"justify",            JUSTIFY},
  194.   {"keyworddisplay",        KEYWORDDISPLAY},
  195.   {"keywordlevel",        KEYWORDLEVEL},
  196.   {"keywordmap",        KEYWORDMAP},
  197.   {"lessthan",            LESSTHAN},
  198.   {"library",            LIBRARY},
  199.   {"libraryref",        LIBRARYREF},
  200.   {"listofnets",        LISTOFNETS},
  201.   {"listofports",        LISTOFPORTS},
  202.   {"loaddelay",            LOADDELAY},
  203.   {"logicassign",        LOGICASSIGN},
  204.   {"logicinput",        LOGICINPUT},
  205.   {"logiclist",            LOGICLIST},
  206.   {"logicmapinput",        LOGICMAPINPUT},
  207.   {"logicmapoutput",        LOGICMAPOUTPUT},
  208.   {"logiconeof",        LOGICONEOF},
  209.   {"logicoutput",        LOGICOUTPUT},
  210.   {"logicport",            LOGICPORT},
  211.   {"logicref",            LOGICREF},
  212.   {"logicvalue",        LOGICVALUE},
  213.   {"logicwaveform",        LOGICWAVEFORM},
  214.   {"maintain",            MAINTAIN},
  215.   {"match",            MATCH},
  216.   {"member",            MEMBER},
  217.   {"minomax",            MINOMAX},
  218.   {"minomaxdisplay",        MINOMAXDISPLAY},
  219.   {"mnm",            MNM},
  220.   {"multiplevalueset",        MULTIPLEVALUESET},
  221.   {"mustjoin",            MUSTJOIN},
  222.   {"name",            NAME},
  223.   {"net",            NET},
  224.   {"netbackannotate",        NETBACKANNOTATE},
  225.   {"netbundle",            NETBUNDLE},
  226.   {"netdelay",            NETDELAY},
  227.   {"netgroup",            NETGROUP},
  228.   {"netmap",            NETMAP},
  229.   {"netref",            NETREF},
  230.   {"nochange",            NOCHANGE},
  231.   {"nonpermutable",        NONPERMUTABLE},
  232.   {"notallowed",        NOTALLOWED},
  233.   {"notchspacing",        NOTCHSPACING},
  234.   {"number",            NUMBER},
  235.   {"numberdefinition",        NUMBERDEFINITION},
  236.   {"numberdisplay",        NUMBERDISPLAY},
  237.   {"offpageconnector",        OFFPAGECONNECTOR},
  238.   {"offsetevent",        OFFSETEVENT},
  239.   {"openshape",            OPENSHAPE},
  240.   {"orientation",        ORIENTATION},
  241.   {"origin",            ORIGIN},
  242.   {"overhangdistance",        OVERHANGDISTANCE},
  243.   {"overlapdistance",        OVERLAPDISTANCE},
  244.   {"oversize",            OVERSIZE},
  245.   {"owner",            OWNER},
  246.   {"page",            PAGE},
  247.   {"pagesize",            PAGESIZE},
  248.   {"parameter",            PARAMETER},
  249.   {"parameterassign",        PARAMETERASSIGN},
  250.   {"parameterdisplay",        PARAMETERDISPLAY},
  251.   {"path",            PATH},
  252.   {"pathdelay",            PATHDELAY},
  253.   {"pathwidth",            PATHWIDTH},
  254.   {"permutable",        PERMUTABLE},
  255.   {"physicaldesignrule",    PHYSICALDESIGNRULE},
  256.   {"plug",            PLUG},
  257.   {"point",            POINT},
  258.   {"pointdisplay",        POINTDISPLAY},
  259.   {"pointlist",            POINTLIST},
  260.   {"polygon",            POLYGON},
  261.   {"port",            PORT},
  262.   {"portbackannotate",        PORTBACKANNOTATE},
  263.   {"portbundle",        PORTBUNDLE},
  264.   {"portdelay",            PORTDELAY},
  265.   {"portgroup",            PORTGROUP},
  266.   {"portimplementation",    PORTIMPLEMENTATION},
  267.   {"portinstance",        PORTINSTANCE},
  268.   {"portlist",            PORTLIST},
  269.   {"portlistalias",        PORTLISTALIAS},
  270.   {"portmap",            PORTMAP},
  271.   {"portref",            PORTREF},
  272.   {"program",            PROGRAM},
  273.   {"property",            PROPERTY},
  274.   {"propertydisplay",        PROPERTYDISPLAY},
  275.   {"protectionframe",        PROTECTIONFRAME},
  276.   {"pt",            PT},
  277.   {"rangevector",        RANGEVECTOR},
  278.   {"rectangle",            RECTANGLE},
  279.   {"rectanglesize",        RECTANGLESIZE},
  280.   {"rename",            RENAME},
  281.   {"resolves",            RESOLVES},
  282.   {"scale",            SCALE},
  283.   {"scalex",            SCALEX},
  284.   {"scaley",            SCALEY},
  285.   {"section",            SECTION},
  286.   {"shape",            SHAPE},
  287.   {"simulate",            SIMULATE},
  288.   {"simulationinfo",        SIMULATIONINFO},
  289.   {"singlevalueset",        SINGLEVALUESET},
  290.   {"site",            SITE},
  291.   {"socket",            SOCKET},
  292.   {"socketset",            SOCKETSET},
  293.   {"status",            STATUS},
  294.   {"steady",            STEADY},
  295.   {"string",            STRING},
  296.   {"stringdisplay",        STRINGDISPLAY},
  297.   {"strong",            STRONG},
  298.   {"symbol",            SYMBOL},
  299.   {"symmetry",            SYMMETRY},
  300.   {"table",            TABLE},
  301.   {"tabledefault",        TABLEDEFAULT},
  302.   {"technology",        TECHNOLOGY},
  303.   {"textheight",        TEXTHEIGHT},
  304.   {"timeinterval",        TIMEINTERVAL},
  305.   {"timestamp",            TIMESTAMP},
  306.   {"timing",            TIMING},
  307.   {"transform",            TRANSFORM},
  308.   {"transition",        TRANSITION},
  309.   {"trigger",            TRIGGER},
  310.   {"true",            TRUE},
  311.   {"unconstrained",        UNCONSTRAINED},
  312.   {"undefined",            UNDEFINED},
  313.   {"union",            UNION},
  314.   {"unit",            UNIT},
  315.   {"unused",            UNUSED},
  316.   {"userdata",            USERDATA},
  317.   {"version",            VERSION},
  318.   {"view",            VIEW},
  319.   {"viewlist",            VIEWLIST},
  320.   {"viewmap",            VIEWMAP},
  321.   {"viewref",            VIEWREF},
  322.   {"viewtype",            VIEWTYPE},
  323.   {"visible",            VISIBLE},
  324.   {"voltagemap",        VOLTAGEMAP},
  325.   {"wavevalue",            WAVEVALUE},
  326.   {"weak",            WEAK},
  327.   {"weakjoined",        WEAKJOINED},
  328.   {"when",            WHEN},
  329.   {"written",            WRITTEN}
  330. };
  331. static int ContextDefSize = sizeof(ContextDef) / sizeof(Context);
  332. /*
  333.  *    Context follower tables:
  334.  *
  335.  *      This is pretty ugly, an array is defined for each context
  336.  *    which has following context levels. Yet another table is used
  337.  *    to bind these arrays to the originating contexts.
  338.  *      Arrays are declared as:
  339.  *
  340.  *        static short f_<Context name>[] = { ... };
  341.  *
  342.  *    The array entries are the '%token' values for all keywords which
  343.  *    can be reached from the <Context name> context. Like I said, ugly,
  344.  *    but it works.
  345.  *      A negative entry means that the follow can only occur once within
  346.  *    the specified context.
  347.  */
  348. static short f_NULL[] = {EDIF};
  349. static short f_Edif[] = {
  350.   NAME,RENAME,EDIFVERSION,EDIFLEVEL,KEYWORDMAP,-STATUS,EXTERNAL,LIBRARY,
  351.   DESIGN,COMMENT,USERDATA
  352. };
  353. static short f_AcLoad[] = {MNM,E,MINOMAXDISPLAY};
  354. static short f_After[] = {MNM,E,FOLLOW,MAINTAIN,LOGICASSIGN,COMMENT,USERDATA};
  355. static short f_Annotate[] = {STRINGDISPLAY};
  356. static short f_Apply[] = {CYCLE,LOGICINPUT,LOGICOUTPUT,COMMENT,USERDATA};
  357. static short f_Arc[] = {PT};
  358. static short f_Array[] = {NAME,RENAME};
  359. static short f_ArrayMacro[] = {PLUG};
  360. static short f_ArrayRelatedInfo[] = {
  361.   BASEARRAY,ARRAYSITE,ARRAYMACRO,COMMENT,USERDATA
  362. };
  363. static short f_ArraySite[] = {SOCKET};
  364. static short f_AtLeast[] = {E};
  365. static short f_AtMost[] = {E};
  366. static short f_Becomes[] = {NAME,LOGICLIST,LOGICONEOF};
  367. static short f_Between[] = {ATLEAST,GREATERTHAN,ATMOST,LESSTHAN};
  368. static short f_Boolean[] = {FALSE,TRUE,BOOLEANDISPLAY,BOOLEAN};
  369. static short f_BooleanDisplay[] = {FALSE,TRUE,DISPLAY};
  370. static short f_BooleanMap[] = {FALSE,TRUE};
  371. static short f_BorderPattern[] = {BOOLEAN};
  372. static short f_BoundingBox[] = {RECTANGLE};
  373. static short f_Cell[] = {
  374.   NAME,CELLTYPE,-STATUS,-VIEWMAP,VIEW,COMMENT,USERDATA,PROPERTY
  375. };
  376. static short f_CellRef[] = {NAME,LIBRARYREF};
  377. static short f_Change[] = {NAME,PORTREF,PORTLIST,BECOMES,TRANSITION};
  378. static short f_Circle[] = {PT,PROPERTY};
  379. static short f_Color[] = {E};
  380. static short f_CommentGraphics[] = {
  381.   ANNOTATE,FIGURE,INSTANCE,-BOUNDINGBOX,PROPERTY,COMMENT,USERDATA
  382. };
  383. static short f_Compound[] = {NAME};
  384. static short f_ConnectLocation[] = {FIGURE};
  385. static short f_Contents[] = {
  386.   INSTANCE,OFFPAGECONNECTOR,FIGURE,SECTION,NET,NETBUNDLE,PAGE,
  387.   COMMENTGRAPHICS,PORTIMPLEMENTATION,TIMING,SIMULATE,WHEN,FOLLOW,
  388.   LOGICPORT,-BOUNDINGBOX,COMMENT,USERDATA
  389. };
  390. static short f_Criticality[] = {INTEGERDISPLAY};
  391. static short f_CurrentMap[] = {MNM,E};
  392. static short f_Curve[] = {ARC,PT};
  393. static short f_Cycle[] = {DURATION};
  394. static short f_DataOrigin[] = {VERSION};
  395. static short f_DcFanInLoad[] = {E,NUMBERDISPLAY};
  396. static short f_DcFanOutLoad[] = {E,NUMBERDISPLAY};
  397. static short f_DcMaxFanIn[] = {E,NUMBERDISPLAY};
  398. static short f_DcMaxFanOut[] = {E,NUMBERDISPLAY};
  399. static short f_Delay[] = {MNM,E};
  400. static short f_Delta[] = {PT};
  401. static short f_Design[] = {
  402.   NAME,RENAME,CELLREF,STATUS,COMMENT,PROPERTY,USERDATA
  403. };
  404. static short f_Designator[] = {STRINGDISPLAY};
  405. static short f_Difference[] = {
  406.   FIGUREGROUPREF,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE
  407. };
  408. static short f_Display[] = {
  409.   NAME,FIGUREGROUPOVERRIDE,JUSTIFY,ORIENTATION,ORIGIN
  410. };
  411. static short f_Dominates[] = {NAME};
  412. static short f_Dot[] = {PT,PROPERTY};
  413. static short f_Duration[] = {E};
  414. static short f_EnclosureDistance[] = {
  415.   NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,
  416.   EXACTLY,BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
  417. };
  418. static short f_Entry[] = {
  419.   MATCH,CHANGE,STEADY,LOGICREF,PORTREF,NOCHANGE,TABLE,DELAY,LOADDELAY
  420. };
  421. static short f_Exactly[] = {E};
  422. static short f_External[] = {
  423.   NAME,RENAME,EDIFLEVEL,TECHNOLOGY,-STATUS,CELL,COMMENT,USERDATA
  424. };
  425. static short f_Fabricate[] = {NAME,RENAME};
  426. static short f_Figure[] = {
  427.   NAME,FIGUREGROUPOVERRIDE,CIRCLE,DOT,OPENSHAPE,PATH,POLYGON,RECTANGLE,
  428.   SHAPE,COMMENT,USERDATA
  429. };
  430. static short f_FigureArea[] = {
  431.   NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,
  432.   EXACTLY,BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
  433. };
  434. static short f_FigureGroup[] = {
  435.   NAME,RENAME,-CORNERTYPE,-ENDTYPE,-PATHWIDTH,-BORDERWIDTH,-COLOR,
  436.   -FILLPATTERN,-BORDERPATTERN,-TEXTHEIGHT,-VISIBLE,INCLUDEFIGUREGROUP,
  437.   COMMENT,PROPERTY,USERDATA
  438. };
  439. static short f_FigureGroupObject[] = {
  440.   NAME,FIGUREGROUPOBJECT,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE
  441. };
  442. static short f_FigureGroupOverride[] = {
  443.   NAME,-CORNERTYPE,-ENDTYPE,-PATHWIDTH,-BORDERWIDTH,-COLOR,-FILLPATTERN,
  444.   -TEXTHEIGHT,-BORDERPATTERN,VISIBLE,COMMENT,PROPERTY,USERDATA
  445. };
  446. static short f_FigureGroupRef[] = {NAME,LIBRARYREF};
  447. static short f_FigurePerimeter[] = {
  448.   NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
  449.   BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
  450. };
  451. static short f_FigureWidth[] = {
  452.   NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
  453.   BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
  454. };
  455. static short f_FillPattern[] = {BOOLEAN};
  456. static short f_Follow[] = {NAME,PORTREF,TABLE,DELAY,LOADDELAY};
  457. static short f_ForbiddenEvent[] = {TIMEINTERVAL,EVENT};
  458. static short f_GlobalPortRef[] = {NAME};
  459. static short f_GreaterThan[] = {E};
  460. static short f_GridMap[] = {E};
  461. static short f_IncludeFigureGroup[] = {
  462.   FIGUREGROUPREF,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE
  463. };
  464. static short f_Instance[] = {
  465.   NAME,RENAME,ARRAY,VIEWREF,VIEWLIST,-TRANSFORM,PARAMETERASSIGN,PORTINSTANCE,
  466.   TIMING,-DESIGNATOR,PROPERTY,COMMENT,USERDATA
  467. };
  468. static short f_InstanceBackAnnotate[] = {
  469.   INSTANCEREF,-DESIGNATOR,TIMING,PROPERTY,COMMENT
  470. };
  471. static short f_InstanceGroup[] = {INSTANCEREF};
  472. static short f_InstanceMap[] = {
  473.   INSTANCEREF,INSTANCEGROUP,COMMENT,USERDATA
  474. };
  475. static short f_InstanceRef[] = {NAME,MEMBER,INSTANCEREF,VIEWREF};
  476. static short f_Integer[] = {INTEGERDISPLAY,INTEGER};
  477. static short f_IntegerDisplay[] = {DISPLAY};
  478. static short f_Interface[] = {
  479.   PORT,PORTBUNDLE,-SYMBOL,-PROTECTIONFRAME,-ARRAYRELATEDINFO,PARAMETER,
  480.   JOINED,MUSTJOIN,WEAKJOINED,PERMUTABLE,TIMING,SIMULATE,-DESIGNATOR,PROPERTY,
  481.   COMMENT,USERDATA
  482. };
  483. static short f_InterFigureGroupSpacing[] = {
  484.   NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
  485.   BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
  486. };
  487. static short f_Intersection[] = {
  488.   FIGUREGROUPREF,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE
  489. };
  490. static short f_IntraFigureGroupSpacing[] = {
  491.   NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
  492.   BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
  493. };
  494. static short f_Inverse[] = {
  495.   FIGUREGROUPREF,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE
  496. };
  497. static short f_Joined[] = {PORTREF,PORTLIST,GLOBALPORTREF};
  498. static short f_KeywordDisplay[] = {DISPLAY};
  499. static short f_KeywordMap[] = {KEYWORDLEVEL,COMMENT};
  500. static short f_LessThan[] = {E};
  501. static short f_Library[] = {
  502.   NAME,RENAME,EDIFLEVEL,TECHNOLOGY,-STATUS,CELL,COMMENT,USERDATA
  503. };
  504. static short f_LibraryRef[] = {NAME};
  505. static short f_ListOfNets[] = {NET};
  506. static short f_ListOfPorts[] = {PORT,PORTBUNDLE};
  507. static short f_LoadDelay[] = {MNM,E,MINOMAXDISPLAY};
  508. static short f_LogicAssign[] = {NAME,PORTREF,LOGICREF,TABLE,DELAY,LOADDELAY};
  509. static short f_LogicInput[] = {PORTLIST,PORTREF,NAME,LOGICWAVEFORM};
  510. static short f_LogicList[] = {NAME,LOGICONEOF,IGNORE};
  511. static short f_LogicMapInput[] = {LOGICREF};
  512. static short f_LogicMapOutput[] = {LOGICREF};
  513. static short f_LogicOneOf[] = {NAME,LOGICLIST};
  514. static short f_LogicOutput[] = {PORTLIST,PORTREF,NAME,LOGICWAVEFORM};
  515. static short f_LogicPort[] = {NAME,RENAME,PROPERTY,COMMENT,USERDATA};
  516. static short f_LogicRef[] = {NAME,LIBRARYREF};
  517. static short f_LogicValue[] = {
  518.   NAME,RENAME,-VOLTAGEMAP,-CURRENTMAP,-BOOLEANMAP,-COMPOUND,-WEAK,-STRONG,
  519.   -DOMINATES,-LOGICMAPOUTPUT,-LOGICMAPINPUT,-ISOLATED,RESOLVES,PROPERTY,
  520.   COMMENT,USERDATA
  521. };
  522. static short f_LogicWaveform[] = {NAME,LOGICLIST,LOGICONEOF,IGNORE};
  523. static short f_Maintain[] = {NAME,PORTREF,DELAY,LOADDELAY};
  524. static short f_Match[] = {NAME,PORTREF,PORTLIST,LOGICLIST,LOGICONEOF};
  525. static short f_Member[] = {NAME};
  526. static short f_MiNoMax[] = {MNM,E,MINOMAXDISPLAY,MINOMAX};
  527. static short f_MiNoMaxDisplay[] = {MNM,E,DISPLAY};
  528. static short f_Mnm[] = {E,UNDEFINED,UNCONSTRAINED};
  529. static short f_MultipleValueSet[] = {RANGEVECTOR};
  530. static short f_MustJoin[] = {PORTREF,PORTLIST,WEAKJOINED,JOINED};
  531. static short f_Name[] = {DISPLAY};
  532. static short f_Net[] = {
  533.   NAME,RENAME,-CRITICALITY,NETDELAY,FIGURE,NET,INSTANCE,COMMENTGRAPHICS,
  534.   PROPERTY,COMMENT,USERDATA,JOINED,ARRAY
  535. };
  536. static short f_NetBackAnnotate[] = {
  537.   NETREF,NETDELAY,-CRITICALITY,PROPERTY,COMMENT
  538. };
  539. static short f_NetBundle[] = {
  540.   NAME,RENAME,ARRAY,LISTOFNETS,FIGURE,COMMENTGRAPHICS,PROPERTY,COMMENT,
  541.   USERDATA
  542. };
  543. static short f_NetDelay[] = {DERIVATION,DELAY,TRANSITION,BECOMES};
  544. static short f_NetGroup[] = {NAME,MEMBER,NETREF};
  545. static short f_NetMap[] = {NETREF,NETGROUP,COMMENT,USERDATA};
  546. static short f_NetRef[] = {NAME,MEMBER,NETREF,INSTANCEREF,VIEWREF};
  547. static short f_NonPermutable[] = {PORTREF,PERMUTABLE};
  548. static short f_NotAllowed[] = {
  549.   NAME,RENAME,FIGUREGROUPOBJECT,COMMENT,USERDATA
  550. };
  551. static short f_NotchSpacing[] = {
  552.   NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
  553.   BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
  554. };
  555. static short f_Number[] = {E,NUMBERDISPLAY,NUMBER};
  556. static short f_NumberDefinition[] = {SCALE,-GRIDMAP,COMMENT};
  557. static short f_NumberDisplay[] = {E,DISPLAY};
  558. static short f_OffPageConnector[] = {
  559.   NAME,RENAME,-UNUSED,PROPERTY,COMMENT,USERDATA
  560. };
  561. static short f_OffsetEvent[] = {EVENT,E};
  562. static short f_OpenShape[] = {CURVE,PROPERTY};
  563. static short f_Origin[] = {PT};
  564. static short f_OverhangDistance[] = {
  565.   NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
  566.   BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
  567. };
  568. static short f_OverlapDistance[] = {
  569.   NAME,RENAME,FIGUREGROUPOBJECT,LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,
  570.   BETWEEN,SINGLEVALUESET,COMMENT,USERDATA
  571. };
  572. static short f_Oversize[] = {
  573.   FIGUREGROUPREF,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE,CORNERTYPE
  574. };
  575. static short f_Page[] = {
  576.   NAME,RENAME,ARRAY,INSTANCE,NET,NETBUNDLE,COMMENTGRAPHICS,PORTIMPLEMENTATION,
  577.   -PAGESIZE,-BOUNDINGBOX,COMMENT,USERDATA
  578. };
  579. static short f_PageSize[] = {RECTANGLE};
  580. static short f_Parameter[] = {
  581.   NAME,RENAME,ARRAY,BOOLEAN,INTEGER,MINOMAX,NUMBER,POINT,STRING
  582. };
  583. static short f_ParameterAssign[] = {
  584.   NAME,MEMBER,BOOLEAN,INTEGER,MINOMAX,NUMBER,POINT,STRING
  585. };
  586. static short f_ParameterDisplay[] = {NAME,MEMBER,DISPLAY};
  587. static short f_Path[] = {POINTLIST,PROPERTY};
  588. static short f_PathDelay[] = {DELAY,EVENT};
  589. static short f_Permutable[] = {PORTREF,PERMUTABLE,NONPERMUTABLE};
  590. static short f_PhysicalDesignRule[] = {
  591.   FIGUREWIDTH,FIGUREAREA,RECTANGLESIZE,FIGUREPERIMETER,OVERLAPDISTANCE,
  592.   OVERHANGDISTANCE,ENCLOSUREDISTANCE,INTERFIGUREGROUPSPACING,NOTCHSPACING,
  593.   INTRAFIGUREGROUPSPACING,NOTALLOWED,FIGUREGROUP,COMMENT,USERDATA
  594. };
  595. static short f_Plug[] = {SOCKETSET};
  596. static short f_Point[] = {PT,POINTDISPLAY,POINT};
  597. static short f_PointDisplay[] = {PT,DISPLAY};
  598. static short f_PointList[] = {PT};
  599. static short f_Polygon[] = {POINTLIST,PROPERTY};
  600. static short f_Port[] = {
  601.   NAME,RENAME,ARRAY,-DIRECTION,-UNUSED,PORTDELAY,-DESIGNATOR,-DCFANINLOAD,
  602.   -DCFANOUTLOAD,-DCMAXFANIN,-DCMAXFANOUT,-ACLOAD,PROPERTY,COMMENT,USERDATA
  603. };
  604. static short f_PortBackAnnotate[] = {
  605.   PORTREF,-DESIGNATOR,PORTDELAY,-DCFANINLOAD,-DCFANOUTLOAD,-DCMAXFANIN,
  606.   -DCMAXFANOUT,-ACLOAD,PROPERTY,COMMENT
  607. };
  608. static short f_PortBundle[] = {
  609.   NAME,RENAME,ARRAY,LISTOFPORTS,PROPERTY,COMMENT,USERDATA
  610. };
  611. static short f_PortDelay[] = {DERIVATION,DELAY,LOADDELAY,TRANSITION,BECOMES};
  612. static short f_PortGroup[] = {NAME,MEMBER,PORTREF};
  613. static short f_PortImplementation[] = {
  614.   PORTREF,NAME,MEMBER,-CONNECTLOCATION,FIGURE,INSTANCE,COMMENTGRAPHICS,
  615.   PROPERTYDISPLAY,KEYWORDDISPLAY,PROPERTY,USERDATA,COMMENT
  616. };
  617. static short f_PortInstance[] = {
  618.   PORTREF,NAME,MEMBER,-UNUSED,PORTDELAY,-DESIGNATOR,-DCFANINLOAD,-DCFANOUTLOAD,
  619.   -DCMAXFANIN,-DCMAXFANOUT,-ACLOAD,PROPERTY,COMMENT,USERDATA
  620. };
  621. static short f_PortList[] = {PORTREF,NAME,MEMBER};
  622. static short f_PortListAlias[] = {NAME,RENAME,ARRAY,PORTLIST};
  623. static short f_PortMap[] = {PORTREF,PORTGROUP,COMMENT,USERDATA};
  624. static short f_PortRef[] = {NAME,MEMBER,PORTREF,INSTANCEREF,VIEWREF};
  625. static short f_Program[] = {VERSION};
  626. static short f_Property[] = {
  627.   NAME,RENAME,BOOLEAN,INTEGER,MINOMAX,NUMBER,POINT,STRING,-OWNER,-UNIT,
  628.   PROPERTY,COMMENT
  629. };
  630. static short f_PropertyDisplay[] = {NAME,DISPLAY};
  631. static short f_ProtectionFrame[] = {
  632.   PORTIMPLEMENTATION,FIGURE,INSTANCE,COMMENTGRAPHICS,-BOUNDINGBOX,
  633.   PROPERTYDISPLAY,KEYWORDDISPLAY,PARAMETERDISPLAY,PROPERTY,COMMENT,USERDATA
  634. };
  635. static short f_RangeVector[] = {
  636.   LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,BETWEEN,SINGLEVALUESET
  637. };
  638. static short f_Rectangle[] = {PT,PROPERTY};
  639. static short f_RectangleSize[] = {
  640.   NAME,RENAME,FIGUREGROUPOBJECT,RANGEVECTOR,MULTIPLEVALUESET,COMMENT,USERDATA
  641. };
  642. static short f_Rename[] = {NAME,STRINGDISPLAY};
  643. static short f_Resolves[] = {NAME};
  644. static short f_Scale[] = {E,UNIT};
  645. static short f_Section[] = {SECTION,INSTANCE};
  646. static short f_Shape[] = {CURVE,PROPERTY};
  647. static short f_Simulate[] = {
  648.   NAME,PORTLISTALIAS,WAVEVALUE,APPLY,COMMENT,USERDATA
  649. };
  650. static short f_SimulationInfo[] = {LOGICVALUE,COMMENT,USERDATA};
  651. static short f_SingleValueSet[] = {
  652.   LESSTHAN,GREATERTHAN,ATMOST,ATLEAST,EXACTLY,BETWEEN
  653. };
  654. static short f_Site[] = {VIEWREF,TRANSFORM};
  655. static short f_Socket[] = {SYMMETRY};
  656. static short f_SocketSet[] = {SYMMETRY,SITE};
  657. static short f_Status[] = {WRITTEN,COMMENT,USERDATA};
  658. static short f_Steady[] = {
  659.   NAME,MEMBER,PORTREF,PORTLIST,DURATION,TRANSITION,BECOMES
  660. };
  661. static short f_String[] = {STRINGDISPLAY,STRING};
  662. static short f_StringDisplay[] = {DISPLAY};
  663. static short f_Strong[] = {NAME};
  664. static short f_Symbol[] = {
  665.   PORTIMPLEMENTATION,FIGURE,INSTANCE,COMMENTGRAPHICS,ANNOTATE,-PAGESIZE,
  666.   -BOUNDINGBOX,PROPERTYDISPLAY,KEYWORDDISPLAY,PARAMETERDISPLAY,PROPERTY,
  667.   COMMENT,USERDATA
  668. };
  669. static short f_Symmetry[] = {TRANSFORM};
  670. static short f_Table[] = {ENTRY,TABLEDEFAULT};
  671. static short f_TableDefault[] = {
  672.   LOGICREF,PORTREF,NOCHANGE,TABLE,DELAY,LOADDELAY
  673. };
  674. static short f_Technology[] = {
  675.   NUMBERDEFINITION,FIGUREGROUP,FABRICATE,-SIMULATIONINFO,COMMENT,USERDATA,
  676.   -PHYSICALDESIGNRULE
  677. };
  678. static short f_TimeInterval[] = {EVENT,OFFSETEVENT,DURATION};
  679. static short f_Timing[] = {
  680.   DERIVATION,PATHDELAY,FORBIDDENEVENT,COMMENT,USERDATA
  681. };
  682. static short f_Transform[] = {SCALEX,SCALEY,DELTA,ORIENTATION,ORIGIN};
  683. static short f_Transition[] = {NAME,LOGICLIST,LOGICONEOF};
  684. static short f_Trigger[] = {CHANGE,STEADY,INITIAL};
  685. static short f_Union[] = {
  686.   FIGUREGROUPREF,INTERSECTION,UNION,DIFFERENCE,INVERSE,OVERSIZE
  687. };
  688. static short f_View[] = {
  689.   NAME,RENAME,VIEWTYPE,INTERFACE,-STATUS,-CONTENTS,COMMENT,PROPERTY,USERDATA
  690. };
  691. static short f_ViewList[] = {VIEWREF,VIEWLIST};
  692. static short f_ViewMap[] = {
  693.   PORTMAP,PORTBACKANNOTATE,INSTANCEMAP,INSTANCEBACKANNOTATE,NETMAP,
  694.   NETBACKANNOTATE,COMMENT,USERDATA
  695. };
  696. static short f_ViewRef[] = {NAME,CELLREF};
  697. static short f_Visible[] = {FALSE,TRUE};
  698. static short f_VoltageMap[] = {MNM,E};
  699. static short f_WaveValue[] = {NAME,RENAME,E,LOGICWAVEFORM};
  700. static short f_Weak[] = {NAME};
  701. static short f_WeakJoined[] = {PORTREF,PORTLIST,JOINED};
  702. static short f_When[] = {
  703.   TRIGGER,AFTER,FOLLOW,MAINTAIN,LOGICASSIGN,COMMENT,USERDATA
  704. };
  705. static short f_Written[] = {
  706.   TIMESTAMP,AUTHOR,PROGRAM,DATAORIGIN,PROPERTY,COMMENT,USERDATA
  707. };
  708. /*
  709.  *    Context binding table:
  710.  *
  711.  *      This binds context follower arrays to their originating context.
  712.  */
  713. typedef struct Binder {
  714.   short *Follower;        /* pointer to follower array */
  715.   short Origin;            /* '%token' value of origin */
  716.   short FollowerSize;        /* size of follower array */
  717. } Binder;
  718. #define    BE(f,o)            {f,o,sizeof(f)/sizeof(short)}
  719. static Binder BinderDef[] = {
  720.   BE(f_NULL,            NULL),
  721.   BE(f_Edif,            EDIF),
  722.   BE(f_AcLoad,            ACLOAD),
  723.   BE(f_After,            AFTER),
  724.   BE(f_Annotate,        ANNOTATE),
  725.   BE(f_Apply,            APPLY),
  726.   BE(f_Arc,            ARC),
  727.   BE(f_Array,            ARRAY),
  728.   BE(f_ArrayMacro,        ARRAYMACRO),
  729.   BE(f_ArrayRelatedInfo,    ARRAYRELATEDINFO),
  730.   BE(f_ArraySite,        ARRAYSITE),
  731.   BE(f_AtLeast,            ATLEAST),
  732.   BE(f_AtMost,            ATMOST),
  733.   BE(f_Becomes,            BECOMES),
  734.   BE(f_Boolean,            BOOLEAN),
  735.   BE(f_BooleanDisplay,        BOOLEANDISPLAY),
  736.   BE(f_BooleanMap,        BOOLEANMAP),
  737.   BE(f_BorderPattern,        BORDERPATTERN),
  738.   BE(f_BoundingBox,        BOUNDINGBOX),
  739.   BE(f_Cell,            CELL),
  740.   BE(f_CellRef,            CELLREF),
  741.   BE(f_Change,            CHANGE),
  742.   BE(f_Circle,            CIRCLE),
  743.   BE(f_Color,            COLOR),
  744.   BE(f_CommentGraphics,        COMMENTGRAPHICS),
  745.   BE(f_Compound,        COMPOUND),
  746.   BE(f_ConnectLocation,        CONNECTLOCATION),
  747.   BE(f_Contents,        CONTENTS),
  748.   BE(f_Criticality,        CRITICALITY),
  749.   BE(f_CurrentMap,        CURRENTMAP),
  750.   BE(f_Curve,            CURVE),
  751.   BE(f_Cycle,            CYCLE),
  752.   BE(f_DataOrigin,        DATAORIGIN),
  753.   BE(f_DcFanInLoad,        DCFANINLOAD),
  754.   BE(f_DcFanOutLoad,        DCFANOUTLOAD),
  755.   BE(f_DcMaxFanIn,        DCMAXFANIN),
  756.   BE(f_DcMaxFanOut,        DCMAXFANOUT),
  757.   BE(f_Delay,            DELAY),
  758.   BE(f_Delta,            DELTA),
  759.   BE(f_Design,            DESIGN),
  760.   BE(f_Designator,        DESIGNATOR),
  761.   BE(f_Difference,        DIFFERENCE),
  762.   BE(f_Display,            DISPLAY),
  763.   BE(f_Dominates,        DOMINATES),
  764.   BE(f_Dot,            DOT),
  765.   BE(f_Duration,        DURATION),
  766.   BE(f_EnclosureDistance,    ENCLOSUREDISTANCE),
  767.   BE(f_Entry,            ENTRY),
  768.   BE(f_Exactly,            EXACTLY),
  769.   BE(f_External,        EXTERNAL),
  770.   BE(f_Fabricate,        FABRICATE),
  771.   BE(f_Figure,            FIGURE),
  772.   BE(f_FigureArea,        FIGUREAREA),
  773.   BE(f_FigureGroup,        FIGUREGROUP),
  774.   BE(f_FigureGroupObject,    FIGUREGROUPOBJECT),
  775.   BE(f_FigureGroupOverride,    FIGUREGROUPOVERRIDE),
  776.   BE(f_FigureGroupRef,        FIGUREGROUPREF),
  777.   BE(f_FigurePerimeter,        FIGUREPERIMETER),
  778.   BE(f_FigureWidth,        FIGUREWIDTH),
  779.   BE(f_FillPattern,        FILLPATTERN),
  780.   BE(f_Follow,            FOLLOW),
  781.   BE(f_ForbiddenEvent,        FORBIDDENEVENT),
  782.   BE(f_GlobalPortRef,        GLOBALPORTREF),
  783.   BE(f_GreaterThan,        GREATERTHAN),
  784.   BE(f_GridMap,            GRIDMAP),
  785.   BE(f_IncludeFigureGroup,    INCLUDEFIGUREGROUP),
  786.   BE(f_Instance,        INSTANCE),
  787.   BE(f_InstanceBackAnnotate,    INSTANCEBACKANNOTATE),
  788.   BE(f_InstanceGroup,        INSTANCEGROUP),
  789.   BE(f_InstanceMap,        INSTANCEMAP),
  790.   BE(f_InstanceRef,        INSTANCEREF),
  791.   BE(f_Integer,            INTEGER),
  792.   BE(f_IntegerDisplay,        INTEGERDISPLAY),
  793.   BE(f_InterFigureGroupSpacing,    INTERFIGUREGROUPSPACING),
  794.   BE(f_Interface,        INTERFACE),
  795.   BE(f_Intersection,        INTERSECTION),
  796.   BE(f_IntraFigureGroupSpacing,    INTRAFIGUREGROUPSPACING),
  797.   BE(f_Inverse,            INVERSE),
  798.   BE(f_Joined,            JOINED),
  799.   BE(f_KeywordDisplay,        KEYWORDDISPLAY),
  800.   BE(f_KeywordMap,        KEYWORDMAP),
  801.   BE(f_LessThan,        LESSTHAN),
  802.   BE(f_Library,            LIBRARY),
  803.   BE(f_LibraryRef,        LIBRARYREF),
  804.   BE(f_ListOfNets,        LISTOFNETS),
  805.   BE(f_ListOfPorts,        LISTOFPORTS),
  806.   BE(f_LoadDelay,        LOADDELAY),
  807.   BE(f_LogicAssign,        LOGICASSIGN),
  808.   BE(f_LogicInput,        LOGICINPUT),
  809.   BE(f_LogicList,        LOGICLIST),
  810.   BE(f_LogicMapInput,        LOGICMAPINPUT),
  811.   BE(f_LogicMapOutput,        LOGICMAPOUTPUT),
  812.   BE(f_LogicOneOf,        LOGICONEOF),
  813.   BE(f_LogicOutput,        LOGICOUTPUT),
  814.   BE(f_LogicPort,        LOGICPORT),
  815.   BE(f_LogicRef,        LOGICREF),
  816.   BE(f_LogicValue,        LOGICVALUE),
  817.   BE(f_LogicWaveform,        LOGICWAVEFORM),
  818.   BE(f_Maintain,        MAINTAIN),
  819.   BE(f_Match,            MATCH),
  820.   BE(f_Member,            MEMBER),
  821.   BE(f_MiNoMax,            MINOMAX),
  822.   BE(f_MiNoMaxDisplay,        MINOMAXDISPLAY),
  823.   BE(f_Mnm,            MNM),
  824.   BE(f_MultipleValueSet,    MULTIPLEVALUESET),
  825.   BE(f_MustJoin,        MUSTJOIN),
  826.   BE(f_Name,            NAME),
  827.   BE(f_Net,            NET),
  828.   BE(f_NetBackAnnotate,        NETBACKANNOTATE),
  829.   BE(f_NetBundle,        NETBUNDLE),
  830.   BE(f_NetDelay,        NETDELAY),
  831.   BE(f_NetGroup,        NETGROUP),
  832.   BE(f_NetMap,            NETMAP),
  833.   BE(f_NetRef,            NETREF),
  834.   BE(f_NonPermutable,        NONPERMUTABLE),
  835.   BE(f_NotAllowed,        NOTALLOWED),
  836.   BE(f_NotchSpacing,        NOTCHSPACING),
  837.   BE(f_Number,            NUMBER),
  838.   BE(f_NumberDefinition,    NUMBERDEFINITION),
  839.   BE(f_NumberDisplay,        NUMBERDISPLAY),
  840.   BE(f_OffPageConnector,    OFFPAGECONNECTOR),
  841.   BE(f_OffsetEvent,        OFFSETEVENT),
  842.   BE(f_OpenShape,        OPENSHAPE),
  843.   BE(f_Origin,            ORIGIN),
  844.   BE(f_OverhangDistance,    OVERHANGDISTANCE),
  845.   BE(f_OverlapDistance,        OVERLAPDISTANCE),
  846.   BE(f_Oversize,        OVERSIZE),
  847.   BE(f_Page,            PAGE),
  848.   BE(f_PageSize,        PAGESIZE),
  849.   BE(f_Parameter,        PARAMETER),
  850.   BE(f_ParameterAssign,        PARAMETERASSIGN),
  851.   BE(f_ParameterDisplay,    PARAMETERDISPLAY),
  852.   BE(f_Path,            PATH),
  853.   BE(f_PathDelay,        PATHDELAY),
  854.   BE(f_Permutable,        PERMUTABLE),
  855.   BE(f_PhysicalDesignRule,    PHYSICALDESIGNRULE),
  856.   BE(f_Plug,            PLUG),
  857.   BE(f_Point,            POINT),
  858.   BE(f_PointDisplay,        POINTDISPLAY),
  859.   BE(f_PointList,        POINTLIST),
  860.   BE(f_Polygon,            POLYGON),
  861.   BE(f_Port,            PORT),
  862.   BE(f_PortBackAnnotate,    PORTBACKANNOTATE),
  863.   BE(f_PortBundle,        PORTBUNDLE),
  864.   BE(f_PortDelay,        PORTDELAY),
  865.   BE(f_PortGroup,        PORTGROUP),
  866.   BE(f_PortImplementation,    PORTIMPLEMENTATION),
  867.   BE(f_PortInstance,        PORTINSTANCE),
  868.   BE(f_PortList,        PORTLIST),
  869.   BE(f_PortListAlias,        PORTLISTALIAS),
  870.   BE(f_PortMap,            PORTMAP),
  871.   BE(f_PortRef,            PORTREF),
  872.   BE(f_Program,            PROGRAM),
  873.   BE(f_Property,        PROPERTY),
  874.   BE(f_PropertyDisplay,        PROPERTYDISPLAY),
  875.   BE(f_ProtectionFrame,        PROTECTIONFRAME),
  876.   BE(f_RangeVector,        RANGEVECTOR),
  877.   BE(f_Rectangle,        RECTANGLE),
  878.   BE(f_RectangleSize,        RECTANGLESIZE),
  879.   BE(f_Rename,            RENAME),
  880.   BE(f_Resolves,        RESOLVES),
  881.   BE(f_Scale,            SCALE),
  882.   BE(f_Section,            SECTION),
  883.   BE(f_Shape,            SHAPE),
  884.   BE(f_Simulate,        SIMULATE),
  885.   BE(f_SimulationInfo,        SIMULATIONINFO),
  886.   BE(f_SingleValueSet,        SINGLEVALUESET),
  887.   BE(f_Site,            SITE),
  888.   BE(f_Socket,            SOCKET),
  889.   BE(f_SocketSet,        SOCKETSET),
  890.   BE(f_Status,            STATUS),
  891.   BE(f_Steady,            STEADY),
  892.   BE(f_String,            STRING),
  893.   BE(f_StringDisplay,        STRINGDISPLAY),
  894.   BE(f_Strong,            STRONG),
  895.   BE(f_Symbol,            SYMBOL),
  896.   BE(f_Symmetry,        SYMMETRY),
  897.   BE(f_Table,            TABLE),
  898.   BE(f_TableDefault,        TABLEDEFAULT),
  899.   BE(f_Technology,        TECHNOLOGY),
  900.   BE(f_TimeInterval,        TIMEINTERVAL),
  901.   BE(f_Timing,            TIMING),
  902.   BE(f_Transform,        TRANSFORM),
  903.   BE(f_Transition,        TRANSITION),
  904.   BE(f_Trigger,            TRIGGER),
  905.   BE(f_Union,            UNION),
  906.   BE(f_View,            VIEW),
  907.   BE(f_ViewList,        VIEWLIST),
  908.   BE(f_ViewMap,            VIEWMAP),
  909.   BE(f_ViewRef,            VIEWREF),
  910.   BE(f_Visible,            VISIBLE),
  911.   BE(f_VoltageMap,        VOLTAGEMAP),
  912.   BE(f_WaveValue,        WAVEVALUE),
  913.   BE(f_Weak,            WEAK),
  914.   BE(f_WeakJoined,        WEAKJOINED),
  915.   BE(f_When,            WHEN),
  916.   BE(f_Written,            WRITTEN)
  917. };
  918. static int BinderDefSize = sizeof(BinderDef) / sizeof(Binder);
  919. /*
  920.  *    Keyword table:
  921.  *
  922.  *      This hash table holds all strings which may have to be matched
  923.  *    to. WARNING: it is assumed that there is no overlap of the 'token'
  924.  *    and 'context' strings.
  925.  */
  926. typedef struct Keyword {
  927.   struct Keyword *Next;         /* pointer to next entry */
  928.   char *String;            /* pointer to associated string */
  929. } Keyword;
  930. #define    KEYWORD_HASH    127    /* hash table size */
  931. static Keyword *KeywordTable[KEYWORD_HASH];
  932. /*
  933.  *    Enter keyword:
  934.  *
  935.  *      The passed string is entered into the keyword hash table.
  936.  */
  937. static EnterKeyword(str)
  938. char *str;
  939. {
  940.   /* 
  941.    *    Locals.
  942.    */
  943.   register Keyword *key;
  944.   register unsigned int hsh;
  945.   register char *cp;
  946.   /*
  947.    *    Create the hash code, and add an entry to the table.
  948.    */
  949.   for (hsh = 0, cp = str; *cp; hsh += hsh + *cp++);
  950.   hsh %= KEYWORD_HASH;
  951.   key = (Keyword *) Malloc(sizeof(Keyword));
  952.   key->Next = KeywordTable[hsh];
  953.   (KeywordTable[hsh] = key)->String = str;
  954. }
  955. /*
  956.  *    Find keyword:
  957.  *
  958.  *      The passed string is located within the keyword table. If an
  959.  *    entry exists, then the value of the keyword string is returned. This
  960.  *    is real useful for doing string comparisons by pointer value later.
  961.  *    If there is no match, a NULL is returned.
  962.  */
  963. static char *FindKeyword(str)
  964. char *str;
  965. {
  966.   /*
  967.    *    Locals.
  968.    */
  969.   register Keyword *wlk,*owk;
  970.   register unsigned int hsh;
  971.   register char *cp;
  972.   char lower[IDENT_LENGTH + 1];
  973.   /*
  974.    *    Create a lower case copy of the string.
  975.    */
  976.   for (cp = lower; *str;)
  977.     if (isupper(*str))
  978.       *cp++ = tolower(*str++);
  979.     else
  980.       *cp++ = *str++;
  981.   *cp = '\0';
  982.   /*
  983.    *    Search the hash table for a match.
  984.    */
  985.   for (hsh = 0, cp = lower; *cp; hsh += hsh + *cp++);
  986.   hsh %= KEYWORD_HASH;
  987.   for (owk = NULL, wlk = KeywordTable[hsh]; wlk; wlk = (owk = wlk)->Next)
  988.     if (!strcmp(wlk->String,lower)){
  989.       /*
  990.        *    Readjust the LRU.
  991.        */
  992.       if (owk){
  993.           owk->Next = wlk->Next;
  994.           wlk->Next = KeywordTable[hsh];
  995.           KeywordTable[hsh] = wlk;
  996.       }
  997.       return (wlk->String);
  998.     }
  999.   return (NULL);
  1000. }
  1001. /*
  1002.  *    Token hash table.
  1003.  */
  1004. #define    TOKEN_HASH    51
  1005. static Token *TokenHash[TOKEN_HASH];
  1006. /*
  1007.  *    Find token:
  1008.  *
  1009.  *      A pointer to the token of the passed code is returned. If
  1010.  *    no such beastie is present a NULL is returned instead.
  1011.  */
  1012. static Token *FindToken(cod)
  1013. register int cod;
  1014. {
  1015.   /*
  1016.    *    Locals.
  1017.    */
  1018.   register Token *wlk,*owk;
  1019.   register unsigned int hsh;
  1020.   /*
  1021.    *    Search the hash table for a matching token.
  1022.    */
  1023.   hsh = cod % TOKEN_HASH;
  1024.   for (owk = NULL, wlk = TokenHash[hsh]; wlk; wlk = (owk = wlk)->Next)
  1025.     if (cod == wlk->Code){
  1026.       if (owk){
  1027.           owk->Next = wlk->Next;
  1028.           wlk->Next = TokenHash[hsh];
  1029.           TokenHash[hsh] = wlk;
  1030.       }
  1031.       break;
  1032.     }
  1033.   return (wlk);
  1034. }
  1035. /*
  1036.  *    Context hash table.
  1037.  */
  1038. #define    CONTEXT_HASH    127
  1039. static Context *ContextHash[CONTEXT_HASH];
  1040. /*
  1041.  *    Find context:
  1042.  *
  1043.  *      A pointer to the context of the passed code is returned. If
  1044.  *    no such beastie is present a NULL is returned instead.
  1045.  */
  1046. static Context *FindContext(cod)
  1047. register int cod;
  1048. {
  1049.   /*
  1050.    *    Locals.
  1051.    */
  1052.   register Context *wlk,*owk;
  1053.   register unsigned int hsh;
  1054.   /*
  1055.    *    Search the hash table for a matching context.
  1056.    */
  1057.   hsh = cod % CONTEXT_HASH;
  1058.   for (owk = NULL, wlk = ContextHash[hsh]; wlk; wlk = (owk = wlk)->Next)
  1059.     if (cod == wlk->Code){
  1060.       if (owk){
  1061.           owk->Next = wlk->Next;
  1062.           wlk->Next = ContextHash[hsh];
  1063.           ContextHash[hsh] = wlk;
  1064.       }
  1065.       break;
  1066.     }
  1067.   return (wlk);
  1068. }
  1069. /*
  1070.  *    Token stacking variables.
  1071.  */
  1072. #ifdef    DEBUG
  1073. #define    TS_DEPTH    8
  1074. #define    TS_MASK        (TS_DEPTH - 1)
  1075. static unsigned int TSP = 0;        /* token stack pointer */
  1076. static char *TokenStack[TS_DEPTH];    /* token name strings */
  1077. static short TokenType[TS_DEPTH];    /* token types */
  1078. /*
  1079.  *    Stack:
  1080.  *
  1081.  *      Add a token to the debug stack. The passed string and type are
  1082.  *    what is to be pushed.
  1083.  */
  1084. static Stack(str,typ)
  1085. char *str;
  1086. int typ;
  1087. {
  1088.   /*
  1089.    *    Free any previous string, then push.
  1090.    */
  1091.   if (TokenStack[TSP & TS_MASK])
  1092.     Free(TokenStack[TSP & TS_MASK]);
  1093.   TokenStack[TSP & TS_MASK] = strcpy(Malloc(strlen(str) + 1),str);
  1094.   TokenType[TSP & TS_MASK] = typ;
  1095.   TSP += 1;
  1096. }
  1097. /*
  1098.  *    Dump stack:
  1099.  *
  1100.  *      This displays the last set of accumulated tokens.
  1101.  */
  1102. static DumpStack()
  1103. {
  1104.   /*
  1105.    *    Locals.
  1106.    */
  1107.   register int i;
  1108.   register Context *cxt;
  1109.   register Token *tok;
  1110.   register char *nam;
  1111.   /*
  1112.    *    Run through the list displaying the oldest first.
  1113.    */
  1114.   fprintf(Error,"\n\n");
  1115.   for (i = 0; i < TS_DEPTH; i += 1)
  1116.     if (TokenStack[(TSP + i) & TS_MASK]){
  1117.       /*
  1118.        *    Get the type name string.
  1119.        */
  1120.       if (cxt = FindContext(TokenType[(TSP + i) & TS_MASK]))
  1121.         nam = cxt->Name;
  1122.       else if (tok = FindToken(TokenType[(TSP + i) & TS_MASK]))
  1123.         nam = tok->Name;
  1124.       else switch (TokenType[(TSP + i) & TS_MASK]){
  1125.           case IDENT:    nam = "IDENT";        break;
  1126.           case INT:    nam = "INT";        break;
  1127.           case KEYWORD:    nam = "KEYWORD";    break;
  1128.           case STR:    nam = "STR";        break;
  1129.           default:    nam = "?";        break;
  1130.       }
  1131.       /*
  1132.        *    Now print the token state.
  1133.        */
  1134.       fprintf(Error,"%2d %-16.16s '%s'\n",TS_DEPTH - i,nam,
  1135.         TokenStack[(TSP + i) & TS_MASK]);
  1136.     }
  1137.   fprintf(Error,"\n");
  1138. }
  1139. #else
  1140. #define    Stack(s,t)
  1141. #endif    DEBUG
  1142. /*
  1143.  *    yyerror:
  1144.  *
  1145.  *      Standard error reporter, it prints out the passed string
  1146.  *    preceeded by the current filename and line number.
  1147.  */
  1148. static yyerror(ers)
  1149. char *ers;
  1150. {
  1151. #ifdef    DEBUG
  1152.   DumpStack();
  1153. #endif    DEBUG
  1154.   fprintf(Error,"%s, line %d: %s\n",InFile,LineNumber,ers);
  1155. }
  1156. /*
  1157.  *    String bucket definitions.
  1158.  */
  1159. #define    BUCKET_SIZE    64
  1160. typedef struct Bucket {
  1161.   struct Bucket *Next;            /* pointer to next bucket */
  1162.   int Index;                /* pointer to next free slot */
  1163.   char Data[BUCKET_SIZE];        /* string data */
  1164. } Bucket;
  1165. static Bucket *CurrentBucket = NULL;    /* string bucket list */
  1166. static int StringSize = 0;        /* current string length */
  1167. /*
  1168.  *    Push string:
  1169.  *
  1170.  *      This adds the passed charater to the current string bucket.
  1171.  */
  1172. static PushString(chr)
  1173. char chr;
  1174. {
  1175.   /*
  1176.    *    Locals.
  1177.    */
  1178.   register Bucket *bck;
  1179.   /*
  1180.    *    Make sure there is room for the push.
  1181.    */
  1182.   if ((bck = CurrentBucket)->Index >= BUCKET_SIZE){
  1183.     bck = (Bucket *) Malloc(sizeof(Bucket));
  1184.     bck->Next = CurrentBucket;
  1185.     (CurrentBucket = bck)->Index = 0;
  1186.   }
  1187.   /*
  1188.    *    Push the character.
  1189.    */
  1190.   bck->Data[bck->Index++] = chr;
  1191.   StringSize += 1;
  1192. }
  1193. /*
  1194.  *    Form string:
  1195.  *
  1196.  *      This converts the current string bucket into a real live string,
  1197.  *    whose pointer is returned.
  1198.  */
  1199. static char *FormString()
  1200. {
  1201.   /*
  1202.    *    Locals.
  1203.    */
  1204.   register Bucket *bck;
  1205.   register char *cp;
  1206.   /*
  1207.    *    Allocate space for the string, set the pointer at the end.
  1208.    */
  1209.   cp = (char *) Malloc(StringSize + 1);
  1210.   cp += StringSize;
  1211.   *cp-- = '\0';
  1212.   /*
  1213.    *    Yank characters out of the bucket.
  1214.    */
  1215.   for (bck = CurrentBucket; bck->Index || bck->Next;){
  1216.     if (!bck->Index){
  1217.       CurrentBucket = bck->Next;
  1218.       Free(bck);
  1219.       bck = CurrentBucket;
  1220.     }
  1221.     *cp-- = bck->Data[--bck->Index];
  1222.   }
  1223.   return (cp + 1);
  1224. }
  1225. /*
  1226.  *    Parse EDIF:
  1227.  *
  1228.  *      This builds the context tree and then calls the real parser.
  1229.  *    It is passed two file streams, the first is where the input comes
  1230.  *    from; the second is where error messages get printed.
  1231.  */
  1232. ParseEDIF(inp,err)
  1233. FILE *inp,*err;
  1234. {
  1235.   /*
  1236.    *    Locals.
  1237.    */
  1238.   register int i;
  1239.   static int ContextDefined = 1;
  1240.   /*
  1241.    *    Set up the file state to something useful.
  1242.    */
  1243.   Input = inp;
  1244.   Error = err;
  1245.   LineNumber = 1;
  1246.   /*
  1247.    *    Define both the enabled token and context strings.
  1248.    */
  1249.   if (ContextDefined){
  1250.     for (i = TokenDefSize; i--; EnterKeyword(TokenDef[i].Name)){
  1251.       register unsigned int hsh;
  1252.       hsh = TokenDef[i].Code % TOKEN_HASH;
  1253.       TokenDef[i].Next = TokenHash[hsh];
  1254.       TokenHash[hsh] = &TokenDef[i];
  1255.     }
  1256.     for (i = ContextDefSize; i--; EnterKeyword(ContextDef[i].Name)){
  1257.       register unsigned int hsh;
  1258.       hsh = ContextDef[i].Code % CONTEXT_HASH;
  1259.       ContextDef[i].Next = ContextHash[hsh];
  1260.       ContextHash[hsh] = &ContextDef[i];
  1261.     }
  1262.     /*
  1263.      *    Build the context tree.
  1264.      */
  1265.     for (i = BinderDefSize; i--;){
  1266.       register Context *cxt;
  1267.       register int j;
  1268.       /*
  1269.        *    Define the current context to have carriers bound to it.
  1270.        */
  1271.       cxt = FindContext(BinderDef[i].Origin);
  1272.       for (j = BinderDef[i].FollowerSize; j--;){
  1273.         register ContextCar *cc;
  1274.         /*
  1275.          *    Add carriers to the current context.
  1276.          */
  1277.         cc = (ContextCar *) Malloc(sizeof(ContextCar));
  1278.         cc->Next = cxt->Context;
  1279.         (cxt->Context = cc)->Context =
  1280.           FindContext(ABS(BinderDef[i].Follower[j]));
  1281.         cc->u.Single = BinderDef[i].Follower[j] < 0;
  1282.       }
  1283.     }
  1284.     /*
  1285.      *    Build the token tree.
  1286.      */
  1287.     for (i = TieDefSize; i--;){
  1288.       register Context *cxt;
  1289.       register int j;
  1290.       /*
  1291.        *    Define the current context to have carriers bound to it.
  1292.        */
  1293.       cxt = FindContext(TieDef[i].Origin);
  1294.       for (j = TieDef[i].EnableSize; j--;){
  1295.         register TokenCar *tc;
  1296.         /*
  1297.          *    Add carriers to the current context.
  1298.          */
  1299.         tc = (TokenCar *) Malloc(sizeof(TokenCar));
  1300.         tc->Next = cxt->Token;
  1301.         (cxt->Token = tc)->Token = FindToken(TieDef[i].Enable[j]);
  1302.       }
  1303.     }
  1304.     /*
  1305.      *    Put a bogus context on the stack which has 'EDIF' as its
  1306.      *    follower.
  1307.      */
  1308.     CSP = (ContextCar *) Malloc(sizeof(ContextCar));
  1309.     CSP->Next = NULL;
  1310.     CSP->Context = FindContext(NULL);
  1311.     CSP->u.Used = NULL;
  1312.     ContextDefined = 0;
  1313.   }
  1314.   /*
  1315.    *    Create an initial, empty string bucket.
  1316.    */
  1317.   CurrentBucket = (Bucket *) Malloc(sizeof(Bucket));
  1318.   CurrentBucket->Next = 0;
  1319.   CurrentBucket->Index = 0;
  1320.   /*
  1321.    *    Fill the token stack with NULLs if debugging is enabled.
  1322.    */
  1323. #ifdef    DEBUG
  1324.   for (i = TS_DEPTH; i--; TokenStack[i] = NULL)
  1325.     if (TokenStack[i])
  1326.       Free(TokenStack[i]);
  1327.   TSP = 0;
  1328. #endif    DEBUG
  1329.   /*
  1330.    *    Go parse things!
  1331.    */
  1332.   yyparse();
  1333. }
  1334. /*
  1335.  *    Match token:
  1336.  *
  1337.  *      The passed string is looked up in the current context's token
  1338.  *    list to see if it is enabled. If so the token value is returned,
  1339.  *    if not then zero.
  1340.  */
  1341. static int MatchToken(str)
  1342. register char *str;
  1343. {
  1344.   /*
  1345.    *    Locals.
  1346.    */
  1347.   register TokenCar *wlk,*owk;
  1348.   /*
  1349.    *    Convert the string to the proper form, then search the token
  1350.    *    carrier list for a match.
  1351.    */
  1352.   str = FindKeyword(str);
  1353.   for (owk = NULL, wlk = CSP->Context->Token; wlk; wlk = (owk = wlk)->Next)
  1354.     if (str == wlk->Token->Name){
  1355.       if (owk){
  1356.         owk->Next = wlk->Next;
  1357.         wlk->Next = CSP->Context->Token;
  1358.         CSP->Context->Token = wlk;
  1359.       }
  1360.       return (wlk->Token->Code);
  1361.     }
  1362.   return (0);
  1363. }
  1364. /*
  1365.  *    Match context:
  1366.  *
  1367.  *      If the passed keyword string is within the current context, the
  1368.  *    new context is pushed and token value is returned. A zero otherwise.
  1369.  */
  1370. static int MatchContext(str)
  1371. register char *str;
  1372. {
  1373.   /*
  1374.    *    Locals.
  1375.    */
  1376.   register ContextCar *wlk,*owk;
  1377.   /*
  1378.    *    See if the context is present.
  1379.    */
  1380.   str = FindKeyword(str);
  1381.   for (owk = NULL, wlk = CSP->Context->Context; wlk; wlk = (owk = wlk)->Next)
  1382.     if (str == wlk->Context->Name){
  1383.       if (owk){
  1384.           owk->Next = wlk->Next;
  1385.           wlk->Next = CSP->Context->Context;
  1386.           CSP->Context->Context = wlk;
  1387.       }
  1388.       /*
  1389.        *    If a single context, make sure it isn't already used.
  1390.        */
  1391.       if (wlk->u.Single){
  1392.           register UsedCar *usc;
  1393.           for (usc = CSP->u.Used; usc; usc = usc->Next)
  1394.             if (usc->Code == wlk->Context->Code)
  1395.               break;
  1396.           if (usc){
  1397.             sprintf(CharBuf,"'%s' is used more than once within '%s'",
  1398.               str,CSP->Context->Name);
  1399.             yyerror(CharBuf);
  1400.           } else {
  1401.             usc = (UsedCar *) Malloc(sizeof(UsedCar));
  1402.             usc->Next = CSP->u.Used;
  1403.             (CSP->u.Used = usc)->Code = wlk->Context->Code;
  1404.           }
  1405.       }
  1406.       /*
  1407.        *    Push the new context.
  1408.        */
  1409.       owk = (ContextCar *) Malloc(sizeof(ContextCar));
  1410.       owk->Next = CSP;
  1411.       (CSP = owk)->Context = wlk->Context;
  1412.       owk->u.Used = NULL;
  1413.       return (wlk->Context->Code);
  1414.     }
  1415.   return (0);
  1416. }
  1417. /*
  1418.  *    PopC:
  1419.  *
  1420.  *      This pops the current context.
  1421.  */
  1422. static PopC()
  1423. {
  1424.   /*
  1425.    *    Locals.
  1426.    */
  1427.   register UsedCar *usc;
  1428.   register ContextCar *csp;
  1429.   /*
  1430.    *    Release single markers and pop context.
  1431.    */
  1432.   while (usc = CSP->u.Used){
  1433.     CSP->u.Used = usc->Next;
  1434.     Free(usc);
  1435.   }
  1436.   csp = CSP->Next;
  1437.   Free(CSP);
  1438.   CSP = csp;
  1439. }
  1440. /*
  1441.  *    Lexical analyzer states.
  1442.  */
  1443. #define    L_START        0
  1444. #define    L_INT        1
  1445. #define    L_IDENT        2
  1446. #define    L_KEYWORD    3
  1447. #define    L_STRING    4
  1448. #define    L_KEYWORD2    5
  1449. #define    L_ASCIICHAR    6
  1450. #define    L_ASCIICHAR2    7
  1451. /*
  1452.  *    yylex:
  1453.  *
  1454.  *      This is the lexical analyzer called by the YACC/BISON parser.
  1455.  *    It returns a pretty restricted set of token types and does the
  1456.  *    context movement when acceptable keywords are found. The token
  1457.  *    value returned is a NULL terminated string to allocated storage
  1458.  *    (ie - it should get released some time) with some restrictions.
  1459.  *      The token value for integers is strips a leading '+' if present.
  1460.  *    String token values have the leading and trailing '"'-s stripped.
  1461.  *    '%' conversion characters in string values are passed converted.
  1462.  *    The '(' and ')' characters do not have a token value.
  1463.  */
  1464. static int yylex()
  1465. {
  1466.   /*
  1467.    *    Locals.
  1468.    */
  1469.   register int c,s,l;
  1470.   /*
  1471.    *    Keep on sucking up characters until we find something which
  1472.    *    explicitly forces us out of this function.
  1473.    */
  1474.   for (s = L_START, l = 0; 1;){
  1475.     yytext[l++] = c = Getc(Input);
  1476.     switch (s){
  1477.       /*
  1478.        *    Starting state, look for something resembling a token.
  1479.        */
  1480.       case L_START:
  1481.         if (isdigit(c) || c == '-')
  1482.           s = L_INT;
  1483.         else if (isalpha(c) || c == '&')
  1484.           s = L_IDENT;
  1485.         else if (isspace(c)){
  1486.           if (c == '\n')
  1487.             LineNumber += 1;
  1488.           l = 0;
  1489.         } else if (c == '('){
  1490.           l = 0;
  1491.           s = L_KEYWORD;
  1492.         } else if (c == '"')
  1493.           s = L_STRING;
  1494.         else if (c == '+'){
  1495.           l = 0;                /* strip '+' */
  1496.           s = L_INT;
  1497.         } else if (c == EOF)
  1498.           return ('\0');
  1499.         else {
  1500.           yytext[1] = '\0';
  1501.           Stack(yytext,c);
  1502.           return (c);
  1503.         }
  1504.         break;
  1505.       /*
  1506.        *    Suck up the integer digits.
  1507.        */
  1508.       case L_INT:
  1509.         if (isdigit(c))
  1510.           break;
  1511.         Ungetc(c);
  1512.         yytext[--l] = '\0';
  1513.         yylval.s = strcpy(Malloc(l + 1),yytext);
  1514.         Stack(yytext,INT);
  1515.         return (INT);
  1516.       /*
  1517.        *    Grab an identifier, see if the current context enables
  1518.        *    it with a specific token value.
  1519.        */
  1520.       case L_IDENT:
  1521.         if (isalpha(c) || isdigit(c) || c == '_')
  1522.           break;
  1523.         Ungetc(c);
  1524.         yytext[--l] = '\0';
  1525.         if (CSP->Context->Token && (c = MatchToken(yytext))){
  1526.           Stack(yytext,c);
  1527.           return (c);
  1528.         }
  1529.         yylval.s = strcpy(Malloc(l + 1),yytext);
  1530.         Stack(yytext,IDENT);
  1531.         return (IDENT);
  1532.       /*
  1533.        *    Scan until you find the start of an identifier, discard
  1534.        *    any whitespace found. On no identifier, return a '('.
  1535.        */
  1536.       case L_KEYWORD:
  1537.         if (isalpha(c) || c == '&'){
  1538.           s = L_KEYWORD2;
  1539.           break;
  1540.         } else if (isspace(c)){
  1541.           l = 0;
  1542.           break;
  1543.         }
  1544.         Ungetc(c);
  1545.         Stack("(",'(');
  1546.         return ('(');
  1547.       /*
  1548.        *    Suck up the keyword identifier, if it matches the set of
  1549.        *    allowable contexts then return its token value and push
  1550.        *    the context, otherwise just return the identifier string.
  1551.        */
  1552.       case L_KEYWORD2:
  1553.         if (isalpha(c) || isdigit(c) || c == '_')
  1554.           break;
  1555.         Ungetc(c);
  1556.         yytext[--l] = '\0';
  1557.         if (c = MatchContext(yytext)){
  1558.           Stack(yytext,c);
  1559.           return (c);
  1560.         }
  1561.         yylval.s = strcpy(Malloc(l + 1),yytext);
  1562.         Stack(yytext,KEYWORD);
  1563.         return (KEYWORD);
  1564.       /*
  1565.        *    Suck up string characters but once resolved they should
  1566.        *    be deposited in the string bucket because they can be
  1567.        *    arbitrarily long.
  1568.        */
  1569.       case L_STRING:
  1570.         if (c == '\n')
  1571.           LineNumber += 1;
  1572.         else if (c == '\r')
  1573.           ;
  1574.         else if (c == '"' || c == EOF){
  1575.           yylval.s = FormString();
  1576.           Stack(yylval.s,STR);
  1577.           return (STR);
  1578.         } else if (c == '%')
  1579.           s = L_ASCIICHAR;
  1580.         else
  1581.           PushString(c);
  1582.         l = 0;
  1583.         break;
  1584.       /*
  1585.        *    Skip white space and look for integers to be pushed
  1586.        *    as characters.
  1587.        */
  1588.       case L_ASCIICHAR:
  1589.         if (isdigit(c)){
  1590.           s = L_ASCIICHAR2;
  1591.           break;
  1592.         } else if (c == '%' || c == EOF)
  1593.           s = L_STRING;
  1594.         else if (c == '\n')
  1595.           LineNumber += 1;
  1596.         l = 0;
  1597.         break;
  1598.       /*
  1599.        *    Convert the accumulated integer into a char and push.
  1600.        */
  1601.       case L_ASCIICHAR2:
  1602.         if (isdigit(c))
  1603.           break;
  1604.         Ungetc(c);
  1605.         yytext[--l] = '\0';
  1606.         PushString(atoi(yytext));
  1607.         s = L_ASCIICHAR;
  1608.         l = 0;
  1609.         break;
  1610.     }
  1611.   }
  1612. }
  1613.