1: %{
   2: /*
   3:  * Copyright (c) 1983 Regents of the University of California.
   4:  * All rights reserved.  The Berkeley software License Agreement
   5:  * specifies the terms and conditions for redistribution.
   6:  */
   7: 
   8: #ifndef lint
   9: static char sccsid[] = "@(#)parse.y	5.2 (Berkeley) 6/21/85";
  10: #endif not lint
  11: 
  12: 
  13: #include "htable.h"
  14: %}
  15: 
  16: %union {
  17:     int number;
  18:     struct  addr *addrlist;
  19:     struct  name *namelist;
  20: }
  21: %start Table
  22: 
  23: %token          END
  24: %token <number>     NUMBER KEYWORD
  25: %token <namelist>   NAME
  26: 
  27: %type <namelist>    Names Cputype Opsys Protos Proto
  28: %type <addrlist>    Addresses Address
  29: %%
  30: Table   :   Entry
  31:     |   Table Entry
  32:     ;
  33: 
  34: Entry   :   KEYWORD ':' Addresses ':' Names ':' END
  35:     = {
  36:         do_entry($1, $3, $5, NONAME, NONAME, NONAME);
  37:     }
  38:     |   KEYWORD ':' Addresses ':' Names ':' Cputype ':' END
  39:     = {
  40:         do_entry($1, $3, $5, $7, NONAME, NONAME);
  41:     }
  42:     |   KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' END
  43:     = {
  44:         do_entry($1, $3, $5, $7, $9, NONAME);
  45:     }
  46:     |   KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' ':' END
  47:     = {
  48:         do_entry($1, $3, $5, $7, $9, NONAME);
  49:     }
  50:     |   KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' Protos ':' END
  51:     = {
  52:         do_entry($1, $3, $5, $7, $9, $11);
  53:     }
  54:     |   error END
  55:     |   END     /* blank line */
  56:     ;
  57: 
  58: Addresses:  Address
  59:     = {
  60:         $$ = $1;
  61:     }
  62:     |   Address ',' Addresses
  63:     = {
  64:         $1->addr_link = $3;
  65:         $$ = $1;
  66:     }
  67:     ;
  68: 
  69: Address :   NUMBER '.' NUMBER '.' NUMBER '.' NUMBER
  70:     = {
  71:         char *a;
  72: 
  73:         $$ = (struct addr *)malloc(sizeof (struct addr));
  74:         a = (char *)&($$->addr_val);
  75:         a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7;
  76:         $$->addr_link = NOADDR;
  77:     }
  78:     ;
  79: 
  80: Names   :   NAME
  81:     = {
  82:         $$ = $1;
  83:     }
  84:     |   NAME ',' Names
  85:     = {
  86:         $1->name_link = $3;
  87:         $$ = $1;
  88:     }
  89:     ;
  90: 
  91: Cputype :   /* empty */
  92:     = {
  93:         $$ = NONAME;
  94:     }
  95:     |   NAME
  96:     = {
  97:         $$ = $1;
  98:     }
  99:     ;
 100: 
 101: Opsys   :   /* empty */
 102:     = {
 103:         $$ = NONAME;
 104:     }
 105:     |   NAME
 106:     = {
 107:         $$ = $1;
 108:     }
 109:     ;
 110: 
 111: Protos  :   Proto
 112:     = {
 113:         $$ = $1;
 114:     }
 115:     |   Proto ',' Protos
 116:     = {
 117:         $1->name_link = $3;
 118:         $$ = $1;
 119:     }
 120:     ;
 121: 
 122: Proto   :   NAME
 123:     = {
 124:         $$ = $1;
 125:     }
 126:     ;
 127: %%
 128: 
 129: #include <stdio.h>
 130: 
 131: extern int yylineno;
 132: 
 133: yyerror(msg)
 134:     char *msg;
 135: {
 136:     fprintf(stderr, "\"%s\", line %d: %s\n", infile, yylineno, msg);
 137: }

Defined functions

_yyerror defined in line 133; never used
Last modified: 1987-02-16
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1152
Valid CSS Valid XHTML 1.0 Strict