1 /* $NetBSD: parse.y,v 1.16 2012/03/06 16:55:18 mbalmer Exp $ */
4 * Copyright 1997 Piermont Information Systems Inc.
7 * Written by Philip A. Nelson for Piermont Information Systems Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of Piermont Information Systems Inc. may not be used to endorse
18 * or promote products derived from this software without specific prior
21 * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
22 * AND 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 PIERMONT INFORMATION SYSTEMS INC. BE
25 * 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.
41 static id_rec
*cur_menu
;
42 static optn_info
*cur_optn
;
49 optn_info
*optn_value
;
54 %token
<i_value
> X Y W H NO BOX SUB HELP MENU NEXT EXIT ACTION ENDWIN OPTION
55 %token
<i_value
> TITLE DEFAULT DISPLAY ERROR EXITSTRING ALLOW DYNAMIC MENUS
56 SCROLLABLE SHORTCUT CLEAR MESSAGES ALWAYS SCROLL
57 %token
<s_value
> STRING NAME CODE INT_CONST CHAR_CONST
59 %type
<s_value
> init_code system helpstr text
60 %type
<optn_value
> option option_list
61 %type
<i_value
> act_opt
62 %type
<a_value
> action exitact
68 system
: init_code menu_list
75 init_code
: /* empty */ { $$
= ""; }
79 menu_list
: /* empty */
81 | menu_list default_def
82 | menu_list initerror_def
83 | menu_list dynamic_def
84 | menu_list msgxlat_def
87 dynamic_def
: ALLOW DYNAMIC MENUS
';'
90 msgxlat_def
: ALLOW DYNAMIC MESSAGES
';'
93 initerror_def
: ERROR action
';'
97 { cur_menu
= &default_menu
; }
101 { cur_menu
= get_menu
($2);
102 if
(cur_menu
->info
!= NULL
)
103 yyerror ("Menu %s defined twice", $2);
106 (menu_info
*) malloc
(sizeof
(menu_info
));
107 *(cur_menu
->info
) = default_info
;
110 opts
";" dispact option_list exitact helpstr
112 cur_menu
->info
->optns
= NULL
;
116 t
->next
= cur_menu
->info
->optns
;
117 cur_menu
->info
->optns
= t
;
118 cur_menu
->info
->numopt
++;
133 opt
: NO EXIT
{ cur_menu
->info
->mopt |
= MC_NOEXITOPT
; }
134 | EXIT
{ cur_menu
->info
->mopt
&= ~MC_NOEXITOPT
; }
135 | NO BOX
{ cur_menu
->info
->mopt |
= MC_NOBOX
; }
136 | BOX
{ cur_menu
->info
->mopt
&= ~MC_NOBOX
; }
137 | NO SCROLLABLE
{ cur_menu
->info
->mopt
&= ~MC_SCROLL
; }
138 | SCROLLABLE
{ cur_menu
->info
->mopt |
= MC_SCROLL
; }
139 | NO SHORTCUT
{ cur_menu
->info
->mopt |
= MC_NOSHORTCUT
; }
140 | SHORTCUT
{ cur_menu
->info
->mopt
&= ~MC_NOSHORTCUT
; }
141 | NO CLEAR
{ cur_menu
->info
->mopt |
= MC_NOCLEAR
; }
142 | CLEAR
{ cur_menu
->info
->mopt
&= ~MC_NOCLEAR
; }
143 | NO DEFAULT EXIT
{ cur_menu
->info
->mopt
&= ~MC_DFLTEXIT
; }
144 | DEFAULT EXIT
{ cur_menu
->info
->mopt |
= MC_DFLTEXIT
; }
145 | NO ALWAYS SCROLL
{ cur_menu
->info
->mopt
&= ~MC_ALWAYS_SCROLL
; }
146 | ALWAYS SCROLL
{ cur_menu
->info
->mopt |
= MC_ALWAYS_SCROLL
; }
147 | NO SUB MENU
{ cur_menu
->info
->mopt
&= ~MC_SUBMENU
; }
148 | SUB MENU
{ cur_menu
->info
->mopt |
= MC_SUBMENU
; }
149 | X
"=" INT_CONST
{ cur_menu
->info
->x
= atoi
($3); }
150 | Y
"=" INT_CONST
{ cur_menu
->info
->y
= atoi
($3); }
151 | W
"=" INT_CONST
{ cur_menu
->info
->w
= atoi
($3); }
152 | H
"=" INT_CONST
{ cur_menu
->info
->h
= atoi
($3); }
153 | TITLE text
{ cur_menu
->info
->title
= $2; }
154 | EXITSTRING text
{ cur_menu
->info
->exitstr
= $2;
155 cur_menu
->info
->mopt
&= ~MC_NOEXITOPT
; }
159 | option_list option
{ $2->next
= $1; $$
= $2; }
163 { cur_optn
= (optn_info
*) malloc
(sizeof
(optn_info
));
165 cur_optn
->name
= NULL
;
166 cur_optn
->name_is_code
= FALSE
;
167 cur_optn
->issub
= FALSE
;
168 cur_optn
->doexit
= FALSE
;
169 cur_optn
->optact.code
= "";
170 cur_optn
->optact.endwin
= FALSE
;
171 cur_optn
->next
= NULL
;
178 option_legend
: text
{ cur_optn
->name
= $1; }
179 | CODE
{ cur_optn
->name
= $1; cur_optn
->name_is_code
= TRUE
;}
185 elem
: NEXT MENU NAME
186 { id_rec
*t
= get_menu
($3);
187 if
(cur_optn
->menu
!= -1)
188 yyerror ("Double sub/next menu definition");
190 cur_optn
->menu
= t
->menu_no
;
194 { id_rec
*t
= get_menu
($3);
195 if
(cur_optn
->menu
!= -1)
196 yyerror ("Double sub/next menu definition");
198 cur_optn
->menu
= t
->menu_no
;
199 cur_optn
->issub
= TRUE
;
202 | action
{ cur_optn
->optact
= $1; }
203 | EXIT
{ cur_optn
->doexit
= TRUE
; }
206 action
: ACTION act_opt CODE
212 act_opt
: /* empty */ { $$
= 0; }
213 |
"(" ENDWIN
")" { $$
= 1; }
216 dispact
: /* empty */ { cur_menu
->info
->postact.code
= ""; }
217 | DISPLAY action
";" { cur_menu
->info
->postact
= $2; }
221 exitact
: /* empty */ { cur_menu
->info
->exitact.code
= ""; }
222 | EXIT action
";" { cur_menu
->info
->exitact
= $2; }
225 helpstr
: /* empty */ { cur_menu
->info
->helpstr
= NULL
; }
226 | HELP CODE
";" { asprintf
(&cur_menu
->info
->helpstr
, "\"%s\"", $2); }
227 | HELP text
";" { cur_menu
->info
->helpstr
= $2; }