

/*  A Bison parser, made from hdl.y
 by  GNU Bison version 1.25
  */

#define YYBISON 1 /* Identify Bison output.  */

#define NL 258
#define NAME 259
#define NUMBER 260
#define MODULE 261
#define ENDMODULE 262
#define WIRE 263
#define INPUT 264
#define OUTPUT 265
#define INOUT 266
#define NETTYPE 267
#define ASSIGN 268
#define STRENGTH0 269
#define STRENGTH1 270
#define GATETYPE 271
#define INITIAL 272
#define PARAMETER 273
#define REG 274
#define TIME 275
#define INTEGER 276
#define REAL 277
#define EVENT 278
#define DEFPARAM 279
#define BIN_OP 280
#define UNARY_OP 281
#define PRIMITIVE 282
#define ENDPRIM 283
#define TABLE 284
#define ENDTABLE 285
#define OUT_SYM 286
#define LEV_SYM 287
#define EDGE_SYM 288

#line 26 "hdl.y"

#define YYDEBUG 1
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>

#define out(c) putc (c, yyout)
#define NCOM 300

int bug = 0, ind;
FILE *fopen (), *freopen (), *fi, *ft, *fo, *fr;
static int i, comment = 0;
char *cp, *st, refd[20], part[20];
char ln[80];

extern char *strsave (), *malloc ();
extern int yyleng, lexval;
extern char yytext[];
extern char yysbuf[];

typedef struct YYS_TYPE
{ /* use instead of %union below */
        int i;
        char s[50];
} yys_type;
#define YYSTYPE yys_type

#define YYLMAX 132

int yylineno = 0;
int yyleng;
char yytext[YYLMAX];
char yysbuf[YYLMAX];
char modnam[YYLMAX];
int yysptr = -1, yylast, toklast;
FILE *yyout;
#define YYNL 10

#ifndef YYSTYPE
#define YYSTYPE int
#endif
#ifndef YYDEBUG
#define YYDEBUG 1
#endif

#include <stdio.h>

#ifndef __cplusplus
#ifndef __STDC__
#define const
#endif
#endif

#define YYFINAL 270
#define YYFLAG -32768
#define YYNTBASE 53

#define YYTRANSLATE(x) ((unsigned) (x) <= 288 ? yytranslate[x] : 112)

static const char yytranslate[] = {
    0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  47, 2,  2,  2,  40, 34, 35, 2,  2,  37, 2,
    48, 2,  42, 39, 2,  2,  2,  2,  2,  2,  2,  2,  44, 36, 2,  38, 2,  2,  2,  2,  2,  2,  2,
    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  45,
    2,  46, 2,  2,  2,  2,  41, 2,  51, 2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  52, 2,  2,  2,
    2,  2,  2,  2,  2,  43, 2,  2,  49, 2,  50, 2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
    2,  2,  2,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
    21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33};

#if YYDEBUG != 0
static const short yyprhs[] = {
    0,   0,   3,   6,   8,   10,  12,  21,  25,  27,  31,  34,  36,  38,  40,  45,  50,
    55,  60,  62,  64,  68,  71,  73,  76,  78,  83,  90,  97,  99,  103, 105, 110, 112,
    114, 116, 122, 131, 135, 137, 139, 144, 151, 154, 156, 158, 160, 162, 164, 166, 168,
    170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 201, 205,
    209, 214, 219, 223, 228, 232, 237, 241, 246, 250, 255, 260, 266, 272, 275, 278, 284,
    290, 294, 296, 300, 305, 307, 311, 313, 318, 323, 325, 329, 331, 335, 337, 343, 345,
    350, 357, 359, 364, 368, 373, 378, 384, 388, 390, 394, 400, 402, 407, 409, 411, 415,
    419, 421, 423, 426, 431, 435, 437, 442, 444, 446, 448, 453, 458};

static const short yyrhs[] = {
    53,  54,  0,   53,  1,   0,   54,  0,   70,  0,  55,  0,   27,  4,   34,  56,  35,  36,
    57,  28,  0,   56,  37,  4,   0,   4,   0,   58, 59,  61,  0,   58,  61,  0,   85,  0,
    84,  0,   76,  0,   17,  4,   38,  60,  0,   39, 40,  41,  42,  0,   39,  40,  41,  39,
    0,   39,  40,  41,  43,  0,   39,  0,   42,  0,  29,  62,  30,  0,   62,  63,  0,   63,
    0,   62,  64,  0,   64,  0,   65,  44,  31,  36, 0,   65,  44,  68,  44,  69,  36,  0,
    66,  44,  68,  44,  69,  36,  0,   32,  0,   32, 67,  32,  0,   67,  0,   34,  32,  32,
    35,  0,   33,  0,   32,  0,   31,  0,   6,   4,  36,  73,  7,   0,   6,   4,   34,  71,
    35,  36,  73,  7,   0,   71,  37,  72,  0,   72, 0,   4,   0,   4,   45,  106, 46,  0,
    4,   45,  106, 44,  106, 46,  0,   73,  74,  0,  74,  0,   75,  0,   84,  0,   85,  0,
    86,  0,   87,  0,   76,  0,   77,  0,   78,  0,  79,  0,   80,  0,   82,  0,   92,  0,
    81,  0,   102, 0,   18,  0,   19,  0,   20,  0,  21,  0,   22,  0,   23,  0,   24,  0,
    16,  83,  0,   16,  90,  83,  0,   16,  89,  83, 0,   16,  90,  89,  83,  0,   4,   34,
    109, 35,  0,   9,   91,  36,  0,   9,   88,  91, 36,  0,   10,  91,  36,  0,   10,  88,
    91,  36,  0,   11,  91,  36,  0,   11,  88,  91, 36,  0,   12,  91,  36,  0,   12,  88,
    91,  36,  0,   12,  89,  91,  36,  0,   12,  88, 89,  91,  36,  0,   45,  106, 44,  106,
    46,  0,   47,  111, 0,   47,  4,   0,   34,  14, 37,  15,  35,  0,   34,  15,  37,  14,
    35,  0,   91,  37,  4,   0,   4,   0,   93,  94, 36,  0,   93,  101, 94,  36,  0,   4,
    0,   94,  37,  95,  0,   95,  0,   96,  34,  97, 35,  0,   96,  34,  98,  35,  0,   4,
    0,   97,  37,  109, 0,   109, 0,   98,  37,  99, 0,   99,  0,   48,  4,   34,  100, 35,
    0,   4,   0,   4,   45,  109, 46,  0,   4,   45, 109, 44,  109, 46,  0,   107, 0,   47,
    34,  109, 35,  0,   13,  103, 36,  0,   13,  90, 103, 36,  0,   13,  89,  103, 36,  0,
    13,  90,  89,  103, 36,  0,   103, 37,  104, 0,  104, 0,   105, 38,  109, 0,   105, 38,
    34,  109, 35,  0,   4,   0,   4,   45,  109, 46, 0,   107, 0,   109, 0,   49,  108, 50,
    0,   108, 37,  109, 0,   109, 0,   110, 0,   26, 110, 0,   26,  34,  109, 35,  0,   109,
    25,  109, 0,   111, 0,   4,   45,  109, 46,  0,  4,   0,   107, 0,   5,   0,   5,   40,
    41,  5,   0,   5,   40,  51,  5,   0,   5,   40, 52,  5,   0};

