inf-parse.y revision 330897
1%{
2/*-
3 * SPDX-License-Identifier: BSD-4-Clause
4 *
5 * Copyright (c) 2003
6 *	Bill Paul <wpaul@windriver.com>.  All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 *    must display the following acknowledgement:
18 *	This product includes software developed by Bill Paul.
19 * 4. Neither the name of the author nor the names of any co-contributors
20 *    may be used to endorse or promote products derived from this software
21 *    without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: stable/11/usr.sbin/ndiscvt/inf-parse.y 330897 2018-03-14 03:19:51Z eadler $");
38
39#include <stdio.h>
40#include <sys/types.h>
41#include <sys/queue.h>
42
43#include "inf.h"
44
45extern int yylex (void);
46extern void yyerror(const char *);
47%}
48
49%token	EQUALS COMMA EOL
50%token	<str> SECTION
51%token	<str> STRING
52%token	<str> WORD
53
54%union {
55	char *str;
56}
57
58%%
59
60inf_file
61	: inf_list
62	|
63	;
64
65inf_list
66	: inf
67	| inf_list inf
68	;
69
70inf
71	: SECTION EOL
72		{ section_add($1); }
73	| WORD EQUALS assign EOL
74		{ assign_add($1); }
75	| WORD COMMA regkey EOL
76		{ regkey_add($1); }
77	| WORD EOL
78		{ define_add($1); }
79	| EOL
80	;
81
82assign
83	: WORD
84		{ push_word($1); }
85	| STRING
86		{ push_word($1); }
87	| WORD COMMA assign
88		{ push_word($1); }
89	| STRING COMMA assign
90		{ push_word($1); }
91	| COMMA assign
92		{ push_word(NULL); }
93	| COMMA
94		{ push_word(NULL); }
95	|
96	;
97
98regkey
99	: WORD
100		{ push_word($1); }
101	| STRING
102		{ push_word($1); }
103	| WORD COMMA regkey
104		{ push_word($1); }
105	| STRING COMMA regkey
106		{ push_word($1); }
107	| COMMA regkey
108		{ push_word(NULL); }
109	| COMMA
110		{ push_word(NULL); }
111	;
112%%
113