parse.y revision 105573
1%{ 2/*- 3 * DEVD (Device action daemon) 4 * 5 * Copyright (c) 2002 M. Warner Losh <imp@freebsd.org>. 6 * 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 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $FreeBSD: head/sbin/devd/parse.y 105573 2002-10-20 22:15:17Z imp $ 30 */ 31 32#include "devd.h" 33#include <stdio.h> 34 35%} 36 37%union { 38 char *str; 39 int i; 40} 41 42%token SEMICOLON BEGINBLOCK ENDBLOCK COMMA 43%token <i> NUMBER 44%token <str> STRING 45%token <str> ID 46%token OPTIONS SET DIRECTORY PID_FILE DEVICE_NAME ACTION MATCH 47%token ATTACH DETACH NOMATCH 48 49%type <str> id 50%type <i> number 51%type <str> string 52 53%% 54 55config_file 56 : config_list 57 ; 58 59config_list 60 : config 61 | config_list config 62 ; 63 64config 65 : option_block 66 | attach_block 67 | detach_block 68 | nomatch_block 69 ; 70 71option_block 72 : OPTIONS BEGINBLOCK options ENDBLOCK SEMICOLON 73 ; 74 75options 76 : option 77 | options option 78 79option 80 : directory_option 81 | pid_file_option 82 | set_option 83 ; 84 85directory_option 86 : DIRECTORY string SEMICOLON { add_directory($2); } 87 ; 88 89pid_file_option 90 : PID_FILE string SEMICOLON 91 ; 92 93set_option 94 : SET id string SEMICOLON 95 ; 96 97attach_block 98 : ATTACH number BEGINBLOCK match_or_action_list ENDBLOCK SEMICOLON 99 ; 100 101detach_block 102 : DETACH number BEGINBLOCK match_or_action_list ENDBLOCK SEMICOLON 103 ; 104 105nomatch_block 106 : NOMATCH number BEGINBLOCK match_or_action_list ENDBLOCK SEMICOLON 107 ; 108 109match_or_action_list 110 : match_or_action 111 | match_or_action_list match_or_action 112 ; 113 114match_or_action 115 : match 116 | action 117 ; 118 119match 120 : MATCH string string SEMICOLON 121 | DEVICE_NAME string SEMICOLON 122 ; 123 124action 125 : ACTION string SEMICOLON 126 ; 127 128number 129 : NUMBER { $$ = $1; } 130 131string 132 : STRING { $$ = $1; } 133 134id 135 : ID { $$ = $1; } 136 137%% 138