Commit | Line | Data |
---|---|---|
10f88819 | 1 | %{ |
528b0614 DF |
2 | /* |
3 | * Copyright (c) 1983 Regents of the University of California. | |
4 | * All rights reserved. The Berkeley software License Agreement | |
5 | * specifies the terms and conditions for redistribution. | |
6 | */ | |
7 | ||
8 | #ifndef lint | |
9 | char copyright[] = | |
10 | "@(#) Copyright (c) 1983 Regents of the University of California.\n\ | |
11 | All rights reserved.\n"; | |
12 | #endif not lint | |
13 | ||
10f88819 | 14 | #ifndef lint |
528b0614 DF |
15 | static char sccsid[] = "@(#)parse.y 5.1 (Berkeley) %G%"; |
16 | #endif not lint | |
17 | ||
10f88819 SL |
18 | |
19 | #include "htable.h" | |
20 | %} | |
21 | ||
22 | %union { | |
23 | int number; | |
24 | struct addr *addrlist; | |
25 | struct name *namelist; | |
26 | } | |
27 | %start Table | |
28 | ||
29 | %token END | |
30 | %token <number> NUMBER KEYWORD | |
31 | %token <namelist> NAME | |
32 | ||
33 | %type <namelist> Names Cputype Opsys Protos Proto | |
34 | %type <addrlist> Addresses Address | |
35 | %% | |
36 | Table : Entry | |
37 | | Table Entry | |
38 | ; | |
39 | ||
40 | Entry : KEYWORD ':' Addresses ':' Names ':' END | |
41 | = { | |
42 | do_entry($1, $3, $5, NONAME, NONAME, NONAME); | |
43 | } | |
44 | | KEYWORD ':' Addresses ':' Names ':' Cputype ':' END | |
45 | = { | |
46 | do_entry($1, $3, $5, $7, NONAME, NONAME); | |
47 | } | |
48 | | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' END | |
49 | = { | |
50 | do_entry($1, $3, $5, $7, $9, NONAME); | |
51 | } | |
52 | | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' ':' END | |
53 | = { | |
54 | do_entry($1, $3, $5, $7, $9, NONAME); | |
55 | } | |
56 | | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' Protos ':' END | |
57 | = { | |
58 | do_entry($1, $3, $5, $7, $9, $11); | |
59 | } | |
60 | | error END | |
61 | | END /* blank line */ | |
62 | ; | |
63 | ||
64 | Addresses: Address | |
65 | = { | |
66 | $$ = $1; | |
67 | } | |
68 | | Address ',' Addresses | |
69 | = { | |
70 | $1->addr_link = $3; | |
71 | $$ = $1; | |
72 | } | |
73 | ; | |
74 | ||
75 | Address : NUMBER '.' NUMBER '.' NUMBER '.' NUMBER | |
76 | = { | |
cd08f4dd SL |
77 | char *a; |
78 | ||
79 | $$ = (struct addr *)malloc(sizeof (struct addr)); | |
80 | a = (char *)&($$->addr_val); | |
81 | a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7; | |
10f88819 SL |
82 | $$->addr_link = NOADDR; |
83 | } | |
84 | ; | |
85 | ||
86 | Names : NAME | |
87 | = { | |
88 | $$ = $1; | |
89 | } | |
90 | | NAME ',' Names | |
91 | = { | |
92 | $1->name_link = $3; | |
93 | $$ = $1; | |
94 | } | |
95 | ; | |
96 | ||
97 | Cputype : /* empty */ | |
98 | = { | |
99 | $$ = NONAME; | |
100 | } | |
101 | | NAME | |
102 | = { | |
103 | $$ = $1; | |
104 | } | |
105 | ; | |
106 | ||
107 | Opsys : /* empty */ | |
108 | = { | |
109 | $$ = NONAME; | |
110 | } | |
111 | | NAME | |
112 | = { | |
113 | $$ = $1; | |
114 | } | |
115 | ; | |
116 | ||
117 | Protos : Proto | |
118 | = { | |
119 | $$ = $1; | |
120 | } | |
121 | | Proto ',' Protos | |
122 | = { | |
123 | $1->name_link = $3; | |
124 | $$ = $1; | |
125 | } | |
126 | ; | |
127 | ||
128 | Proto : NAME | |
129 | = { | |
130 | $$ = $1; | |
131 | } | |
132 | ; | |
133 | %% | |
134 | ||
135 | #include <stdio.h> | |
136 | ||
137 | extern int yylineno; | |
138 | ||
139 | yyerror(msg) | |
140 | char *msg; | |
141 | { | |
142 | fprintf(stderr, "\"%s\", line %d: %s\n", infile, yylineno, msg); | |
143 | } |