|
|
1.1 ! root 1: %{ ! 2: ! 3: /* ! 4: * Copyright (c) 1983 Regents of the University of California. ! 5: * All rights reserved. ! 6: * ! 7: * Redistribution and use in source and binary forms are permitted ! 8: * provided that the above copyright notice and this paragraph are ! 9: * duplicated in all such forms and that any documentation, ! 10: * advertising materials, and other materials related to such ! 11: * distribution and use acknowledge that the software was developed ! 12: * by the University of California, Berkeley. The name of the ! 13: * University may not be used to endorse or promote products derived ! 14: * from this software without specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 17: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #ifndef lint ! 21: static char sccsid[] = "@(#)parse.y 5.4 (Berkeley) 6/18/88"; ! 22: #endif /* not lint */ ! 23: ! 24: #include "htable.h" ! 25: %} ! 26: ! 27: %union { ! 28: int number; ! 29: struct addr *addrlist; ! 30: struct name *namelist; ! 31: } ! 32: %start Table ! 33: ! 34: %token END ! 35: %token <number> NUMBER KEYWORD ! 36: %token <namelist> NAME ! 37: ! 38: %type <namelist> Names Cputype Opsys Protos Proto ! 39: %type <addrlist> Addresses Address ! 40: %% ! 41: Table : Entry ! 42: | Table Entry ! 43: ; ! 44: ! 45: Entry : KEYWORD ':' Addresses ':' Names ':' END ! 46: = { ! 47: do_entry($1, $3, $5, NONAME, NONAME, NONAME); ! 48: } ! 49: | KEYWORD ':' Addresses ':' Names ':' Cputype ':' END ! 50: = { ! 51: do_entry($1, $3, $5, $7, NONAME, NONAME); ! 52: } ! 53: | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' END ! 54: = { ! 55: do_entry($1, $3, $5, $7, $9, NONAME); ! 56: } ! 57: | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' ':' END ! 58: = { ! 59: do_entry($1, $3, $5, $7, $9, NONAME); ! 60: } ! 61: | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' Protos ':' END ! 62: = { ! 63: do_entry($1, $3, $5, $7, $9, $11); ! 64: } ! 65: | error END ! 66: | END /* blank line */ ! 67: ; ! 68: ! 69: Addresses: Address ! 70: = { ! 71: $$ = $1; ! 72: } ! 73: | Address ',' Addresses ! 74: = { ! 75: $1->addr_link = $3; ! 76: $$ = $1; ! 77: } ! 78: ; ! 79: ! 80: Address : NUMBER '.' NUMBER '.' NUMBER '.' NUMBER ! 81: = { ! 82: char *a; ! 83: ! 84: $$ = (struct addr *)malloc(sizeof (struct addr)); ! 85: a = (char *)&($$->addr_val); ! 86: a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7; ! 87: $$->addr_link = NOADDR; ! 88: } ! 89: ; ! 90: ! 91: Names : NAME ! 92: = { ! 93: $$ = $1; ! 94: } ! 95: | NAME ',' Names ! 96: = { ! 97: $1->name_link = $3; ! 98: $$ = $1; ! 99: } ! 100: ; ! 101: ! 102: Cputype : /* empty */ ! 103: = { ! 104: $$ = NONAME; ! 105: } ! 106: | NAME ! 107: = { ! 108: $$ = $1; ! 109: } ! 110: ; ! 111: ! 112: Opsys : /* empty */ ! 113: = { ! 114: $$ = NONAME; ! 115: } ! 116: | NAME ! 117: = { ! 118: $$ = $1; ! 119: } ! 120: ; ! 121: ! 122: Protos : Proto ! 123: = { ! 124: $$ = $1; ! 125: } ! 126: | Proto ',' Protos ! 127: = { ! 128: $1->name_link = $3; ! 129: $$ = $1; ! 130: } ! 131: ; ! 132: ! 133: Proto : NAME ! 134: = { ! 135: $$ = $1; ! 136: } ! 137: ; ! 138: %% ! 139: ! 140: #include <stdio.h> ! 141: ! 142: extern int yylineno; ! 143: ! 144: yyerror(msg) ! 145: char *msg; ! 146: { ! 147: fprintf(stderr, "\"%s\", line %d: %s\n", infile, yylineno, msg); ! 148: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.