18734Ssam %{ 221131Sdist /* 321131Sdist * Copyright (c) 1983 Regents of the University of California. 4*33537Sbostic * All rights reserved. 5*33537Sbostic * 6*33537Sbostic * Redistribution and use in source and binary forms are permitted 7*33537Sbostic * provided that this notice is preserved and that due credit is given 8*33537Sbostic * to the University of California at Berkeley. The name of the University 9*33537Sbostic * may not be used to endorse or promote products derived from this 10*33537Sbostic * software without specific prior written permission. This software 11*33537Sbostic * is provided ``as is'' without express or implied warranty. 1221131Sdist */ 1321131Sdist 148734Ssam #ifndef lint 15*33537Sbostic static char sccsid[] = "@(#)parse.y 5.3 (Berkeley) 02/23/88"; 16*33537Sbostic #endif /* not lint */ 178734Ssam 188734Ssam #include "htable.h" 198734Ssam %} 208734Ssam 218734Ssam %union { 228734Ssam int number; 238734Ssam struct addr *addrlist; 248734Ssam struct name *namelist; 258734Ssam } 268734Ssam %start Table 278734Ssam 288734Ssam %token END 298734Ssam %token <number> NUMBER KEYWORD 308734Ssam %token <namelist> NAME 318734Ssam 328734Ssam %type <namelist> Names Cputype Opsys Protos Proto 338734Ssam %type <addrlist> Addresses Address 348734Ssam %% 358734Ssam Table : Entry 368734Ssam | Table Entry 378734Ssam ; 388734Ssam 398734Ssam Entry : KEYWORD ':' Addresses ':' Names ':' END 408734Ssam = { 418734Ssam do_entry($1, $3, $5, NONAME, NONAME, NONAME); 428734Ssam } 438734Ssam | KEYWORD ':' Addresses ':' Names ':' Cputype ':' END 448734Ssam = { 458734Ssam do_entry($1, $3, $5, $7, NONAME, NONAME); 468734Ssam } 478734Ssam | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' END 488734Ssam = { 498734Ssam do_entry($1, $3, $5, $7, $9, NONAME); 508734Ssam } 518734Ssam | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' ':' END 528734Ssam = { 538734Ssam do_entry($1, $3, $5, $7, $9, NONAME); 548734Ssam } 558734Ssam | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' Protos ':' END 568734Ssam = { 578734Ssam do_entry($1, $3, $5, $7, $9, $11); 588734Ssam } 598734Ssam | error END 608734Ssam | END /* blank line */ 618734Ssam ; 628734Ssam 638734Ssam Addresses: Address 648734Ssam = { 658734Ssam $$ = $1; 668734Ssam } 678734Ssam | Address ',' Addresses 688734Ssam = { 698734Ssam $1->addr_link = $3; 708734Ssam $$ = $1; 718734Ssam } 728734Ssam ; 738734Ssam 748734Ssam Address : NUMBER '.' NUMBER '.' NUMBER '.' NUMBER 758734Ssam = { 768785Ssam char *a; 778785Ssam 788785Ssam $$ = (struct addr *)malloc(sizeof (struct addr)); 798785Ssam a = (char *)&($$->addr_val); 808785Ssam a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7; 818734Ssam $$->addr_link = NOADDR; 828734Ssam } 838734Ssam ; 848734Ssam 858734Ssam Names : NAME 868734Ssam = { 878734Ssam $$ = $1; 888734Ssam } 898734Ssam | NAME ',' Names 908734Ssam = { 918734Ssam $1->name_link = $3; 928734Ssam $$ = $1; 938734Ssam } 948734Ssam ; 958734Ssam 968734Ssam Cputype : /* empty */ 978734Ssam = { 988734Ssam $$ = NONAME; 998734Ssam } 1008734Ssam | NAME 1018734Ssam = { 1028734Ssam $$ = $1; 1038734Ssam } 1048734Ssam ; 1058734Ssam 1068734Ssam Opsys : /* empty */ 1078734Ssam = { 1088734Ssam $$ = NONAME; 1098734Ssam } 1108734Ssam | NAME 1118734Ssam = { 1128734Ssam $$ = $1; 1138734Ssam } 1148734Ssam ; 1158734Ssam 1168734Ssam Protos : Proto 1178734Ssam = { 1188734Ssam $$ = $1; 1198734Ssam } 1208734Ssam | Proto ',' Protos 1218734Ssam = { 1228734Ssam $1->name_link = $3; 1238734Ssam $$ = $1; 1248734Ssam } 1258734Ssam ; 1268734Ssam 1278734Ssam Proto : NAME 1288734Ssam = { 1298734Ssam $$ = $1; 1308734Ssam } 1318734Ssam ; 1328734Ssam %% 1338734Ssam 1348734Ssam #include <stdio.h> 1358734Ssam 1368734Ssam extern int yylineno; 1378734Ssam 1388734Ssam yyerror(msg) 1398734Ssam char *msg; 1408734Ssam { 1418734Ssam fprintf(stderr, "\"%s\", line %d: %s\n", infile, yylineno, msg); 1428734Ssam } 143