#endif

#if YYDEBUG != 0
static const short yyrline[] = {
    0,   87,  88,  89,  92,  93,  96,  99,  100, 103, 104, 107, 108, 109, 112, 115, 116,
    117, 118, 119, 122, 125, 126, 127, 128, 131, 134, 135, 138, 141, 142, 145, 146, 149,
    151, 154, 155, 158, 159, 162, 163, 164, 167, 168, 171, 172, 173, 174, 175, 176, 177,
    178, 179, 180, 181, 182, 183, 184, 187, 189, 191, 193, 195, 197, 199, 201, 202, 203,
    204, 207, 210, 211, 214, 215, 218, 219, 222, 223, 224, 225, 228, 231, 232, 235, 236,
    239, 240, 243, 244, 247, 251, 252, 255, 256, 259, 263, 264, 267, 268, 271, 278, 279,
    285, 293, 297, 300, 301, 302, 303, 306, 307, 310, 311, 314, 315, 316, 319, 322, 325,
    326, 329, 330, 331, 332, 335, 336, 337, 338, 341, 342, 343, 344};
#endif

#if YYDEBUG != 0 || defined(YYERROR_VERBOSE)

static const char *const yytname[] = {"$",
                                      "error",
                                      "$undefined.",
                                      "NL",
                                      "NAME",
                                      "NUMBER",
                                      "MODULE",
                                      "ENDMODULE",
                                      "WIRE",
                                      "INPUT",
                                      "OUTPUT",
                                      "INOUT",
                                      "NETTYPE",
                                      "ASSIGN",
                                      "STRENGTH0",
                                      "STRENGTH1",
                                      "GATETYPE",
                                      "INITIAL",
                                      "PARAMETER",
                                      "REG",
                                      "TIME",
                                      "INTEGER",
                                      "REAL",
                                      "EVENT",
                                      "DEFPARAM",
                                      "BIN_OP",
                                      "UNARY_OP",
                                      "PRIMITIVE",
                                      "ENDPRIM",
                                      "TABLE",
                                      "ENDTABLE",
                                      "OUT_SYM",
                                      "LEV_SYM",
                                      "EDGE_SYM",
                                      "'('",
                                      "')'",
                                      "';'",
                                      "','",
                                      "'='",
                                      "'1'",
                                      "'''",
                                      "'b'",
                                      "'0'",
                                      "'x'",
                                      "':'",
                                      "'['",
                                      "']'",
                                      "'#'",
                                      "'.'",
                                      "'{'",
                                      "'}'",
                                      "'d'",
                                      "'o'",
                                      "modules",
                                      "mod_prim",
                                      "primitive",
                                      "list_of_vars",
                                      "prim_body",
                                      "UDP_decl",
                                      "UDP_init",
                                      "init_val",
                                      "table_def",
                                      "table_entries",
                                      "combin_entry",
                                      "seq_entry",
                                      "level_in_list",
                                      "edge_in_list",
                                      "edge",
                                      "state",
                                      "next_state",
                                      "module",
                                      "list_of_ports",
                                      "port",
                                      "mod_body",
                                      "module_item",
                                      "param_decl",
                                      "reg_decl",
                                      "time_decl",
                                      "integer_decl",
                                      "real_decl",
                                      "event_decl",
                                      "defparm_decl",
                                      "gate_decl",
                                      "gate_instant",
                                      "input_decl",
                                      "output_decl",
                                      "inout_decl",
                                      "net_decl",
                                      "range",
                                      "delay",
                                      "dr_strength",
                                      "list_vars",
                                      "module_instant",
                                      "name_mod",
                                      "mod_inst_list",
                                      "mod_inst",
                                      "reference",
                                      "list_mod_conn",
                                      "list_nam_conn",
                                      "nam_conn",
                                      "sig_nam",
                                      "par_val",
                                      "cont_assign",
                                      "list_assigns",
                                      "assignment",
                                      "lvalue",
                                      "const_exp",
                                      "concatenation",
                                      "exp_list",
                                      "exp",
                                      "primary",
                                      "number",
                                      NULL};
#endif

static const short yyr1[] = {
    0,   53,  53,  53,  54,  54,  55,  56,  56,  57,  57,  58,  58,  58,  59,  60,  60,
    60,  60,  60,  61,  62,  62,  62,  62,  63,  64,  64,  65,  66,  66,  67,  67,  68,
    69,  70,  70,  71,  71,  72,  72,  72,  73,  73,  74,  74,  74,  74,  74,  74,  74,
    74,  74,  74,  74,  74,  74,  74,  75,  76,  77,  78,  79,  80,  81,  82,  82,  82,
    82,  83,  84,  84,  85,  85,  86,  86,  87,  87,  87,  87,  88,  89,  89,  90,  90,
    91,  91,  92,  92,  93,  94,  94,  95,  95,  96,  97,  97,  98,  98,  99,  100, 100,
    100, 100, 101, 102, 102, 102, 102, 103, 103, 104, 104, 105, 105, 105, 106, 107, 108,
    108, 109, 109, 109, 109, 110, 110, 110, 110, 111, 111, 111, 111};

static const short yyr2[] = {0, 2, 2, 1, 1, 1, 8, 3, 1, 3, 2, 1, 1, 1, 4, 4, 4, 4, 1, 1, 3, 2,
                             1, 2, 1, 4, 6, 6, 1, 3, 1, 4, 1, 1, 1, 5, 8, 3, 1, 1, 4, 6, 2, 1,
                             1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
                             3, 3, 4, 4, 3, 4, 3, 4, 3, 4, 3, 4, 4, 5, 5, 2, 2, 5, 5, 3, 1, 3,
                             4, 1, 3, 1, 4, 4, 1, 3, 1, 3, 1, 5, 1, 4, 6, 1, 4, 3, 4, 4, 5, 3,
                             1, 3, 5, 1, 4, 1, 1, 3, 3, 1, 1, 2, 4, 3, 1, 4, 1, 1, 1, 4, 4, 4};

