|
|
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: #include "htable.h"
24:
25: #include "y.tab.h"
26: %}
27:
28: %union {
29: int number;
30: struct addr *addrlist;
31: struct name *namelist;
32: }
33: %start Table
34:
35: %token END
36: %token <number> NUMBER KEYWORD
37: %token <namelist> NAME
38:
39: %type <namelist> Names Cputype Opsys Protos Proto
40: %type <addrlist> Addresses Address
41: %%
42: Table : Entry
43: | Table Entry
44: ;
45:
46: Entry : KEYWORD ':' Addresses ':' Names ':' END
47: = {
48: do_entry($1, $3, $5, NONAME, NONAME, NONAME);
49: }
50: | KEYWORD ':' Addresses ':' Names ':' Cputype ':' END
51: = {
52: do_entry($1, $3, $5, $7, NONAME, NONAME);
53: }
54: | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' END
55: = {
56: do_entry($1, $3, $5, $7, $9, NONAME);
57: }
58: | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' ':' END
59: = {
60: do_entry($1, $3, $5, $7, $9, NONAME);
61: }
62: | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' Protos ':' END
63: = {
64: do_entry($1, $3, $5, $7, $9, $11);
65: }
66: | error END
67: | END /* blank line */
68: ;
69:
70: Addresses: Address
71: = {
72: $$ = $1;
73: }
74: | Address ',' Addresses
75: = {
76: $1->addr_link = $3;
77: $$ = $1;
78: }
79: ;
80:
81: Address : NUMBER '.' NUMBER '.' NUMBER '.' NUMBER
82: = {
83: char *a;
84:
85: $$ = (struct addr *)malloc(sizeof (struct addr));
86: a = (char *)&($$->addr_val);
87: a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7;
88: $$->addr_link = NOADDR;
89: }
90: ;
91:
92: Names : NAME
93: = {
94: $$ = $1;
95: }
96: | NAME ',' Names
97: = {
98: $1->name_link = $3;
99: $$ = $1;
100: }
101: ;
102:
103: Cputype : /* empty */
104: = {
105: $$ = NONAME;
106: }
107: | NAME
108: = {
109: $$ = $1;
110: }
111: ;
112:
113: Opsys : /* empty */
114: = {
115: $$ = NONAME;
116: }
117: | NAME
118: = {
119: $$ = $1;
120: }
121: ;
122:
123: Protos : Proto
124: = {
125: $$ = $1;
126: }
127: | Proto ',' Protos
128: = {
129: $1->name_link = $3;
130: $$ = $1;
131: }
132: ;
133:
134: Proto : NAME
135: = {
136: $$ = $1;
137: }
138: ;
139: %%
140:
141: #include <stdio.h>
142:
143: extern int yylineno;
144:
145: yyerror(msg)
146: char *msg;
147: {
148: fprintf(stderr, "\"%s\", line %d: %s\n", infile, yylineno, msg);
149: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.