167 lines
3.7 KiB
Plaintext
167 lines
3.7 KiB
Plaintext
%{
|
|
|
|
/*
|
|
* Copyright (c) 1983 Regents of the University of California.
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
* must display the following acknowledgement:
|
|
* This product includes software developed by the University of
|
|
* California, Berkeley and its contributors.
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
* may be used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*/
|
|
|
|
#ifndef lint
|
|
/*static char sccsid[] = "from: @(#)parse.y 5.5 (Berkeley) 6/1/90";*/
|
|
static char rcsid[] = "$Id: parse.y,v 1.3 1994/12/23 16:47:06 cgd Exp $";
|
|
#endif /* not lint */
|
|
|
|
#include <stdlib.h>
|
|
#include "htable.h"
|
|
%}
|
|
|
|
%union {
|
|
int number;
|
|
struct addr *addrlist;
|
|
struct name *namelist;
|
|
}
|
|
%start Table
|
|
|
|
%token END
|
|
%token <number> NUMBER KEYWORD
|
|
%token <namelist> NAME
|
|
|
|
%type <namelist> Names Cputype Opsys Protos Proto
|
|
%type <addrlist> Addresses Address
|
|
%%
|
|
Table : Entry
|
|
| Table Entry
|
|
;
|
|
|
|
Entry : KEYWORD ':' Addresses ':' Names ':' END
|
|
= {
|
|
do_entry($1, $3, $5, NONAME, NONAME, NONAME);
|
|
}
|
|
| KEYWORD ':' Addresses ':' Names ':' Cputype ':' END
|
|
= {
|
|
do_entry($1, $3, $5, $7, NONAME, NONAME);
|
|
}
|
|
| KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' END
|
|
= {
|
|
do_entry($1, $3, $5, $7, $9, NONAME);
|
|
}
|
|
| KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' ':' END
|
|
= {
|
|
do_entry($1, $3, $5, $7, $9, NONAME);
|
|
}
|
|
| KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' Protos ':' END
|
|
= {
|
|
do_entry($1, $3, $5, $7, $9, $11);
|
|
}
|
|
| error END
|
|
| END /* blank line */
|
|
;
|
|
|
|
Addresses: Address
|
|
= {
|
|
$$ = $1;
|
|
}
|
|
| Address ',' Addresses
|
|
= {
|
|
$1->addr_link = $3;
|
|
$$ = $1;
|
|
}
|
|
;
|
|
|
|
Address : NUMBER '.' NUMBER '.' NUMBER '.' NUMBER
|
|
= {
|
|
char *a;
|
|
|
|
$$ = (struct addr *)malloc(sizeof (struct addr));
|
|
a = (char *)&($$->addr_val);
|
|
a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7;
|
|
$$->addr_link = NOADDR;
|
|
}
|
|
;
|
|
|
|
Names : NAME
|
|
= {
|
|
$$ = $1;
|
|
}
|
|
| NAME ',' Names
|
|
= {
|
|
$1->name_link = $3;
|
|
$$ = $1;
|
|
}
|
|
;
|
|
|
|
Cputype : /* empty */
|
|
= {
|
|
$$ = NONAME;
|
|
}
|
|
| NAME
|
|
= {
|
|
$$ = $1;
|
|
}
|
|
;
|
|
|
|
Opsys : /* empty */
|
|
= {
|
|
$$ = NONAME;
|
|
}
|
|
| NAME
|
|
= {
|
|
$$ = $1;
|
|
}
|
|
;
|
|
|
|
Protos : Proto
|
|
= {
|
|
$$ = $1;
|
|
}
|
|
| Proto ',' Protos
|
|
= {
|
|
$1->name_link = $3;
|
|
$$ = $1;
|
|
}
|
|
;
|
|
|
|
Proto : NAME
|
|
= {
|
|
$$ = $1;
|
|
}
|
|
;
|
|
%%
|
|
|
|
#include <stdio.h>
|
|
|
|
extern int yylineno;
|
|
|
|
yyerror(msg)
|
|
char *msg;
|
|
{
|
|
fprintf(stderr, "\"%s\", line %d: %s\n", infile, yylineno, msg);
|
|
}
|