static const short yydefact[] = {
    0,   0,  0,   0,   3,   5,   4,   0,  0,   2,  1,   0,   0,   0,   39,  0,   38,  89,  0,
    0,   0,  0,   0,   0,   58,  59,  60, 61,  62, 63,  64,  0,   43,  44,  49,  50,  51,  52,
    53,  56, 54,  45,  46,  47,  48,  55, 0,   57, 8,   0,   0,   0,   0,   86,  0,   0,   0,
    0,   0,  0,   0,   0,   0,   0,   0,  113, 0,  0,   0,   0,   0,   110, 0,   115, 0,   65,
    0,   0,  35,  42,  94,  0,   0,   91, 0,   0,  0,   0,   126, 128, 0,   0,   127, 116, 120,
    124, 0,  37,  0,   0,   70,  0,   0,  72,  0,  74,  82,  81,  0,   0,   0,   76,  0,   0,
    0,   0,  119, 0,   0,   0,   105, 0,  0,   0,  67,  66,  0,   0,   87,  0,   0,   0,   0,
    7,   0,  0,   0,   121, 0,   40,  0,  0,   0,  71,  85,  73,  75,  0,   77,  78,  0,   0,
    0,   0,  117, 107, 0,   106, 109, 0,  111, 0,  68,  0,   90,  0,   0,   0,   98,  96,  88,
    0,   0,  13,  12,  11,  0,   0,   0,  0,   0,  0,   123, 36,  0,   79,  114, 0,   0,   118,
    108, 0,  69,  104, 0,   92,  0,   93, 0,   6,  0,   0,   0,   10,  125, 129, 130, 131, 122,
    41,  80, 83,  84,  112, 0,   95,  97, 0,   28, 32,  0,   0,   22,  24,  0,   0,   30,  9,
    100, 0,  103, 0,   0,   0,   20,  21, 23,  0,  0,   0,   99,  18,  19,  14,  29,  0,   0,
    33,  0,  0,   0,   0,   31,  25,  0,  0,   0,  101, 0,   34,  0,   0,   0,   16,  15,  17,
    26,  27, 102, 0,   0};

static const short yydefgoto[] = {3,   4,   5,   49,  171, 172, 202, 243, 203, 221, 222, 223,
                                  224, 225, 226, 248, 260, 6,   15,  16,  31,  32,  33,  34,
                                  35,  36,  37,  38,  39,  40,  75,  41,  42,  43,  44,  55,
                                  63,  69,  56,  45,  46,  82,  83,  84,  166, 167, 168, 229,
                                  85,  47,  70,  71,  72,  91,  92,  115, 93,  94,  95};

static const short yypact[] = {
    -3,     39,     91,     92,     -32768, -32768, -32768, 107,    66,     -32768, -32768,
    109,    177,    113,    75,     118,    -32768, -32768, 83,     83,     83,     58,
    24,     76,     -32768, -32768, -32768, -32768, -32768, -32768, -32768, 126,    -32768,
    -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768,
    -32768, -32768, 37,     -32768, -32768, 127,    33,     104,    109,    -32768, 33,
    125,    -25,    125,    148,    125,    173,    207,    41,     125,    178,    116,
    202,    33,     21,     36,     182,    -32768, 94,     -32768, 139,    -32768, 187,
    77,     -32768, -32768, -32768, 179,    184,    -32768, 204,    243,    212,    245,
    206,    112,    30,     134,    -32768, 225,    -32768, -32768, 177,    -32768, 208,
    186,    -32768, 249,    188,    -32768, 190,    -32768, -32768, -32768, 125,    192,
    194,    -32768, 33,     217,    218,    57,     225,    196,    21,     198,    -32768,
    21,     18,     33,     -32768, -32768, 187,    33,     -32768, 243,    28,     200,
    99,     -32768, 33,     63,     33,     -32768, 33,     -32768, 33,     147,    33,
    -32768, -32768, -32768, -32768, 203,    -32768, -32768, -19,    241,    244,    33,
    -32768, -32768, 205,    -32768, -32768, 33,     225,    1,      -32768, 81,     -32768,
    253,    170,    171,    -32768, 225,    -32768, 231,    72,     -32768, -32768, -32768,
    -7,     255,    256,    257,    87,     219,    -32768, -32768, 220,    -32768, -32768,
    228,    229,    225,    -32768, 96,     -32768, -32768, 233,    -32768, 33,     -32768,
    221,    -32768, 264,    93,     242,    -32768, -32768, -32768, -32768, -32768, -32768,
    -32768, -32768, -32768, -32768, -32768, 26,     225,    -32768, 232,    210,    -32768,
    240,    142,    -32768, -32768, 230,    234,    -32768, -32768, 235,    238,    -32768,
    -35,    247,    250,    -32768, -32768, -32768, 214,    251,    33,     -32768, 236,
    -32768, -32768, -32768, 246,    239,    -32768, 248,    252,    -15,    254,    -32768,
    -32768, 258,    258,    33,     -32768, 140,    -32768, 261,    262,    -4,     -32768,
    -32768, -32768, -32768, -32768, -32768, 277,    -32768};

static const short yypgoto[] = {
    -32768, 281, -32768, -32768, -32768, -32768, -32768, -32768, 84,     -32768,
    64,     67,  -32768, -32768, 69,     52,     38,     -32768, -32768, 259,
    195,    -30, -32768, 162,    -32768, -32768, -32768, -32768, -32768, -32768,
    -60,    167, 168,    -32768, -32768, 183,    -14,    278,    -6,     -32768,
    -32768, 222, 174,    -32768, -32768, -32768, 106,    -32768, -32768, -32768,
    -49,    181, -32768, -52,    -22,    -32768, -62,    215,    260};

#define YYLAST 321

