Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/zonecfg/zonecfg_grammar.y
+++ new/usr/src/cmd/zonecfg/zonecfg_grammar.y
1 1 %{
2 2 /*
3 3 * CDDL HEADER START
4 4 *
5 5 * The contents of this file are subject to the terms of the
6 6 * Common Development and Distribution License (the "License").
7 7 * You may not use this file except in compliance with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
|
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22
23 23 /*
24 24 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
25 - * Copyright 2013, Joyent Inc. All rights reserved.
26 25 */
27 26
28 27 /*
29 28 * This file defines zonecfg(1M)'s grammar.
30 29 *
31 30 * Reduction rules that consume TOKENs must invoke claim_token() immediately
32 31 * before freeing the TOKENs or adding them to data structures (e.g., cmd) that
33 32 * will be cleaned up when the parser finishes or encounters errors.
34 33 */
35 34
36 35 #include <stdio.h>
37 36 #include <strings.h>
38 37
39 38 #include "zonecfg.h"
40 39
41 40 static cmd_t *cmd = NULL; /* Command being processed */
42 41 static complex_property_ptr_t complex = NULL;
43 42 static list_property_ptr_t new_list = NULL, tmp_list, last,
44 43 list[MAX_EQ_PROP_PAIRS];
45 44 static property_value_t property[MAX_EQ_PROP_PAIRS];
46 45
47 46 extern boolean_t newline_terminated;
48 47 extern int num_prop_vals; /* # of property values */
49 48
50 49 /* yacc externals */
51 50 extern int yydebug;
52 51 extern void yyerror(char *s);
53 52
54 53 /*
55 54 * This function is used by the simple_prop_val reduction rules to set up
56 55 * a list_property_ptr_t and adjust the above global variables appropriately.
57 56 * Note that this function duplicates the specified string and makes
58 57 * the new list's lp_simple field point to the duplicate. This function does
59 58 * not free the original string.
60 59 *
61 60 * This function returns a pointer to the duplicated string or NULL if an error
62 61 * occurred. The simple_prop_val reduction rules that invoke this function
63 62 * should set $$ to the returned pointer.
64 63 */
65 64 static char *
66 65 simple_prop_val_func(const char *str)
67 66 {
68 67 char *retstr;
69 68
70 69 if ((new_list = alloc_list()) == NULL)
71 70 return (NULL);
72 71 if ((retstr = strdup(str)) == NULL) {
73 72 free_list(new_list);
74 73 return (NULL);
75 74 }
76 75 new_list->lp_simple = retstr;
77 76 new_list->lp_complex = NULL;
78 77 new_list->lp_next = NULL;
79 78 if (list[num_prop_vals] == NULL) {
80 79 list[num_prop_vals] = new_list;
81 80 } else {
82 81 for (tmp_list = list[num_prop_vals]; tmp_list != NULL;
83 82 tmp_list = tmp_list->lp_next)
84 83 last = tmp_list;
85 84 last->lp_next = new_list;
86 85 }
87 86 return (retstr);
88 87 }
89 88
90 89 /*
91 90 * This function is used by the complex_piece reduction rules to set up a
92 91 * complex_property_prt_t and adjust the above global variables appropriately.
93 92 * Note that this function duplicates the specified string and makes the new
94 93 * complex_property_ptr_t's cp_value field point to the duplicate. It also sets
95 94 * the complex_property_ptr_t's cp_type field to cp_type and its cp_next field
96 95 * to cp_next. This function does not free the original string.
97 96 *
98 97 * This function returns a pointer to the complex_property_t created for the
99 98 * complex_piece or NULL if an error occurred. The complex_piece reduction
100 99 * rules that invoke this function should set $$ to the returned pointer.
101 100 */
102 101 static complex_property_ptr_t
103 102 complex_piece_func(int cp_type, const char *str, complex_property_ptr_t cp_next)
104 103 {
105 104 complex_property_ptr_t retval;
106 105
107 106 if ((retval = alloc_complex()) == NULL)
108 107 return (NULL);
109 108 if ((retval->cp_value = strdup(str)) == NULL) {
110 109 free_complex(retval);
111 110 return (NULL);
112 111 }
113 112 retval->cp_type = cp_type;
114 113 retval->cp_next = cp_next;
115 114 complex = retval;
116 115 return (retval);
117 116 }
118 117
119 118
120 119 %}
121 120
122 121 %union {
123 122 int ival;
124 123 char *strval;
125 124 cmd_t *cmd;
126 125 complex_property_ptr_t complex;
127 126 list_property_ptr_t list;
128 127 }
129 128
|
↓ open down ↓ |
94 lines elided |
↑ open up ↑ |
130 129 %start commands
131 130
132 131 %token HELP CREATE EXPORT ADD DELETE REMOVE SELECT SET INFO CANCEL END VERIFY
133 132 %token COMMIT REVERT EXIT SEMICOLON TOKEN ZONENAME ZONEPATH AUTOBOOT POOL NET
134 133 %token FS ATTR DEVICE RCTL SPECIAL RAW DIR OPTIONS TYPE ADDRESS PHYSICAL
135 134 %token IPTYPE HOSTID FS_ALLOWED ALLOWED_ADDRESS
136 135 %token NAME MATCH PRIV LIMIT ACTION VALUE EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
137 136 %token OPEN_PAREN CLOSE_PAREN COMMA DATASET LIMITPRIV BOOTARGS BRAND PSET PCAP
138 137 %token MCAP NCPUS IMPORTANCE SHARES MAXLWPS MAXSHMMEM MAXSHMIDS MAXMSGIDS
139 138 %token MAXSEMIDS LOCKED SWAP SCHED CLEAR DEFROUTER ADMIN USER AUTHS MAXPROCS
140 -%token ZFSPRI MAC VLANID GNIC NPROP UUID
139 +%token ZFSPRI MAC VLANID GNIC NPROP
141 140
142 141 %type <strval> TOKEN EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
143 142 property_value OPEN_PAREN CLOSE_PAREN COMMA simple_prop_val
144 143 %type <complex> complex_piece complex_prop_val
145 144 %type <ival> resource_type NET FS DEVICE RCTL ATTR DATASET PSET PCAP MCAP
146 145 ADMIN
147 146 %type <ival> property_name SPECIAL RAW DIR OPTIONS TYPE ADDRESS PHYSICAL NAME
148 147 MATCH ZONENAME ZONEPATH AUTOBOOT POOL LIMITPRIV BOOTARGS VALUE PRIV LIMIT
149 148 ACTION BRAND SCHED IPTYPE DEFROUTER HOSTID USER AUTHS FS_ALLOWED
150 - ALLOWED_ADDRESS MAC VLANID GNIC NPROP UUID
149 + ALLOWED_ADDRESS MAC VLANID GNIC NPROP
151 150 %type <cmd> command
152 151 %type <cmd> add_command ADD
153 152 %type <cmd> cancel_command CANCEL
154 153 %type <cmd> commit_command COMMIT
155 154 %type <cmd> create_command CREATE
156 155 %type <cmd> delete_command DELETE
157 156 %type <cmd> end_command END
158 157 %type <cmd> exit_command EXIT
159 158 %type <cmd> export_command EXPORT
160 159 %type <cmd> help_command HELP
161 160 %type <cmd> info_command INFO
162 161 %type <cmd> remove_command REMOVE
163 162 %type <cmd> revert_command REVERT
164 163 %type <cmd> select_command SELECT
165 164 %type <cmd> set_command SET
166 165 %type <cmd> clear_command CLEAR
167 166 %type <cmd> verify_command VERIFY
168 167 %type <cmd> terminator
169 168
170 169 %%
171 170
172 171 /*
173 172 * NOTE: Each commands reduction rule must invoke assert_no_unclaimed_tokens()
174 173 * before it completes if it isn't processing an error. This ensures that
175 174 * reduction rules properly consume TOKENs.
176 175 */
177 176 commands: command terminator
178 177 {
179 178 if ($1 != NULL) {
180 179 if ($1->cmd_handler != NULL)
181 180 $1->cmd_handler($1);
182 181 free_cmd($1);
183 182 bzero(list, sizeof (list_property_t));
184 183 num_prop_vals = 0;
185 184 }
186 185 assert_no_unclaimed_tokens();
187 186 return (0);
188 187 }
189 188 | command error terminator
190 189 {
191 190 if ($1 != NULL) {
192 191 free_cmd($1);
193 192 bzero(list, sizeof (list_property_t));
194 193 num_prop_vals = 0;
195 194 }
196 195 if (YYRECOVERING())
197 196 YYABORT;
198 197 yyclearin;
199 198 yyerrok;
200 199 }
201 200 | error terminator
202 201 {
203 202 if (YYRECOVERING())
204 203 YYABORT;
205 204 yyclearin;
206 205 yyerrok;
207 206 }
208 207 | terminator
209 208 {
210 209 assert_no_unclaimed_tokens();
211 210 return (0);
212 211 }
213 212
214 213 command: add_command
215 214 | cancel_command
216 215 | clear_command
217 216 | create_command
218 217 | commit_command
219 218 | delete_command
220 219 | end_command
221 220 | exit_command
222 221 | export_command
223 222 | help_command
224 223 | info_command
225 224 | remove_command
226 225 | revert_command
227 226 | select_command
228 227 | set_command
229 228 | verify_command
230 229
231 230 terminator: '\n' { newline_terminated = B_TRUE; }
232 231 | ';' { newline_terminated = B_FALSE; }
233 232
234 233 add_command: ADD
235 234 {
236 235 short_usage(CMD_ADD);
237 236 (void) fputs("\n", stderr);
238 237 usage(B_FALSE, HELP_RES_PROPS);
239 238 YYERROR;
240 239 }
241 240 | ADD TOKEN
242 241 {
243 242 if (($$ = alloc_cmd()) == NULL)
244 243 YYERROR;
245 244 cmd = $$;
246 245 $$->cmd_handler = &add_func;
247 246 $$->cmd_argc = 1;
248 247 $$->cmd_argv[0] = claim_token($2);
249 248 $$->cmd_argv[1] = NULL;
250 249 }
251 250 | ADD resource_type
252 251 {
253 252 if (($$ = alloc_cmd()) == NULL)
254 253 YYERROR;
255 254 cmd = $$;
256 255 $$->cmd_handler = &add_func;
257 256 $$->cmd_argc = 0;
258 257 $$->cmd_res_type = $2;
259 258 $$->cmd_prop_nv_pairs = 0;
260 259 }
261 260 | ADD property_name property_value
262 261 {
263 262 if (($$ = alloc_cmd()) == NULL)
264 263 YYERROR;
265 264 cmd = $$;
266 265 $$->cmd_handler = &add_func;
267 266 $$->cmd_argc = 0;
268 267 $$->cmd_prop_nv_pairs = 1;
269 268 $$->cmd_prop_name[0] = $2;
270 269 $$->cmd_property_ptr[0] = &property[0];
271 270 }
272 271
273 272 cancel_command: CANCEL
274 273 {
275 274 if (($$ = alloc_cmd()) == NULL)
276 275 YYERROR;
277 276 cmd = $$;
278 277 $$->cmd_handler = &cancel_func;
279 278 $$->cmd_argc = 0;
280 279 $$->cmd_argv[0] = NULL;
281 280 }
282 281 | CANCEL TOKEN
283 282 {
284 283 if (($$ = alloc_cmd()) == NULL)
285 284 YYERROR;
286 285 cmd = $$;
287 286 $$->cmd_handler = &cancel_func;
288 287 $$->cmd_argc = 1;
289 288 $$->cmd_argv[0] = claim_token($2);
290 289 $$->cmd_argv[1] = NULL;
291 290 }
292 291
293 292 create_command: CREATE
294 293 {
295 294 if (($$ = alloc_cmd()) == NULL)
296 295 YYERROR;
297 296 cmd = $$;
298 297 $$->cmd_handler = &create_func;
299 298 $$->cmd_argc = 0;
300 299 $$->cmd_argv[0] = NULL;
301 300 }
302 301 | CREATE TOKEN
303 302 {
304 303 if (($$ = alloc_cmd()) == NULL)
305 304 YYERROR;
306 305 cmd = $$;
307 306 $$->cmd_handler = &create_func;
308 307 $$->cmd_argc = 1;
309 308 $$->cmd_argv[0] = claim_token($2);
310 309 $$->cmd_argv[1] = NULL;
311 310 }
312 311 | CREATE TOKEN TOKEN
313 312 {
314 313 if (($$ = alloc_cmd()) == NULL)
315 314 YYERROR;
316 315 cmd = $$;
317 316 $$->cmd_handler = &create_func;
318 317 $$->cmd_argc = 2;
319 318 $$->cmd_argv[0] = claim_token($2);
320 319 $$->cmd_argv[1] = claim_token($3);
321 320 $$->cmd_argv[2] = NULL;
322 321 }
323 322 | CREATE TOKEN TOKEN TOKEN
324 323 {
325 324 if (($$ = alloc_cmd()) == NULL)
326 325 YYERROR;
327 326 cmd = $$;
328 327 $$->cmd_handler = &create_func;
329 328 $$->cmd_argc = 3;
330 329 $$->cmd_argv[0] = claim_token($2);
331 330 $$->cmd_argv[1] = claim_token($3);
332 331 $$->cmd_argv[2] = claim_token($4);
333 332 $$->cmd_argv[3] = NULL;
334 333 }
335 334
336 335 commit_command: COMMIT
337 336 {
338 337 if (($$ = alloc_cmd()) == NULL)
339 338 YYERROR;
340 339 cmd = $$;
341 340 $$->cmd_handler = &commit_func;
342 341 $$->cmd_argc = 0;
343 342 $$->cmd_argv[0] = NULL;
344 343 }
345 344 | COMMIT TOKEN
346 345 {
347 346 if (($$ = alloc_cmd()) == NULL)
348 347 YYERROR;
349 348 cmd = $$;
350 349 $$->cmd_handler = &commit_func;
351 350 $$->cmd_argc = 1;
352 351 $$->cmd_argv[0] = claim_token($2);
353 352 $$->cmd_argv[1] = NULL;
354 353 }
355 354
356 355 delete_command: DELETE
357 356 {
358 357 if (($$ = alloc_cmd()) == NULL)
359 358 YYERROR;
360 359 cmd = $$;
361 360 $$->cmd_handler = &delete_func;
362 361 $$->cmd_argc = 0;
363 362 $$->cmd_argv[0] = NULL;
364 363 }
365 364 | DELETE TOKEN
366 365 {
367 366 if (($$ = alloc_cmd()) == NULL)
368 367 YYERROR;
369 368 cmd = $$;
370 369 $$->cmd_handler = &delete_func;
371 370 $$->cmd_argc = 1;
372 371 $$->cmd_argv[0] = claim_token($2);
373 372 $$->cmd_argv[1] = NULL;
374 373 }
375 374
376 375 end_command: END
377 376 {
378 377 if (($$ = alloc_cmd()) == NULL)
379 378 YYERROR;
380 379 cmd = $$;
381 380 $$->cmd_handler = &end_func;
382 381 $$->cmd_argc = 0;
383 382 $$->cmd_argv[0] = NULL;
384 383 }
385 384 | END TOKEN
386 385 {
387 386 if (($$ = alloc_cmd()) == NULL)
388 387 YYERROR;
389 388 cmd = $$;
390 389 $$->cmd_handler = &end_func;
391 390 $$->cmd_argc = 1;
392 391 $$->cmd_argv[0] = claim_token($2);
393 392 $$->cmd_argv[1] = NULL;
394 393 }
395 394
396 395 exit_command: EXIT
397 396 {
398 397 if (($$ = alloc_cmd()) == NULL)
399 398 YYERROR;
400 399 cmd = $$;
401 400 $$->cmd_handler = &exit_func;
402 401 $$->cmd_argc = 0;
403 402 $$->cmd_argv[0] = NULL;
404 403 }
405 404 | EXIT TOKEN
406 405 {
407 406 if (($$ = alloc_cmd()) == NULL)
408 407 YYERROR;
409 408 cmd = $$;
410 409 $$->cmd_handler = &exit_func;
411 410 $$->cmd_argc = 1;
412 411 $$->cmd_argv[0] = claim_token($2);
413 412 $$->cmd_argv[1] = NULL;
414 413 }
415 414
416 415 export_command: EXPORT
417 416 {
418 417 if (($$ = alloc_cmd()) == NULL)
419 418 YYERROR;
420 419 cmd = $$;
421 420 $$->cmd_handler = &export_func;
422 421 $$->cmd_argc = 0;
423 422 $$->cmd_argv[0] = NULL;
424 423 }
425 424 | EXPORT TOKEN
426 425 {
427 426 if (($$ = alloc_cmd()) == NULL)
428 427 YYERROR;
429 428 cmd = $$;
430 429 $$->cmd_handler = &export_func;
431 430 $$->cmd_argc = 1;
432 431 $$->cmd_argv[0] = claim_token($2);
433 432 $$->cmd_argv[1] = NULL;
434 433 }
435 434 | EXPORT TOKEN TOKEN
436 435 {
437 436 if (($$ = alloc_cmd()) == NULL)
438 437 YYERROR;
439 438 cmd = $$;
440 439 $$->cmd_handler = &export_func;
441 440 $$->cmd_argc = 2;
442 441 $$->cmd_argv[0] = claim_token($2);
443 442 $$->cmd_argv[1] = claim_token($3);
444 443 $$->cmd_argv[2] = NULL;
445 444 }
446 445
447 446 help_command: HELP
448 447 {
449 448 if (($$ = alloc_cmd()) == NULL)
450 449 YYERROR;
451 450 cmd = $$;
452 451 $$->cmd_handler = &help_func;
453 452 $$->cmd_argc = 0;
454 453 $$->cmd_argv[0] = NULL;
455 454 }
456 455 | HELP TOKEN
457 456 {
458 457 if (($$ = alloc_cmd()) == NULL)
459 458 YYERROR;
460 459 cmd = $$;
461 460 $$->cmd_handler = &help_func;
462 461 $$->cmd_argc = 1;
463 462 $$->cmd_argv[0] = claim_token($2);
464 463 $$->cmd_argv[1] = NULL;
465 464 }
466 465
467 466 info_command: INFO
468 467 {
469 468 if (($$ = alloc_cmd()) == NULL)
470 469 YYERROR;
471 470 cmd = $$;
472 471 $$->cmd_handler = &info_func;
473 472 $$->cmd_res_type = RT_UNKNOWN;
474 473 $$->cmd_prop_nv_pairs = 0;
475 474 }
476 475 | INFO TOKEN
477 476 {
478 477 short_usage(CMD_INFO);
479 478 (void) fputs("\n", stderr);
480 479 usage(B_FALSE, HELP_RES_PROPS);
481 480 free(claim_token($2));
482 481 YYERROR;
483 482 }
484 483 | INFO resource_type
485 484 {
486 485 if (($$ = alloc_cmd()) == NULL)
487 486 YYERROR;
488 487 cmd = $$;
489 488 $$->cmd_handler = &info_func;
490 489 $$->cmd_res_type = $2;
491 490 $$->cmd_prop_nv_pairs = 0;
492 491 }
493 492 | INFO ZONENAME
494 493 {
495 494 if (($$ = alloc_cmd()) == NULL)
496 495 YYERROR;
497 496 cmd = $$;
498 497 $$->cmd_handler = &info_func;
499 498 $$->cmd_res_type = RT_ZONENAME;
500 499 $$->cmd_prop_nv_pairs = 0;
501 500 }
502 501 | INFO ZONEPATH
503 502 {
504 503 if (($$ = alloc_cmd()) == NULL)
505 504 YYERROR;
506 505 cmd = $$;
507 506 $$->cmd_handler = &info_func;
508 507 $$->cmd_res_type = RT_ZONEPATH;
509 508 $$->cmd_prop_nv_pairs = 0;
510 509 }
511 510 | INFO BRAND
512 511 {
513 512 if (($$ = alloc_cmd()) == NULL)
514 513 YYERROR;
515 514 cmd = $$;
516 515 $$->cmd_handler = &info_func;
517 516 $$->cmd_res_type = RT_BRAND;
518 517 $$->cmd_prop_nv_pairs = 0;
519 518 }
520 519 | INFO AUTOBOOT
521 520 {
522 521 if (($$ = alloc_cmd()) == NULL)
523 522 YYERROR;
524 523 cmd = $$;
525 524 $$->cmd_handler = &info_func;
526 525 $$->cmd_res_type = RT_AUTOBOOT;
527 526 $$->cmd_prop_nv_pairs = 0;
528 527 }
529 528 | INFO IPTYPE
530 529 {
531 530 if (($$ = alloc_cmd()) == NULL)
532 531 YYERROR;
533 532 cmd = $$;
534 533 $$->cmd_handler = &info_func;
535 534 $$->cmd_res_type = RT_IPTYPE;
536 535 $$->cmd_prop_nv_pairs = 0;
537 536 }
538 537 | INFO POOL
539 538 {
540 539 if (($$ = alloc_cmd()) == NULL)
541 540 YYERROR;
542 541 cmd = $$;
543 542 $$->cmd_handler = &info_func;
544 543 $$->cmd_res_type = RT_POOL;
545 544 $$->cmd_prop_nv_pairs = 0;
546 545 }
547 546 | INFO LIMITPRIV
548 547 {
549 548 if (($$ = alloc_cmd()) == NULL)
550 549 YYERROR;
551 550 cmd = $$;
552 551 $$->cmd_handler = &info_func;
553 552 $$->cmd_res_type = RT_LIMITPRIV;
554 553 $$->cmd_prop_nv_pairs = 0;
555 554 }
556 555 | INFO BOOTARGS
557 556 {
558 557 if (($$ = alloc_cmd()) == NULL)
559 558 YYERROR;
560 559 cmd = $$;
561 560 $$->cmd_handler = &info_func;
562 561 $$->cmd_res_type = RT_BOOTARGS;
563 562 $$->cmd_prop_nv_pairs = 0;
564 563 }
565 564 | INFO SCHED
566 565 {
567 566 if (($$ = alloc_cmd()) == NULL)
568 567 YYERROR;
569 568 cmd = $$;
570 569 $$->cmd_handler = &info_func;
571 570 $$->cmd_res_type = RT_SCHED;
572 571 $$->cmd_prop_nv_pairs = 0;
573 572 }
574 573 | INFO SHARES
575 574 {
576 575 if (($$ = alloc_cmd()) == NULL)
577 576 YYERROR;
578 577 cmd = $$;
579 578 $$->cmd_handler = &info_func;
580 579 $$->cmd_res_type = RT_SHARES;
581 580 $$->cmd_prop_nv_pairs = 0;
582 581 }
583 582 | INFO MAXLWPS
584 583 {
585 584 if (($$ = alloc_cmd()) == NULL)
586 585 YYERROR;
587 586 cmd = $$;
588 587 $$->cmd_handler = &info_func;
589 588 $$->cmd_res_type = RT_MAXLWPS;
590 589 $$->cmd_prop_nv_pairs = 0;
591 590 }
592 591 | INFO MAXPROCS
593 592 {
594 593 if (($$ = alloc_cmd()) == NULL)
595 594 YYERROR;
596 595 cmd = $$;
597 596 $$->cmd_handler = &info_func;
598 597 $$->cmd_res_type = RT_MAXPROCS;
599 598 $$->cmd_prop_nv_pairs = 0;
600 599 }
601 600 | INFO MAXSHMMEM
602 601 {
603 602 if (($$ = alloc_cmd()) == NULL)
604 603 YYERROR;
605 604 cmd = $$;
606 605 $$->cmd_handler = &info_func;
607 606 $$->cmd_res_type = RT_MAXSHMMEM;
608 607 $$->cmd_prop_nv_pairs = 0;
609 608 }
610 609 | INFO MAXSHMIDS
611 610 {
612 611 if (($$ = alloc_cmd()) == NULL)
613 612 YYERROR;
614 613 cmd = $$;
615 614 $$->cmd_handler = &info_func;
616 615 $$->cmd_res_type = RT_MAXSHMIDS;
617 616 $$->cmd_prop_nv_pairs = 0;
618 617 }
619 618 | INFO MAXMSGIDS
620 619 {
621 620 if (($$ = alloc_cmd()) == NULL)
622 621 YYERROR;
623 622 cmd = $$;
624 623 $$->cmd_handler = &info_func;
625 624 $$->cmd_res_type = RT_MAXMSGIDS;
626 625 $$->cmd_prop_nv_pairs = 0;
627 626 }
628 627 | INFO MAXSEMIDS
629 628 {
630 629 if (($$ = alloc_cmd()) == NULL)
631 630 YYERROR;
632 631 cmd = $$;
633 632 $$->cmd_handler = &info_func;
634 633 $$->cmd_res_type = RT_MAXSEMIDS;
635 634 $$->cmd_prop_nv_pairs = 0;
636 635 }
637 636 | INFO HOSTID
638 637 {
639 638 if (($$ = alloc_cmd()) == NULL)
640 639 YYERROR;
641 640 cmd = $$;
642 641 $$->cmd_handler = &info_func;
643 642 $$->cmd_res_type = RT_HOSTID;
644 643 $$->cmd_prop_nv_pairs = 0;
|
↓ open down ↓ |
484 lines elided |
↑ open up ↑ |
645 644 }
646 645 | INFO FS_ALLOWED
647 646 {
648 647 if (($$ = alloc_cmd()) == NULL)
649 648 YYERROR;
650 649 cmd = $$;
651 650 $$->cmd_handler = &info_func;
652 651 $$->cmd_res_type = RT_FS_ALLOWED;
653 652 $$->cmd_prop_nv_pairs = 0;
654 653 }
655 - | INFO UUID
656 - {
657 - if (($$ = alloc_cmd()) == NULL)
658 - YYERROR;
659 - cmd = $$;
660 - $$->cmd_handler = &info_func;
661 - $$->cmd_res_type = RT_UUID;
662 - $$->cmd_prop_nv_pairs = 0;
663 - }
664 - | INFO ZFSPRI
665 - {
666 - if (($$ = alloc_cmd()) == NULL)
667 - YYERROR;
668 - cmd = $$;
669 - $$->cmd_handler = &info_func;
670 - $$->cmd_res_type = RT_ZFSPRI;
671 - $$->cmd_prop_nv_pairs = 0;
672 - }
673 654 | INFO resource_type property_name EQUAL property_value
674 655 {
675 656 if (($$ = alloc_cmd()) == NULL)
676 657 YYERROR;
677 658 cmd = $$;
678 659 $$->cmd_handler = &info_func;
679 660 $$->cmd_res_type = $2;
680 661 $$->cmd_prop_nv_pairs = 1;
681 662 $$->cmd_prop_name[0] = $3;
682 663 $$->cmd_property_ptr[0] = &property[0];
683 664 }
684 665 | INFO resource_type property_name EQUAL property_value property_name EQUAL property_value
685 666 {
686 667 if (($$ = alloc_cmd()) == NULL)
687 668 YYERROR;
688 669 cmd = $$;
689 670 $$->cmd_handler = &info_func;
690 671 $$->cmd_res_type = $2;
691 672 $$->cmd_prop_nv_pairs = 2;
692 673 $$->cmd_prop_name[0] = $3;
693 674 $$->cmd_property_ptr[0] = &property[0];
694 675 $$->cmd_prop_name[1] = $6;
695 676 $$->cmd_property_ptr[1] = &property[1];
696 677 }
697 678 | INFO resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
698 679 {
699 680 if (($$ = alloc_cmd()) == NULL)
700 681 YYERROR;
701 682 cmd = $$;
702 683 $$->cmd_handler = &info_func;
703 684 $$->cmd_res_type = $2;
704 685 $$->cmd_prop_nv_pairs = 3;
705 686 $$->cmd_prop_name[0] = $3;
706 687 $$->cmd_property_ptr[0] = &property[0];
707 688 $$->cmd_prop_name[1] = $6;
708 689 $$->cmd_property_ptr[1] = &property[1];
709 690 $$->cmd_prop_name[2] = $9;
710 691 $$->cmd_property_ptr[2] = &property[2];
711 692 }
712 693
713 694 remove_command: REMOVE
714 695 {
715 696 short_usage(CMD_REMOVE);
716 697 (void) fputs("\n", stderr);
717 698 usage(B_FALSE, HELP_RES_PROPS);
718 699 YYERROR;
719 700 }
720 701 | REMOVE TOKEN
721 702 {
722 703 short_usage(CMD_REMOVE);
723 704 (void) fputs("\n", stderr);
724 705 usage(B_FALSE, HELP_RES_PROPS);
725 706 free(claim_token($2));
726 707 YYERROR;
727 708 }
728 709 | REMOVE resource_type
729 710 {
730 711 if (($$ = alloc_cmd()) == NULL)
731 712 YYERROR;
732 713 cmd = $$;
733 714 $$->cmd_handler = &remove_func;
734 715 $$->cmd_res_type = $2;
735 716 }
736 717 | REMOVE TOKEN resource_type
737 718 {
738 719 if (($$ = alloc_cmd()) == NULL)
739 720 YYERROR;
740 721 cmd = $$;
741 722 $$->cmd_handler = &remove_func;
742 723 $$->cmd_res_type = $3;
743 724 $$->cmd_argc = 1;
744 725 $$->cmd_argv[0] = claim_token($2);
745 726 $$->cmd_argv[1] = NULL;
746 727 }
|
↓ open down ↓ |
64 lines elided |
↑ open up ↑ |
747 728 | REMOVE property_name property_value
748 729 {
749 730 if (($$ = alloc_cmd()) == NULL)
750 731 YYERROR;
751 732 cmd = $$;
752 733 $$->cmd_handler = &remove_func;
753 734 $$->cmd_prop_nv_pairs = 1;
754 735 $$->cmd_prop_name[0] = $2;
755 736 $$->cmd_property_ptr[0] = &property[0];
756 737 }
757 - | REMOVE TOKEN property_name property_value
758 - {
759 - if (($$ = alloc_cmd()) == NULL)
760 - YYERROR;
761 - cmd = $$;
762 - $$->cmd_handler = &remove_func;
763 - $$->cmd_argc = 1;
764 - $$->cmd_argv[0] = claim_token($2);
765 - $$->cmd_argv[1] = NULL;
766 - $$->cmd_prop_nv_pairs = 1;
767 - $$->cmd_prop_name[0] = $3;
768 - $$->cmd_property_ptr[0] = &property[0];
769 - }
770 738 | REMOVE resource_type property_name EQUAL property_value
771 739 {
772 740 if (($$ = alloc_cmd()) == NULL)
773 741 YYERROR;
774 742 cmd = $$;
775 743 $$->cmd_handler = &remove_func;
776 744 $$->cmd_res_type = $2;
777 745 $$->cmd_prop_nv_pairs = 1;
778 746 $$->cmd_prop_name[0] = $3;
779 747 $$->cmd_property_ptr[0] = &property[0];
780 748 }
781 - | REMOVE TOKEN resource_type property_name EQUAL property_value
782 - {
783 - if (($$ = alloc_cmd()) == NULL)
784 - YYERROR;
785 - cmd = $$;
786 - $$->cmd_handler = &remove_func;
787 - $$->cmd_res_type = $3;
788 - $$->cmd_argc = 1;
789 - $$->cmd_argv[0] = claim_token($2);
790 - $$->cmd_argv[1] = NULL;
791 - $$->cmd_prop_nv_pairs = 1;
792 - $$->cmd_prop_name[0] = $4;
793 - $$->cmd_property_ptr[0] = &property[0];
794 - }
795 749 | REMOVE resource_type property_name EQUAL property_value property_name EQUAL property_value
796 750 {
797 751 if (($$ = alloc_cmd()) == NULL)
798 752 YYERROR;
799 753 cmd = $$;
800 754 $$->cmd_handler = &remove_func;
801 755 $$->cmd_res_type = $2;
802 756 $$->cmd_prop_nv_pairs = 2;
803 757 $$->cmd_prop_name[0] = $3;
804 758 $$->cmd_property_ptr[0] = &property[0];
805 759 $$->cmd_prop_name[1] = $6;
806 760 $$->cmd_property_ptr[1] = &property[1];
807 761 }
808 - | REMOVE TOKEN resource_type property_name EQUAL property_value property_name EQUAL property_value
809 - {
810 - if (($$ = alloc_cmd()) == NULL)
811 - YYERROR;
812 - cmd = $$;
813 - $$->cmd_handler = &remove_func;
814 - $$->cmd_res_type = $3;
815 - $$->cmd_argc = 1;
816 - $$->cmd_argv[0] = claim_token($2);
817 - $$->cmd_argv[1] = NULL;
818 - $$->cmd_prop_nv_pairs = 2;
819 - $$->cmd_prop_name[0] = $4;
820 - $$->cmd_property_ptr[0] = &property[0];
821 - $$->cmd_prop_name[1] = $7;
822 - $$->cmd_property_ptr[1] = &property[1];
823 - }
824 762 | REMOVE resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
825 763 {
826 764 if (($$ = alloc_cmd()) == NULL)
827 765 YYERROR;
828 766 cmd = $$;
829 767 $$->cmd_handler = &remove_func;
830 768 $$->cmd_res_type = $2;
831 769 $$->cmd_prop_nv_pairs = 3;
832 770 $$->cmd_prop_name[0] = $3;
833 771 $$->cmd_property_ptr[0] = &property[0];
834 772 $$->cmd_prop_name[1] = $6;
835 773 $$->cmd_property_ptr[1] = &property[1];
836 774 $$->cmd_prop_name[2] = $9;
837 775 $$->cmd_property_ptr[2] = &property[2];
838 776 }
839 - | REMOVE TOKEN resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
840 - {
841 - if (($$ = alloc_cmd()) == NULL)
842 - YYERROR;
843 - cmd = $$;
844 - $$->cmd_handler = &remove_func;
845 - $$->cmd_res_type = $3;
846 - $$->cmd_argc = 1;
847 - $$->cmd_argv[0] = claim_token($2);
848 - $$->cmd_argv[1] = NULL;
849 - $$->cmd_prop_nv_pairs = 3;
850 - $$->cmd_prop_name[0] = $4;
851 - $$->cmd_property_ptr[0] = &property[0];
852 - $$->cmd_prop_name[1] = $7;
853 - $$->cmd_property_ptr[1] = &property[1];
854 - $$->cmd_prop_name[2] = $10;
855 - $$->cmd_property_ptr[2] = &property[2];
856 - }
857 777
858 778 revert_command: REVERT
859 779 {
860 780 if (($$ = alloc_cmd()) == NULL)
861 781 YYERROR;
862 782 cmd = $$;
863 783 $$->cmd_handler = &revert_func;
864 784 $$->cmd_argc = 0;
865 785 $$->cmd_argv[0] = NULL;
866 786 }
867 787 | REVERT TOKEN
868 788 {
869 789 if (($$ = alloc_cmd()) == NULL)
870 790 YYERROR;
871 791 cmd = $$;
872 792 $$->cmd_handler = &revert_func;
873 793 $$->cmd_argc = 1;
874 794 $$->cmd_argv[0] = claim_token($2);
875 795 $$->cmd_argv[1] = NULL;
876 796 }
877 797
878 798 select_command: SELECT
879 799 {
880 800 short_usage(CMD_SELECT);
881 801 (void) fputs("\n", stderr);
882 802 usage(B_FALSE, HELP_RES_PROPS);
883 803 YYERROR;
884 804 }
885 805 | SELECT PSET
886 806 {
887 807 if (($$ = alloc_cmd()) == NULL)
888 808 YYERROR;
889 809 cmd = $$;
890 810 $$->cmd_handler = &select_func;
891 811 $$->cmd_res_type = RT_DCPU;
892 812 }
893 813 | SELECT PCAP
894 814 {
895 815 if (($$ = alloc_cmd()) == NULL)
896 816 YYERROR;
897 817 cmd = $$;
898 818 $$->cmd_handler = &select_func;
899 819 $$->cmd_res_type = RT_PCAP;
900 820 }
901 821 | SELECT MCAP
902 822 {
903 823 if (($$ = alloc_cmd()) == NULL)
904 824 YYERROR;
905 825 cmd = $$;
906 826 $$->cmd_handler = &select_func;
907 827 $$->cmd_res_type = RT_MCAP;
908 828 }
909 829 | SELECT resource_type
910 830 {
911 831 short_usage(CMD_SELECT);
912 832 YYERROR;
913 833 }
914 834 | SELECT resource_type property_name EQUAL property_value
915 835 {
916 836 if (($$ = alloc_cmd()) == NULL)
917 837 YYERROR;
918 838 cmd = $$;
919 839 $$->cmd_handler = &select_func;
920 840 $$->cmd_res_type = $2;
921 841 $$->cmd_prop_nv_pairs = 1;
922 842 $$->cmd_prop_name[0] = $3;
923 843 $$->cmd_property_ptr[0] = &property[0];
924 844 }
925 845 | SELECT resource_type property_name EQUAL property_value property_name EQUAL property_value
926 846 {
927 847 if (($$ = alloc_cmd()) == NULL)
928 848 YYERROR;
929 849 cmd = $$;
930 850 $$->cmd_handler = &select_func;
931 851 $$->cmd_res_type = $2;
932 852 $$->cmd_prop_nv_pairs = 2;
933 853 $$->cmd_prop_name[0] = $3;
934 854 $$->cmd_property_ptr[0] = &property[0];
935 855 $$->cmd_prop_name[1] = $6;
936 856 $$->cmd_property_ptr[1] = &property[1];
937 857 }
938 858 | SELECT resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
939 859 {
940 860 if (($$ = alloc_cmd()) == NULL)
941 861 YYERROR;
942 862 cmd = $$;
943 863 $$->cmd_handler = &select_func;
944 864 $$->cmd_res_type = $2;
945 865 $$->cmd_prop_nv_pairs = 3;
946 866 $$->cmd_prop_name[0] = $3;
947 867 $$->cmd_property_ptr[0] = &property[0];
948 868 $$->cmd_prop_name[1] = $6;
949 869 $$->cmd_property_ptr[1] = &property[1];
950 870 $$->cmd_prop_name[2] = $9;
951 871 $$->cmd_property_ptr[2] = &property[2];
952 872 }
953 873
954 874 set_command: SET
955 875 {
956 876 short_usage(CMD_SET);
957 877 (void) fputs("\n", stderr);
958 878 usage(B_FALSE, HELP_PROPS);
959 879 YYERROR;
960 880 }
961 881 | SET property_name EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
962 882 {
963 883 if (($$ = alloc_cmd()) == NULL)
964 884 YYERROR;
965 885 cmd = $$;
966 886 $$->cmd_handler = &set_func;
967 887 $$->cmd_prop_nv_pairs = 0;
968 888 $$->cmd_prop_name[0] = $2;
969 889 property[0].pv_type = PROP_VAL_LIST;
970 890 property[0].pv_list = NULL;
971 891 $$->cmd_property_ptr[0] = &property[0];
972 892 }
973 893 | SET property_name EQUAL property_value
974 894 {
975 895 if (($$ = alloc_cmd()) == NULL)
976 896 YYERROR;
977 897 cmd = $$;
978 898 $$->cmd_handler = &set_func;
979 899 $$->cmd_prop_nv_pairs = 1;
980 900 $$->cmd_prop_name[0] = $2;
981 901 $$->cmd_property_ptr[0] = &property[0];
982 902 }
983 903 | SET TOKEN ZONEPATH EQUAL property_value
984 904 {
985 905 if (($$ = alloc_cmd()) == NULL)
986 906 YYERROR;
987 907 cmd = $$;
988 908 $$->cmd_argc = 1;
989 909 $$->cmd_argv[0] = claim_token($2);
990 910 $$->cmd_argv[1] = NULL;
991 911 $$->cmd_handler = &set_func;
992 912 $$->cmd_prop_nv_pairs = 1;
993 913 $$->cmd_prop_name[0] = PT_ZONEPATH;
994 914 $$->cmd_property_ptr[0] = &property[0];
995 915 }
996 916
997 917 clear_command: CLEAR
998 918 {
999 919 short_usage(CMD_CLEAR);
1000 920 (void) fputs("\n", stderr);
1001 921 usage(B_FALSE, HELP_PROPS);
1002 922 YYERROR;
1003 923 }
1004 924 | CLEAR property_name
1005 925 {
1006 926 if (($$ = alloc_cmd()) == NULL)
1007 927 YYERROR;
1008 928 cmd = $$;
1009 929 $$->cmd_handler = &clear_func;
1010 930 $$->cmd_res_type = $2;
1011 931 }
1012 932
1013 933 verify_command: VERIFY
1014 934 {
1015 935 if (($$ = alloc_cmd()) == NULL)
1016 936 YYERROR;
1017 937 cmd = $$;
1018 938 $$->cmd_handler = &verify_func;
1019 939 $$->cmd_argc = 0;
1020 940 $$->cmd_argv[0] = NULL;
1021 941 }
1022 942 | VERIFY TOKEN
1023 943 {
1024 944 if (($$ = alloc_cmd()) == NULL)
1025 945 YYERROR;
1026 946 cmd = $$;
1027 947 $$->cmd_handler = &verify_func;
1028 948 $$->cmd_argc = 1;
1029 949 $$->cmd_argv[0] = claim_token($2);
1030 950 $$->cmd_argv[1] = NULL;
1031 951 }
1032 952
1033 953 resource_type: NET { $$ = RT_NET; }
1034 954 | FS { $$ = RT_FS; }
1035 955 | DEVICE { $$ = RT_DEVICE; }
1036 956 | RCTL { $$ = RT_RCTL; }
1037 957 | ATTR { $$ = RT_ATTR; }
1038 958 | DATASET { $$ = RT_DATASET; }
1039 959 | PSET { $$ = RT_DCPU; }
1040 960 | PCAP { $$ = RT_PCAP; }
1041 961 | MCAP { $$ = RT_MCAP; }
1042 962 | ADMIN { $$ = RT_ADMIN; }
1043 963
1044 964 property_name: SPECIAL { $$ = PT_SPECIAL; }
1045 965 | RAW { $$ = PT_RAW; }
1046 966 | DIR { $$ = PT_DIR; }
1047 967 | TYPE { $$ = PT_TYPE; }
1048 968 | OPTIONS { $$ = PT_OPTIONS; }
1049 969 | ZONENAME { $$ = PT_ZONENAME; }
1050 970 | ZONEPATH { $$ = PT_ZONEPATH; }
1051 971 | AUTOBOOT { $$ = PT_AUTOBOOT; }
1052 972 | IPTYPE { $$ = PT_IPTYPE; }
1053 973 | POOL { $$ = PT_POOL; }
1054 974 | LIMITPRIV { $$ = PT_LIMITPRIV; }
1055 975 | BOOTARGS { $$ = PT_BOOTARGS; }
1056 976 | ADDRESS { $$ = PT_ADDRESS; }
1057 977 | ALLOWED_ADDRESS { $$ = PT_ALLOWED_ADDRESS; }
1058 978 | PHYSICAL { $$ = PT_PHYSICAL; }
1059 979 | DEFROUTER { $$ = PT_DEFROUTER; }
1060 980 | MAC { $$ = PT_MAC; }
1061 981 | VLANID { $$ = PT_VLANID; }
1062 982 | GNIC { $$ = PT_GNIC; }
1063 983 | NPROP { $$ = PT_NPROP; }
1064 984 | NAME { $$ = PT_NAME; }
1065 985 | VALUE { $$ = PT_VALUE; }
1066 986 | MATCH { $$ = PT_MATCH; }
1067 987 | PRIV { $$ = PT_PRIV; }
1068 988 | LIMIT { $$ = PT_LIMIT; }
1069 989 | ACTION { $$ = PT_ACTION; }
1070 990 | BRAND { $$ = PT_BRAND; }
1071 991 | NCPUS { $$ = PT_NCPUS; }
1072 992 | LOCKED { $$ = PT_LOCKED; }
1073 993 | SWAP { $$ = PT_SWAP; }
1074 994 | IMPORTANCE { $$ = PT_IMPORTANCE; }
1075 995 | SHARES { $$ = PT_SHARES; }
1076 996 | MAXLWPS { $$ = PT_MAXLWPS; }
|
↓ open down ↓ |
210 lines elided |
↑ open up ↑ |
1077 997 | MAXPROCS { $$ = PT_MAXPROCS; }
1078 998 | MAXSHMMEM { $$ = PT_MAXSHMMEM; }
1079 999 | MAXSHMIDS { $$ = PT_MAXSHMIDS; }
1080 1000 | MAXMSGIDS { $$ = PT_MAXMSGIDS; }
1081 1001 | MAXSEMIDS { $$ = PT_MAXSEMIDS; }
1082 1002 | SCHED { $$ = PT_SCHED; }
1083 1003 | HOSTID { $$ = PT_HOSTID; }
1084 1004 | USER { $$ = PT_USER; }
1085 1005 | AUTHS { $$ = PT_AUTHS; }
1086 1006 | FS_ALLOWED { $$ = PT_FS_ALLOWED; }
1087 - | UUID { $$ = PT_UUID; }
1088 - | ZFSPRI { $$ = PT_ZFSPRI; }
1089 1007
1090 1008 /*
1091 1009 * The grammar builds data structures from the bottom up. Thus various
1092 1010 * strings are lexed into TOKENs or commands or resource or property values.
1093 1011 * Below is where the resource and property values are built up into more
1094 1012 * complex data structures.
1095 1013 *
1096 1014 * There are three kinds of properties: simple (single valued), complex
1097 1015 * (one or more name=value pairs) and list (concatenation of one or more
1098 1016 * simple or complex properties).
1099 1017 *
1100 1018 * So the property structure has a type which is one of these, and the
1101 1019 * corresponding _simple, _complex or _list is set to the corresponding
1102 1020 * lower-level data structure.
1103 1021 */
1104 1022
1105 1023 property_value: simple_prop_val
1106 1024 {
1107 1025 property[num_prop_vals].pv_type = PROP_VAL_SIMPLE;
1108 1026 property[num_prop_vals].pv_simple = $1;
1109 1027 if (list[num_prop_vals] != NULL) {
1110 1028 free_outer_list(list[num_prop_vals]);
1111 1029 list[num_prop_vals] = NULL;
1112 1030 }
1113 1031 num_prop_vals++;
1114 1032 }
1115 1033 | complex_prop_val
1116 1034 {
1117 1035 property[num_prop_vals].pv_type = PROP_VAL_COMPLEX;
1118 1036 property[num_prop_vals].pv_complex = complex;
1119 1037 if (list[num_prop_vals] != NULL) {
1120 1038 free_outer_list(list[num_prop_vals]);
1121 1039 list[num_prop_vals] = NULL;
1122 1040 }
1123 1041 num_prop_vals++;
1124 1042 }
1125 1043 | list_prop_val
1126 1044 {
1127 1045 property[num_prop_vals].pv_type = PROP_VAL_LIST;
1128 1046 property[num_prop_vals].pv_list = list[num_prop_vals];
1129 1047 num_prop_vals++;
1130 1048 }
1131 1049
1132 1050 /*
1133 1051 * One level lower, lists are made up of simple or complex values, so
1134 1052 * simple_prop_val and complex_prop_val fill in a list structure and
1135 1053 * insert it into the linked list which is built up. And because
1136 1054 * complex properties can have multiple name=value pairs, we keep
1137 1055 * track of them in another linked list.
1138 1056 *
1139 1057 * The complex and list structures for the linked lists are allocated
1140 1058 * below, and freed by recursive functions which are ultimately called
1141 1059 * by free_cmd(), which is called from the top-most "commands" part of
1142 1060 * the grammar.
1143 1061 *
1144 1062 * NOTE: simple_prop_val and complex_piece need reduction rules for
1145 1063 * property_name and resource_type so that the parser will accept property names
1146 1064 * and resource type names as property values.
1147 1065 */
1148 1066
1149 1067 simple_prop_val: TOKEN
1150 1068 {
1151 1069 $$ = simple_prop_val_func($1);
1152 1070 free(claim_token($1));
1153 1071 if ($$ == NULL)
1154 1072 YYERROR;
1155 1073 }
1156 1074 | resource_type
1157 1075 {
1158 1076 if (($$ = simple_prop_val_func(res_types[$1])) == NULL)
1159 1077 YYERROR;
1160 1078 }
1161 1079 | property_name
1162 1080 {
1163 1081 if (($$ = simple_prop_val_func(prop_types[$1])) == NULL)
1164 1082 YYERROR;
1165 1083 }
1166 1084
1167 1085 complex_prop_val: OPEN_PAREN complex_piece CLOSE_PAREN
1168 1086 {
1169 1087 if ((new_list = alloc_list()) == NULL)
1170 1088 YYERROR;
1171 1089 new_list->lp_simple = NULL;
1172 1090 new_list->lp_complex = complex;
1173 1091 new_list->lp_next = NULL;
1174 1092 if (list[num_prop_vals] == NULL) {
1175 1093 list[num_prop_vals] = new_list;
1176 1094 } else {
1177 1095 for (tmp_list = list[num_prop_vals]; tmp_list != NULL;
1178 1096 tmp_list = tmp_list->lp_next)
1179 1097 last = tmp_list;
1180 1098 last->lp_next = new_list;
1181 1099 }
1182 1100 }
1183 1101
1184 1102 complex_piece: property_name EQUAL TOKEN
1185 1103 {
1186 1104 $$ = complex_piece_func($1, $3, NULL);
1187 1105 free(claim_token($3));
1188 1106 if ($$ == NULL)
1189 1107 YYERROR;
1190 1108 }
1191 1109 | property_name EQUAL resource_type
1192 1110 {
1193 1111 if (($$ = complex_piece_func($1, res_types[$3], NULL)) == NULL)
1194 1112 YYERROR;
1195 1113 }
1196 1114 | property_name EQUAL property_name
1197 1115 {
1198 1116 if (($$ = complex_piece_func($1, prop_types[$3], NULL)) == NULL)
1199 1117 YYERROR;
1200 1118 }
1201 1119 | property_name EQUAL TOKEN COMMA complex_piece
1202 1120 {
1203 1121 $$ = complex_piece_func($1, $3, complex);
1204 1122 free(claim_token($3));
1205 1123 if ($$ == NULL)
1206 1124 YYERROR;
1207 1125 }
1208 1126 | property_name EQUAL resource_type COMMA complex_piece
1209 1127 {
1210 1128 if (($$ = complex_piece_func($1, res_types[$3], complex)) ==
1211 1129 NULL)
1212 1130 YYERROR;
1213 1131 }
1214 1132 | property_name EQUAL property_name COMMA complex_piece
1215 1133 {
1216 1134 if (($$ = complex_piece_func($1, prop_types[$3], complex)) ==
1217 1135 NULL)
1218 1136 YYERROR;
1219 1137 }
1220 1138
1221 1139 list_piece: simple_prop_val
1222 1140 | complex_prop_val
1223 1141 | simple_prop_val COMMA list_piece
1224 1142 | complex_prop_val COMMA list_piece
1225 1143
1226 1144 list_prop_val: OPEN_SQ_BRACKET list_piece CLOSE_SQ_BRACKET
1227 1145 %%
|
↓ open down ↓ |
129 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX