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