static const short yytable[] = {
    73,  79,  98,  1,   241, 116, 140, 242, 68,  76,  140, 100, 101, 58,  60,  64,  124, 125,
    140, 117, 119, 140, 88,  89,  2,   65,  140, 186, 65,  256, 228, 257, 88,  89,  88,  89,
    192, 88,  89,  204, 65,  80,  268, 7,   90,  53,  73,  73,  108, 99,  150, 102, 159, 104,
    90,  118, 109, 110, 66,  90,  160, 161, 53,  126, 136, 163, 162, 67,  169, 156, 67,  61,
    176, 67,  180, 67,  165, 67,  182, 67,  74,  74,  67,  61,  81,  67,  181, 53,  61,  200,
    184, 189, 269, 9,   153, 8,   73,  191, 1,   73,  13,  201, 147, 54,  177, 61,  140, 154,
    18,  19,  66,  79,  140, 14,  178, 179, 193, 48,  25,  2,   50,  140, 208, 61,  61,  218,
    219, 220, 54,  53,  17,  213, 122, 78,  215, 18,  19,  20,  21,  22,  96,  11,  23,  12,
    24,  25,  26,  27,  28,  29,  30,  17,  135, 51,  183, 52,  18,  19,  20,  21,  22,  112,
    86,  23,  87,  24,  25,  26,  27,  28,  29,  30,  234, 123, 218, 219, 220, 250, 138, 263,
    139, 17,  264, 265, 103, 101, 18,  19,  20,  21,  22,  74,  230, 23,  262, 24,  25,  26,
    27,  28,  29,  30,  57,  59,  62,  195, 197, 196, 198, 105, 101, 106, 89,  127, 111, 101,
    113, 114, 120, 121, 128, 129, 143, 101, 145, 101, 146, 101, 148, 101, 149, 101, 155, 121,
    157, 121, 170, 129, 130, 185, 101, 190, 121, 219, 220, 246, 247, 80,  132, 133, 140, 134,
    142, 144, 151, 152, 187, 194, 188, 199, 205, 206, 207, 211, 212, 209, 210, 214, 217, 165,
    231, 201, 233, 240, 237, 253, 251, 270, 238, 244, 239, 252, 245, 247, 10,  235, 227, 232,
    236, 259, 249, 141, 254, 261, 173, 258, 255, 266, 267, 174, 175, 77,  158, 164, 216, 137,
    0,   131, 0,   0,   0,   97,  0,   0,   0,   0,   0,   0,   0,   0,   0,   107};

static const short yycheck[] = {
    22,  31,  54,  6,   39, 67,  25,  42,  22,  23,  25, 36,  37,  19, 20,  21,  76,  77,
    25,  68,  69,  25,  4,  5,   27,  4,   25,  46,  4,  44,  4,   46, 4,   5,   4,   5,
    35,  4,   5,   46,  4,  4,   46,  4,   26,  4,   68, 69,  62,  55, 112, 57,  34,  59,
    26,  69,  62,  63,  34, 26,  122, 123, 4,   77,  34, 127, 126, 49, 130, 118, 49,  47,
    134, 49,  136, 49,  48, 49,  140, 49,  4,   4,   49, 47,  47,  49, 138, 4,   47,  17,
    142, 153, 0,   1,   37, 4,   118, 159, 6,   121, 34, 29,  108, 45, 41,  47,  25,  50,
    9,   10,  34,  141, 25, 4,   51,  52,  35,  4,   19, 27,  45,  25, 35,  47,  47,  32,
    33,  34,  45,  4,   4,  35,  38,  7,   196, 9,   10, 11,  12,  13, 36,  34,  16,  36,
    18,  19,  20,  21,  22, 23,  24,  4,   40,  35,  7,  37,  9,   10, 11,  12,  13,  45,
    35,  16,  37,  18,  19, 20,  21,  22,  23,  24,  30, 34,  32,  33, 34,  239, 44,  39,
    46,  4,   42,  43,  36, 37,  9,   10,  11,  12,  13, 4,   214, 16, 256, 18,  19,  20,
    21,  22,  23,  24,  19, 20,  21,  35,  35,  37,  37, 36,  37,  4,  5,   34,  36,  37,
    14,  15,  36,  37,  36, 37,  36,  37,  36,  37,  36, 37,  36,  37, 36,  37,  36,  37,
    36,  37,  36,  37,  34, 36,  37,  36,  37,  33,  34, 31,  32,  4,  36,  4,   25,  45,
    44,  4,   37,  37,  15, 4,   14,  28,  5,   5,   5,  35,  35,  46, 46,  34,  4,   48,
    38,  29,  32,  35,  44, 36,  40,  0,   44,  32,  45, 35,  32,  32, 3,   221, 202, 218,
    221, 31,  238, 96,  44, 255, 132, 41,  44,  36,  36, 132, 132, 23, 121, 129, 198, 90,
    -1,  85,  -1,  -1,  -1, 52,  -1,  -1,  -1,  -1,  -1, -1,  -1,  -1, -1,  61};
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "/usr/share/bison.simple"

/* Skeleton output parser for bison,
   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */

/* As a special exception, when this file is copied by Bison into a
   Bison output file, you may use that output file without restriction.
   This special exception was added by the Free Software Foundation
   in version 1.24 of Bison.  */

#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C.  */
#if (!defined(__STDC__) && defined(sparc)) || defined(__sparc__) || defined(__sparc) ||       \
    defined(__sgi)
#include <alloca.h>
#else /* not sparc */
#if defined(MSDOS) && !defined(__TURBOC__)
#include <malloc.h>
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
#pragma alloca
#else /* not MSDOS, __TURBOC__, or _AIX */
#ifdef __hpux
#ifdef __cplusplus
extern "C"
{
        void *alloca (unsigned int);
};
#else  /* not __cplusplus */
void *alloca ();
#endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc.  */
#endif /* not GNU C.  */
#endif /* alloca not defined.  */

/* This is the parser code that is written into each bison parser
  when the %semantic_parser declaration is not specified in the grammar.
  It was written by Richard Stallman by simplifying the hairy parser
  used when %semantic_parser is specified.  */

/* Note: there must be only one dollar sign in this file.
   It is replaced by the list of actions, each action
   as one case of the switch.  */

#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
#define YYACCEPT return (0)
#define YYABORT return (1)
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror.
   This remains here temporarily to ease the
   transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */
#define YYFAIL goto yyerrlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(token, value)                                                                \
        do                                                                                    \
                if (yychar == YYEMPTY && yylen == 1)                                          \
                {                                                                             \
                        yychar = (token), yylval = (value);                                   \
                        yychar1 = YYTRANSLATE (yychar);                                       \
                        YYPOPSTACK;                                                           \
                        goto yybackup;                                                        \
                }                                                                             \
                else                                                                          \
                {                                                                             \
                        yyerror ("syntax error: cannot back up");                             \
                        YYERROR;                                                              \
                }                                                                             \
        while (0)

#define YYTERROR 1
#define YYERRCODE 256

#ifndef YYPURE
#define YYLEX yylex ()
#endif

