xref: /csrg-svn/old/htable/parse.y (revision 34773)
18734Ssam %{
2*34773Sbostic 
321131Sdist /*
421131Sdist  * Copyright (c) 1983 Regents of the University of California.
533537Sbostic  * All rights reserved.
633537Sbostic  *
733537Sbostic  * Redistribution and use in source and binary forms are permitted
8*34773Sbostic  * provided that the above copyright notice and this paragraph are
9*34773Sbostic  * duplicated in all such forms and that any documentation,
10*34773Sbostic  * advertising materials, and other materials related to such
11*34773Sbostic  * distribution and use acknowledge that the software was developed
12*34773Sbostic  * by the University of California, Berkeley.  The name of the
13*34773Sbostic  * University may not be used to endorse or promote products derived
14*34773Sbostic  * from this software without specific prior written permission.
15*34773Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16*34773Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17*34773Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1821131Sdist  */
1921131Sdist 
208734Ssam #ifndef lint
21*34773Sbostic static char sccsid[] = "@(#)parse.y	5.4 (Berkeley) 06/18/88";
2233537Sbostic #endif /* not lint */
238734Ssam 
248734Ssam #include "htable.h"
258734Ssam %}
268734Ssam 
278734Ssam %union {
288734Ssam 	int	number;
298734Ssam 	struct	addr *addrlist;
308734Ssam 	struct	name *namelist;
318734Ssam }
328734Ssam %start Table
338734Ssam 
348734Ssam %token			END
358734Ssam %token <number>		NUMBER KEYWORD
368734Ssam %token <namelist>	NAME
378734Ssam 
388734Ssam %type <namelist>	Names Cputype Opsys Protos Proto
398734Ssam %type <addrlist>	Addresses Address
408734Ssam %%
418734Ssam Table	:	Entry
428734Ssam 	|	Table Entry
438734Ssam 	;
448734Ssam 
458734Ssam Entry	:	KEYWORD ':' Addresses ':' Names ':' END
468734Ssam 	= {
478734Ssam 		do_entry($1, $3, $5, NONAME, NONAME, NONAME);
488734Ssam 	}
498734Ssam 	|	KEYWORD ':' Addresses ':' Names ':' Cputype ':' END
508734Ssam 	= {
518734Ssam 		do_entry($1, $3, $5, $7, NONAME, NONAME);
528734Ssam 	}
538734Ssam 	|	KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' END
548734Ssam 	= {
558734Ssam 		do_entry($1, $3, $5, $7, $9, NONAME);
568734Ssam 	}
578734Ssam 	|	KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' ':' END
588734Ssam 	= {
598734Ssam 		do_entry($1, $3, $5, $7, $9, NONAME);
608734Ssam 	}
618734Ssam 	|	KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' Protos ':' END
628734Ssam 	= {
638734Ssam 		do_entry($1, $3, $5, $7, $9, $11);
648734Ssam 	}
658734Ssam 	|	error END
668734Ssam 	|	END		/* blank line */
678734Ssam 	;
688734Ssam 
698734Ssam Addresses:	Address
708734Ssam 	= {
718734Ssam 		$$ = $1;
728734Ssam 	}
738734Ssam 	|	Address ',' Addresses
748734Ssam 	= {
758734Ssam 		$1->addr_link = $3;
768734Ssam 		$$ = $1;
778734Ssam 	}
788734Ssam 	;
798734Ssam 
808734Ssam Address	:	NUMBER '.' NUMBER '.' NUMBER '.' NUMBER
818734Ssam 	= {
828785Ssam 		char *a;
838785Ssam 
848785Ssam 		$$ = (struct addr *)malloc(sizeof (struct addr));
858785Ssam 		a = (char *)&($$->addr_val);
868785Ssam 		a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7;
878734Ssam 		$$->addr_link = NOADDR;
888734Ssam 	}
898734Ssam 	;
908734Ssam 
918734Ssam Names	:	NAME
928734Ssam 	= {
938734Ssam 		$$ = $1;
948734Ssam 	}
958734Ssam 	|	NAME ',' Names
968734Ssam 	= {
978734Ssam 		$1->name_link = $3;
988734Ssam 		$$ = $1;
998734Ssam 	}
1008734Ssam 	;
1018734Ssam 
1028734Ssam Cputype :	/* empty */
1038734Ssam 	= {
1048734Ssam 		$$ = NONAME;
1058734Ssam 	}
1068734Ssam 	|	NAME
1078734Ssam 	= {
1088734Ssam 		$$ = $1;
1098734Ssam 	}
1108734Ssam 	;
1118734Ssam 
1128734Ssam Opsys	:	/* empty */
1138734Ssam 	= {
1148734Ssam 		$$ = NONAME;
1158734Ssam 	}
1168734Ssam 	|	NAME
1178734Ssam 	= {
1188734Ssam 		$$ = $1;
1198734Ssam 	}
1208734Ssam 	;
1218734Ssam 
1228734Ssam Protos	:	Proto
1238734Ssam 	= {
1248734Ssam 		$$ = $1;
1258734Ssam 	}
1268734Ssam 	|	Proto ',' Protos
1278734Ssam 	= {
1288734Ssam 		$1->name_link = $3;
1298734Ssam 		$$ = $1;
1308734Ssam 	}
1318734Ssam 	;
1328734Ssam 
1338734Ssam Proto	:	NAME
1348734Ssam 	= {
1358734Ssam 		$$ = $1;
1368734Ssam 	}
1378734Ssam 	;
1388734Ssam %%
1398734Ssam 
1408734Ssam #include <stdio.h>
1418734Ssam 
1428734Ssam extern int yylineno;
1438734Ssam 
1448734Ssam yyerror(msg)
1458734Ssam 	char *msg;
1468734Ssam {
1478734Ssam 	fprintf(stderr, "\"%s\", line %d: %s\n", infile, yylineno, msg);
1488734Ssam }
149