#ifdef YYPURE
#ifdef YYLSP_NEEDED
#ifdef YYLEX_PARAM
#define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
#else
#define YYLEX yylex (&yylval, &yylloc)
#endif
#else /* not YYLSP_NEEDED */
#ifdef YYLEX_PARAM
#define YYLEX yylex (&yylval, YYLEX_PARAM)
#else
#define YYLEX yylex (&yylval)
#endif
#endif /* not YYLSP_NEEDED */
#endif

/* If nonreentrant, generate the variables here */

#ifndef YYPURE

int yychar;     /*  the lookahead symbol		*/
YYSTYPE yylval; /*  the semantic value of the		*/
                /*  lookahead symbol			*/

#ifdef YYLSP_NEEDED
YYLTYPE yylloc; /*  location data for the lookahead	*/
                /*  symbol				*/
#endif

int yynerrs; /*  number of parse errors so far       */
#endif       /* not YYPURE */

#if YYDEBUG != 0
int yydebug; /*  nonzero means print parse trace	*/
/* Since this is uninitialized, it does not stop multiple parsers
   from coexisting.  */
#endif

/*  YYINITDEPTH indicates the initial size of the parser's stacks	*/

#ifndef YYINITDEPTH
#define YYINITDEPTH 200
#endif

/*  YYMAXDEPTH is the maximum size the stacks can grow to
    (effective only if the built-in stack extension method is used).  */

#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif

/* Prevent warning if -Wstrict-prototypes.  */
#ifdef __GNUC__
int yyparse (void);
#endif

#if __GNUC__ > 1 /* GNU C and GNU C++ define this.  */
#define __yy_memcpy(TO, FROM, COUNT) __builtin_memcpy (TO, FROM, COUNT)
#else /* not GNU C or C++ */
#ifndef __cplusplus

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void __yy_memcpy (to, from, count) char *to;
char *from;
int count;
{
        register char *f = from;
        register char *t = to;
        register int i = count;

        while (i-- > 0)
                *t++ = *f++;
}

#else /* __cplusplus */

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void __yy_memcpy (char *to, char *from, int count)
{
        register char *f = from;
        register char *t = to;
        register int i = count;

        while (i-- > 0)
                *t++ = *f++;
}

#endif
#endif

#line 196 "/usr/share/bison.simple"

/* The user can define YYPARSE_PARAM as the name of an argument to be passed
   into yyparse.  The argument should have type void *.
   It should actually point to an object.
   Grammar actions can access the variable by casting it
   to the proper pointer type.  */

#ifdef YYPARSE_PARAM
#ifdef __cplusplus
#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
#define YYPARSE_PARAM_DECL
#else /* not __cplusplus */
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
#endif /* not __cplusplus */
#else  /* not YYPARSE_PARAM */
#define YYPARSE_PARAM_ARG
#define YYPARSE_PARAM_DECL
#endif /* not YYPARSE_PARAM */

int yyparse (YYPARSE_PARAM_ARG) YYPARSE_PARAM_DECL
{
        register int yystate;
        register int yyn;
        register short *yyssp;
        register YYSTYPE *yyvsp;
        int yyerrstatus; /*  number of tokens to shift before error messages enabled */
        int yychar1 = 0; /*  lookahead token as an internal (translated) token number */

        short yyssa[YYINITDEPTH];   /*  the state stack			*/
        YYSTYPE yyvsa[YYINITDEPTH]; /*  the semantic value stack		*/

        short *yyss = yyssa;   /*  refer to the stacks thru separate pointers */
        YYSTYPE *yyvs = yyvsa; /*  to allow yyoverflow to reallocate them elsewhere */

#ifdef YYLSP_NEEDED
        YYLTYPE yylsa[YYINITDEPTH]; /*  the location stack			*/
        YYLTYPE *yyls = yylsa;
        YYLTYPE *yylsp;

#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
#else
#define YYPOPSTACK (yyvsp--, yyssp--)
#endif

        int yystacksize = YYINITDEPTH;

#ifdef YYPURE
        int yychar;
        YYSTYPE yylval;
        int yynerrs;
#ifdef YYLSP_NEEDED
        YYLTYPE yylloc;
#endif
#endif

        YYSTYPE yyval; /*  the variable used to return		*/
                       /*  semantic values from the action	*/
                       /*  routines				*/

        int yylen;

#if YYDEBUG != 0
        if (yydebug)
                fprintf (stderr, "Starting parse\n");
#endif

        yystate = 0;
        yyerrstatus = 0;
        yynerrs = 0;
        yychar = YYEMPTY; /* Cause a token to be read.  */

        /* Initialize stack pointers.
           Waste one element of value and location stack
           so that they stay on the same level as the state stack.
           The wasted elements are never initialized.  */

        yyssp = yyss - 1;
        yyvsp = yyvs;
#ifdef YYLSP_NEEDED
        yylsp = yyls;
#endif

/* Push a new state, which is found in  yystate  .  */
/* In all cases, when you get here, the value and location stacks
   have just been pushed. so pushing a state here evens the stacks.  */
yynewstate:

        *++yyssp = yystate;

        if (yyssp >= yyss + yystacksize - 1)
        {
                /* Give user a chance to reallocate the stack */
                /* Use copies of these so that the &'s don't force the real ones into memory.
                 */
                YYSTYPE *yyvs1 = yyvs;
                short *yyss1 = yyss;
#ifdef YYLSP_NEEDED
                YYLTYPE *yyls1 = yyls;
#endif

                /* Get the current used size of the three stacks, in elements.  */
                int size = yyssp - yyss + 1;

#ifdef yyoverflow
                /* Each stack pointer address is followed by the size of
                   the data in use in that stack, in bytes.  */
#ifdef YYLSP_NEEDED
                /* This used to be a conditional around just the two extra args,
                   but that might be undefined if yyoverflow is a macro.  */
                yyoverflow (
                    "parser stack overflow",
                    &yyss1,
                    size * sizeof (*yyssp),
                    &yyvs1,
                    size * sizeof (*yyvsp),
                    &yyls1,
                    size * sizeof (*yylsp),
                    &yystacksize);
#else
                yyoverflow (
                    "parser stack overflow",
                    &yyss1,
                    size * sizeof (*yyssp),
                    &yyvs1,
                    size * sizeof (*yyvsp),
                    &yystacksize);
#endif

                yyss = yyss1;
                yyvs = yyvs1;
#ifdef YYLSP_NEEDED
                yyls = yyls1;
#endif
#else /* no yyoverflow */
                /* Extend the stack our own way.  */
                if (yystacksize >= YYMAXDEPTH)
                {
                        yyerror ("parser stack overflow");
                        return 2;
                }
                yystacksize *= 2;
                if (yystacksize > YYMAXDEPTH)
                        yystacksize = YYMAXDEPTH;
                yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
                __yy_memcpy ((char *) yyss, (char *) yyss1, size * sizeof (*yyssp));
                yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
                __yy_memcpy ((char *) yyvs, (char *) yyvs1, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
                yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
                __yy_memcpy ((char *) yyls, (char *) yyls1, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */

                yyssp = yyss + size - 1;
                yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
                yylsp = yyls + size - 1;
#endif

#if YYDEBUG != 0
                if (yydebug)
                        fprintf (stderr, "Stack size increased to %d\n", yystacksize);
#endif

                if (yyssp >= yyss + yystacksize - 1)
                        YYABORT;
        }

#if YYDEBUG != 0
        if (yydebug)
                fprintf (stderr, "Entering state %d\n", yystate);
#endif

        goto yybackup;
yybackup:

        /* Do appropriate processing given the current state.  */
        /* Read a lookahead token if we need one and don't already have one.  */
        /* yyresume: */

        /* First try to decide what to do without reference to lookahead token.  */

        yyn = yypact[yystate];
        if (yyn == YYFLAG)
                goto yydefault;

        /* Not known => get a lookahead token if don't already have one.  */

        /* yychar is either YYEMPTY or YYEOF
           or a valid token in external form.  */

        if (yychar == YYEMPTY)
        {
#if YYDEBUG != 0
                if (yydebug)
                        fprintf (stderr, "Reading a token: ");
#endif
                yychar = YYLEX;
        }

        /* Convert token to internal form (in yychar1) for indexing tables with */

        if (yychar <= 0) /* This means end of input. */
        {
                yychar1 = 0;
                yychar = YYEOF; /* Don't call YYLEX any more */

#if YYDEBUG != 0
                if (yydebug)
                        fprintf (stderr, "Now at end of input.\n");
#endif
        }
        else
        {
                yychar1 = YYTRANSLATE (yychar);

#if YYDEBUG != 0
                if (yydebug)
                {
                        fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
                        /* Give the individual parser a way to print the precise meaning
                           of a token, for further debugging info.  */
#ifdef YYPRINT
                        YYPRINT (stderr, yychar, yylval);
#endif
                        fprintf (stderr, ")\n");
                }
#endif
        }

        yyn += yychar1;
        if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
                goto yydefault;

        yyn = yytable[yyn];

        /* yyn is what to do for this token type in this state.
           Negative => reduce, -yyn is rule number.
           Positive => shift, yyn is new state.
             New state is final state => don't bother to shift,
             just return success.
           0, or most negative number => error.  */

        if (yyn < 0)
        {
                if (yyn == YYFLAG)
                        goto yyerrlab;
                yyn = -yyn;
                goto yyreduce;
        }
        else if (yyn == 0)
                goto yyerrlab;

        if (yyn == YYFINAL)
                YYACCEPT;

                /* Shift the lookahead token.  */

#if YYDEBUG != 0
        if (yydebug)
                fprintf (stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
#endif

        /* Discard the token being shifted unless it is eof.  */
        if (yychar != YYEOF)
                yychar = YYEMPTY;

        *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
        *++yylsp = yylloc;
#endif

        /* count tokens shifted since error; after three, turn off error status.  */
        if (yyerrstatus)
                yyerrstatus--;

        yystate = yyn;
        goto yynewstate;

/* Do the default action for the current state.  */
yydefault:

        yyn = yydefact[yystate];
        if (yyn == 0)
                goto yyerrlab;

/* Do a reduction.  yyn is the number of a rule to reduce with.  */
yyreduce:
        yylen = yyr2[yyn];
        if (yylen > 0)
                yyval = yyvsp[1 - yylen]; /* implement default value of the action */

#if YYDEBUG != 0
        if (yydebug)
        {
                int i;

                fprintf (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]);

                /* Print the symbols being reduced, and their result.  */
                for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
                        fprintf (stderr, "%s ", yytname[yyrhs[i]]);
                fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
        }
#endif

        switch (yyn)
        {
        case 89:
#line 248 "hdl.y"
        {
                strcpy (part, yytext);
                ;
                break;
        }
        case 94:
#line 260 "hdl.y"
        {
                strcpy (refd, yytext);
                ;
                break;
        }
        case 99:
#line 272 "hdl.y"
        {
                fprintf (
                    fo,
                    "%-18s %-22s %-10s %10s %s\n",
                    yyvsp[-1].s,
                    refd,
                    yyvsp[-3].s,
                    part,
                    modnam);
                ;
                break;
        }
        case 101:
#line 280 "hdl.y"
        {
                strcpy (yyval.s, yyvsp[-3].s);
                strcat (yyval.s, "[");
                strcat (yyval.s, yyvsp[-1].s);
                strcat (yyval.s, "]");
                ;
                break;
        }
        case 102:
#line 286 "hdl.y"
        {
                strcpy (yyval.s, yyvsp[-5].s);
                strcat (yyval.s, "[");
                strcat (yyval.s, yyvsp[-3].s);
                strcat (yyval.s, ":");
                strcat (yyval.s, yyvsp[-1].s);
                strcat (yyval.s, "]");
                ;
                break;
        }
        case 103:
#line 294 "hdl.y"
        {
                strcpy (yyval.s, "concatenation");
                ;
                break;
        }
        }
        /* the action file gets copied in in place of this dollarsign */
#line 498 "/usr/share/bison.simple"

        yyvsp -= yylen;
        yyssp -= yylen;
#ifdef YYLSP_NEEDED
        yylsp -= yylen;
#endif

#if YYDEBUG != 0
        if (yydebug)
        {
                short *ssp1 = yyss - 1;
                fprintf (stderr, "state stack now");
                while (ssp1 != yyssp)
                        fprintf (stderr, " %d", *++ssp1);
                fprintf (stderr, "\n");
        }
#endif

        *++yyvsp = yyval;

#ifdef YYLSP_NEEDED
        yylsp++;
        if (yylen == 0)
        {
                yylsp->first_line = yylloc.first_line;
                yylsp->first_column = yylloc.first_column;
                yylsp->last_line = (yylsp - 1)->last_line;
                yylsp->last_column = (yylsp - 1)->last_column;
                yylsp->text = 0;
        }
        else
        {
                yylsp->last_line = (yylsp + yylen - 1)->last_line;
                yylsp->last_column = (yylsp + yylen - 1)->last_column;
        }
#endif

        /* Now "shift" the result of the reduction.
           Determine what state that goes to,
           based on the state we popped back to
           and the rule number reduced by.  */

        yyn = yyr1[yyn];

        yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
        if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
                yystate = yytable[yystate];
        else
                yystate = yydefgoto[yyn - YYNTBASE];

        goto yynewstate;

yyerrlab: /* here on detecting error */

        if (!yyerrstatus)
        /* If not already recovering from an error, report this error.  */
        {
                ++yynerrs;

#ifdef YYERROR_VERBOSE
                yyn = yypact[yystate];

                if (yyn > YYFLAG && yyn < YYLAST)
                {
                        int size = 0;
                        char *msg;
                        int x, count;

                        count = 0;
                        /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
                        for (x = (yyn < 0 ? -yyn : 0);
                             x < (sizeof (yytname) / sizeof (char *));
                             x++)
                                if (yycheck[x + yyn] == x)
                                        size += strlen (yytname[x]) + 15, count++;
                        msg = (char *) malloc (size + 15);
                        if (msg != 0)
                        {
                                strcpy (msg, "parse error");

                                if (count < 5)
                                {
                                        count = 0;
                                        for (x = (yyn < 0 ? -yyn : 0);
                                             x < (sizeof (yytname) / sizeof (char *));
                                             x++)
                                                if (yycheck[x + yyn] == x)
                                                {
                                                        strcat (
                                                            msg,
                                                            count == 0 ? ", expecting `"
                                                                       : " or `");
                                                        strcat (msg, yytname[x]);
                                                        strcat (msg, "'");
                                                        count++;
                                                }
                                }
                                yyerror (msg);
                                free (msg);
                        }
                        else
                                yyerror ("parse error; also virtual memory exceeded");
                }
                else
#endif /* YYERROR_VERBOSE */
                        yyerror ("parse error");
        }

        goto yyerrlab1;
yyerrlab1: /* here on error raised explicitly by an action */

        if (yyerrstatus == 3)
        {
                /* if just tried and failed to reuse lookahead token after an error, discard
                 * it.  */

                /* return failure if at end of input */
                if (yychar == YYEOF)
                        YYABORT;

#if YYDEBUG != 0
                if (yydebug)
                        fprintf (
                            stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif

                yychar = YYEMPTY;
        }

        /* Else will try to reuse lookahead token
           after shifting the error token.  */

        yyerrstatus = 3; /* Each real token shifted decrements this */

        goto yyerrhandle;

yyerrdefault: /* current state does not do anything special for the error token. */

#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */
  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  if (yyn) goto yydefault;
#endif

yyerrpop: /* pop the current state because it cannot handle the error token */

        if (yyssp == yyss)
                YYABORT;
        yyvsp--;
        yystate = *--yyssp;
#ifdef YYLSP_NEEDED
        yylsp--;
#endif

#if YYDEBUG != 0
        if (yydebug)
        {
                short *ssp1 = yyss - 1;
                fprintf (stderr, "Error: state stack now");
                while (ssp1 != yyssp)
                        fprintf (stderr, " %d", *++ssp1);
                fprintf (stderr, "\n");
        }
#endif

yyerrhandle:

        yyn = yypact[yystate];
        if (yyn == YYFLAG)
                goto yyerrdefault;

        yyn += YYTERROR;
        if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
                goto yyerrdefault;

        yyn = yytable[yyn];
        if (yyn < 0)
        {
                if (yyn == YYFLAG)
                        goto yyerrpop;
                yyn = -yyn;
                goto yyreduce;
        }
        else if (yyn == 0)
                goto yyerrpop;

        if (yyn == YYFINAL)
                YYACCEPT;

#if YYDEBUG != 0
        if (yydebug)
                fprintf (stderr, "Shifting error token, ");
#endif

        *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
        *++yylsp = yylloc;
#endif

        yystate = yyn;
        goto yynewstate;
}
#line 347 "hdl.y"
/* start of main */

main (argc, argv) int argc;
char *argv[];
{
        int i, p;
        char frnam[60], fsnam[60];
        yyout = stderr;

        if (argc == 1)
        {
                fprintf (stderr, "use:hdl [-ds] file\n");
                exit (1);
        }
        for (i = 1; i < argc; i++)
                if (argv[i][0] == '-')
                {
                        bug = ((argv[i][1] == 'd') || (argv[i][2] == 'd'));
                }
                else
                        break;

        if (freopen (argv[i], "r", stdin) == NULL)
        {
                fprintf (stderr, "can't open %s\n", argv[i]);
                exit (1);
        }
        else
        {
                /* open output */
                for (cp = argv[i], st = fsnam; *cp && *cp != '.';)
                        *st++ = *cp++;
                *st = 0;
                strcpy (frnam, fsnam);
                strcat (frnam, ".nam");
                strcat (fsnam, ".seq");

                if ((fo = fopen (fsnam, "w")) == NULL)
                        err ("can't open %s", fsnam);

                fprintf (stderr, "reading nets from %s\n", argv[i]);
        }

        yyparse ();

        fclose (fo);

        fprintf (stderr, "sorting...\n");
        sprintf (ln, "sort <%s >%s", fsnam, frnam);
        system (ln);
}

int yylex () /* Gets the next token from the input stream */
{
        int c, i, j;
        static int eline;
        extern int bug;

start:
        if (yysptr == -1)
        {
                i = 0;
                eline = 1;
                yylineno++;
                /* get line to yysbuf */
                while (((c = getchar ()) != EOF) && (c != YYNL))
                {
                        if (c == '\t')
                        {
                                c = ' ';
                                do
                                        yysbuf[i++] = c;
                                while (i & 7);
                        }
                        else
                        {
                                if (c != ' ')
                                        eline = 0;
                                yysbuf[i++] = c;
                        }
                }
                yysptr = 0;
                yysbuf[i] = '\0';
                yylast = toklast = 0;
        }
        if (c == EOF)
                return (EOF);

        while ((c = yysbuf[yysptr]) == ' ')
                yysptr++;

        if (bug)
        {
                fprintf (yyout, "%03d:%s\n", yylineno, yysbuf);
                for (i = yysptr; i > 0; i--)
                        out (' ');
        }

        if (c == YYNL || c == 0)
        {
                yysptr = -1;
                if (bug)
                        fprintf (yyout, "\n");
                goto start;
        }

        if (comment)
        {
                while ((c = yysbuf[yysptr++]) != '*' && c != '/' && c)
                        ;
                if (c == '*' && yysbuf[yysptr] == '/')
                        comment--;
                if (c == '/' && yysbuf[yysptr] == '*')
                        comment++;
                if (c == 0)
                        yysptr = -1;
                if (comment)
                        goto start;
                yysptr++;
                goto start;
        }

        if (c == '/')
        { /* comment // ? */
                if (yysbuf[yysptr + 1] == '/')
                {
                        yysptr = -1;
                        goto start;
                }
                if (yysbuf[yysptr + 1] == '*')
                {
                        comment++;
                        yysptr += 2;
                        goto start;
                }
        }
        if (c == '\\')
        { /* escaped name */
                yyleng = 0;
                while ((c = yysbuf[++yysptr]) != ' ')
                        yytext[yyleng++] = c;
                yytext[yyleng] = '\0';
                if (bug)
                        fprintf (yyout, "    ^tok:NAME\n");
                if (toklast == MODULE)
                {
                        toklast = 0;
                        strcpy (modnam, yytext);
                        fprintf (stderr, "module %s\n", modnam);
                }
                if (toklast == PRIMITIVE)
                {
                        toklast = 0;
                        strcpy (modnam, yytext);
                        fprintf (stderr, "primitive %s\n", modnam);
                }
                strcpy (yylval.s, yytext);
                return (NAME);
        }
        if (isalpha (c))
        {
                if (yylast == '\'')
                { /* number base - 1'b0 */
                        yysptr++;
                        if (bug)
                                if (c < ' ')
                                        fprintf (yyout, "    ^CHAR:%d\n", c);
                                else
                                        fprintf (yyout, "    ^CHAR:%c\n", c);
                        yylast = c;
                        return (c);
                }
                if ((j = chktok ()) != 0)
                {
                        toklast = j;
                        return (j);
                }
        name:
                yyleng = 0;
                while (isalpha (c) || isdigit (c) || c == '_')
                {
                        yytext[yyleng++] = c;
                        c = yysbuf[++yysptr];
                }
                yytext[yyleng] = '\0';
                if (bug)
                        fprintf (yyout, "    ^tok:NAME\n");
                if (toklast == MODULE)
                {
                        toklast = 0;
                        strcpy (modnam, yytext);
                        fprintf (stderr, "module %s\n", modnam);
                }
                if (toklast == PRIMITIVE)
                {
                        toklast = 0;
                        strcpy (modnam, yytext);
                        fprintf (stderr, "primitive %s\n", modnam);
                }
                strcpy (yylval.s, yytext);
                return (NAME);
        }
        if (isdigit (c))
        {
                yyleng = 0;
                while (isdigit (c))
                {
                        yytext[yyleng++] = c;
                        c = yysbuf[++yysptr];
                }
                yytext[yyleng] = '\0';
                if (bug)
                        fprintf (yyout, "    ^tok:NUMBER\n");
                strcpy (yylval.s, yytext);
                return (NUMBER);
        }
        yysptr++;
        yylast = c;
        if (c == '+' || c == '-' || c == '&' || c == '|' || c == '^')
        {
                if (bug)
                        fprintf (yyout, "    ^BIN_OP:%c\n", c);
                return (BIN_OP);
        }
        if (c == '!' || c == '~')
        {
                if (bug)
                        fprintf (yyout, "    ^UNARY_OP:%c\n", c);
                return (UNARY_OP);
        }
        if (bug)
                if (c < ' ')
                        fprintf (yyout, "    ^CHAR:%d\n", c);
                else
                        fprintf (yyout, "    ^CHAR:%c\n", c);
        return (c);
} /* nexttoken */

int chktok ()
{
        static struct
        {
                char *keyword;
                int val, tok;
        } key[] = {"module ",    0, MODULE,    "endmodule",    0, ENDMODULE,
                   "primitive ", 0, PRIMITIVE, "endprimitive", 0, ENDPRIM,
                   "input ",     0, INPUT,     "output ",      0, OUTPUT,
                   "inout ",     0, INOUT,     "assign ",      0, ASSIGN,
                   "wire ",      0, NETTYPE,   "triand ",      1, NETTYPE,
                   "trior ",     2, NETTYPE,   "tri1 ",        3, NETTYPE,
                   "tri ",       4, NETTYPE,   "supply0 ",     5, NETTYPE,
                   "supply1 ",   6, NETTYPE,   "wor ",         7, NETTYPE,
                   "trireg ",    8, NETTYPE,   "supply0 ",     0, STRENGTH0,
                   "strong0 ",   1, STRENGTH0, "pull0 ",       2, STRENGTH0,
                   "weak0 ",     3, STRENGTH0, "highz0 ",      4, STRENGTH0,
                   "supply1 ",   0, STRENGTH1, "strong1 ",     1, STRENGTH1,
                   "pull1 ",     2, STRENGTH1, "weak1 ",       3, STRENGTH1,
                   "highz1 ",    4, STRENGTH1, "parameter ",   0, PARAMETER,
                   "reg ",       0, REG,       "time ",        0, TIME,
                   "integer ",   0, INTEGER,   "real ",        0, REAL,
                   "event ",     0, EVENT,     "defparam ",    0, DEFPARAM,
                   "and ",       0, GATETYPE,  "nand ",        1, GATETYPE,
                   "or ",        2, GATETYPE,  "nor ",         3, GATETYPE,
                   "xor ",       4, GATETYPE,  "xnor ",        5, GATETYPE,
                   "buf ",       6, GATETYPE,  "tran ",        7, GATETYPE,
                   "table ",     0, TABLE,     "endtable",     0, ENDTABLE,
                   "initial ",   0, INITIAL,   NULL,           0, 0};
        int save, i, j;
        char *s;

        for (j = 0; (s = key[j].keyword) != NULL; j++)
        {
                save = yysptr;
                yyleng = 0;
                while (*s == yysbuf[yysptr++] && *s)
                        yytext[yyleng++] = *s++;
                if (*s == '\0')
                {
                        yytext[yyleng] = '\0';
                        yysptr--;
                        if (bug)
                        {
                                for (i = yysptr - 1; i > 0; i--)
                                        out (' ');
                                fprintf (yyout, "    ^tok:%s\n", yytext);
                        }
                        yylval.i = key[j].val;
                        return (key[j].tok);
                }
                yysptr = save;
        }
        return (0);
}

yyerror (s) char *s;
{
        int i;

        fprintf (stderr, "%s error on line %d\n", s, yylineno);
        fprintf (stderr, "%s\n", yysbuf);
        for (i = yysptr; i > 0; i--)
                out (' ');
        fprintf (stderr, "^\n");
}

char *strsave (s) char *s;
{
        char *p, *malloc ();

        if ((p = malloc (strlen (s) + 1)) != NULL)
                strcpy (p, s);
        if (p == NULL)
                err ("out of malloc space");
        return (p);
}

err (s, t) char *s, *t;
{
        fprintf (stderr, s, t);
        fprintf (stderr, "\n");
        exit (1);
}