Release 980301
[wine] / programs / winhelp / macro.yacc.y
1 %{
2 /*
3  * Help Viewer
4  *
5  * Copyright 1996 Ulrich Schmid
6  */
7
8 #include "macro.h"
9
10 static int   skip = 0;
11 static LPSTR filename;
12 static LPSTR windowname;
13
14 %}
15 %union
16   {
17     BOOL    bool;
18     LONG    integer;
19     LPSTR   string;
20     BOOL    (*bool_function_void)(VOID);
21     BOOL    (*bool_function_string)(LPCSTR);
22     VOID    (*void_function_void)(VOID);
23     VOID    (*void_function_uint)(LONG);
24     VOID    (*void_function_string)(LPCSTR);
25     VOID    (*void_function_2int_3uint_string)(LONG,LONG,LONG,LONG,LONG,LPCSTR);
26     VOID    (*void_function_2string)(LPCSTR,LPCSTR);
27     VOID    (*void_function_2string_2uint_2string)(LPCSTR,LPCSTR,LONG,LONG,LPCSTR,LPCSTR);
28     VOID    (*void_function_2string_uint)(LPCSTR,LPCSTR,LONG);
29     VOID    (*void_function_2string_uint_string)(LPCSTR,LPCSTR,LONG,LPCSTR);
30     VOID    (*void_function_2string_wparam_lparam_string)(LPCSTR,LPCSTR,WPARAM,LPARAM,LPCSTR);
31     VOID    (*void_function_2uint)(LONG,LONG);
32     VOID    (*void_function_2uint_string)(LONG,LONG,LPCSTR);
33     VOID    (*void_function_3string)(LPCSTR,LPCSTR,LPCSTR);
34     VOID    (*void_function_3string_2uint)(LPCSTR,LPCSTR,LPCSTR,LONG,LONG);
35     VOID    (*void_function_3uint)(LONG,LONG,LONG);
36     VOID    (*void_function_4string)(LPCSTR,LPCSTR,LPCSTR,LPCSTR);
37     VOID    (*void_function_4string_2uint)(LPCSTR,LPCSTR,LPCSTR,LPCSTR,LONG,LONG);
38     VOID    (*void_function_4string_uint)(LPCSTR,LPCSTR,LPCSTR,LPCSTR,LONG);
39     VOID    (*void_function_string_uint)(LPCSTR,LONG);
40     VOID    (*void_function_string_uint_2string)(LPCSTR,LONG,LPCSTR,LPCSTR);
41     VOID    (*void_function_string_uint_string)(LPCSTR,LONG,LPCSTR);
42     VOID    (*void_function_string_wparam_lparam)(LPCSTR,WPARAM,LPARAM);
43   }
44 %token                                                  NOT
45 %token                                                  IF_THEN
46 %token                                                  IF_THEN_ELSE
47 %token <string>                                         tSTRING
48 %token <integer>                                        INTEGER
49 %token <bool_function_string>                           BOOL_FUNCTION_STRING
50 %token <bool_function_void>                             BOOL_FUNCTION_VOID
51 %token <void_function_2int_3uint_string>                VOID_FUNCTION_2INT_3UINT_STRING
52 %token <void_function_2string>                          VOID_FUNCTION_2STRING
53 %token <void_function_2string_2uint_2string>            VOID_FUNCTION_2STRING_2UINT_2STRING
54 %token <void_function_2string_uint>                     VOID_FUNCTION_2STRING_UINT
55 %token <void_function_2string_uint_string>              VOID_FUNCTION_2STRING_UINT_STRING
56 %token <void_function_2string_wparam_lparam_string>     VOID_FUNCTION_2STRING_WPARAM_LPARAM_STRING
57 %token <void_function_2uint>                            VOID_FUNCTION_2UINT
58 %token <void_function_2uint_string>                     VOID_FUNCTION_2UINT_STRING
59 %token <void_function_3string>                          VOID_FUNCTION_3STRING
60 %token <void_function_3string_2uint>                    VOID_FUNCTION_3STRING_2UINT
61 %token <void_function_3uint>                            VOID_FUNCTION_3UINT
62 %token <void_function_4string>                          VOID_FUNCTION_4STRING
63 %token <void_function_4string_2uint>                    VOID_FUNCTION_4STRING_2UINT
64 %token <void_function_4string_uint>                     VOID_FUNCTION_4STRING_UINT
65 %token <void_function_string>                           VOID_FUNCTION_STRING
66 %token <void_function_string_uint>                      VOID_FUNCTION_STRING_UINT
67 %token <void_function_string_uint_2string>              VOID_FUNCTION_STRING_UINT_2STRING
68 %token <void_function_string_uint_string>               VOID_FUNCTION_STRING_UINT_STRING
69 %token <void_function_string_wparam_lparam>             VOID_FUNCTION_STRING_WPARAM_LPARAM
70 %token <void_function_uint>                             VOID_FUNCTION_UINT
71 %token <void_function_void>                             VOID_FUNCTION_VOID
72 %token <void_function_2string>                          VOID_FUNCTION_FILE_WIN
73 %token <void_function_3string>                          VOID_FUNCTION_FILE_WIN_STRING
74 %token <void_function_2string_uint>                     VOID_FUNCTION_FILE_WIN_UINT
75 %type  <bool> bool_macro
76 %%
77
78 macrostring:    macro |
79                 macro macrosep macrostring ;
80
81 macrosep:       ';' |
82                 ':' ;
83
84 macro:          /* Empty */ |
85                 IF_THEN      '(' bool_macro ','  {if (! $3) skip++;}
86                                  macrostring ')' {if (! $3) skip--;} |
87                 IF_THEN_ELSE '(' bool_macro ','  {if (! $3) skip++;}
88                                  macrostring ',' {if (! $3) skip--; else skip++;}
89                                  macrostring ')' {if (  $3) skip--;} |
90                 VOID_FUNCTION_VOID
91                         '(' ')'
92                         {if (! skip) (*$1)();} |
93                 VOID_FUNCTION_STRING
94                         '(' tSTRING ')'
95                         {if (! skip) (*$1)($3);} |
96                 VOID_FUNCTION_2STRING
97                         '(' tSTRING ',' tSTRING ')'
98                         {if (! skip) (*$1)($3, $5);} |
99                 VOID_FUNCTION_2STRING_UINT
100                         '(' tSTRING ',' tSTRING ',' INTEGER ')'
101                         {if (! skip) (*$1)($3, $5, $7);} |
102                 VOID_FUNCTION_2STRING_UINT_STRING
103                         '(' tSTRING ',' tSTRING ',' INTEGER ',' tSTRING ')'
104                         {if (! skip) (*$1)($3, $5, $7, $9);} |
105                 VOID_FUNCTION_2STRING_2UINT_2STRING
106                         '(' tSTRING ',' tSTRING ',' INTEGER ',' INTEGER ',' tSTRING ',' tSTRING ')'
107                         {if (! skip) (*$1)($3, $5, $7, $9, $11, $13);} |
108                 VOID_FUNCTION_2STRING_WPARAM_LPARAM_STRING
109                         '(' tSTRING ',' tSTRING ',' INTEGER ',' INTEGER ',' tSTRING ')'
110                         {if (! skip) (*$1)($3, $5, $7, $9, $11);} |
111                 VOID_FUNCTION_3STRING
112                         '(' tSTRING ',' tSTRING ',' tSTRING ')'
113                         {if (! skip) (*$1)($3, $5, $7);} |
114                 VOID_FUNCTION_3STRING_2UINT
115                         '(' tSTRING ',' tSTRING ',' tSTRING ',' INTEGER ',' INTEGER ')'
116                         {if (! skip) (*$1)($3, $5, $7, $9, $11);} |
117                 VOID_FUNCTION_4STRING
118                         '(' tSTRING ',' tSTRING ',' tSTRING ',' tSTRING ')'
119                         {if (! skip) (*$1)($3, $5, $7, $9);} |
120                 VOID_FUNCTION_4STRING_UINT
121                         '(' tSTRING ',' tSTRING ',' tSTRING ',' tSTRING ',' INTEGER')'
122                         {if (! skip) (*$1)($3, $5, $7, $9, $11);} |
123                 VOID_FUNCTION_4STRING_2UINT
124                         '(' tSTRING ',' tSTRING ',' tSTRING ',' tSTRING ',' INTEGER ',' INTEGER')'
125                         {if (! skip) (*$1)($3, $5, $7, $9, $11, $13);} |
126                 VOID_FUNCTION_STRING_UINT
127                         '(' tSTRING ',' INTEGER ')'
128                         {if (! skip) (*$1)($3, $5);} |
129                 VOID_FUNCTION_STRING_UINT_STRING
130                         '(' tSTRING ',' INTEGER ',' tSTRING ')'
131                         {if (! skip) (*$1)($3, $5, $7);} |
132                 VOID_FUNCTION_STRING_UINT_2STRING
133                         '(' tSTRING ',' INTEGER ',' tSTRING ',' tSTRING ')'
134                         {if (! skip) (*$1)($3, $5, $7, $9);} |
135                 VOID_FUNCTION_STRING_WPARAM_LPARAM
136                         '(' tSTRING ',' INTEGER ',' INTEGER ')'
137                         {if (! skip) (*$1)($3, $5, $7);} |
138                 VOID_FUNCTION_UINT
139                         '(' INTEGER ')'
140                         {if (! skip) (*$1)($3);} |
141                 VOID_FUNCTION_2UINT
142                         '(' INTEGER ',' INTEGER ')'
143                         {if (! skip) (*$1)($3, $5);} |
144                 VOID_FUNCTION_2UINT_STRING
145                         '(' INTEGER ',' INTEGER ',' tSTRING ')'
146                         {if (! skip) (*$1)($3, $5, $7);} |
147                 VOID_FUNCTION_3UINT
148                         '(' INTEGER ',' INTEGER ',' INTEGER ')'
149                         {if (! skip) (*$1)($3, $5, $7);} |
150                 VOID_FUNCTION_2INT_3UINT_STRING
151                         '(' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ',' tSTRING ')'
152                         {if (! skip) (*$1)($3, $5, $7, $9, $11, $13);} |
153                 VOID_FUNCTION_FILE_WIN
154                         '(' file_win ')'
155                         {if (! skip) (*$1)(filename, windowname);} |
156                 VOID_FUNCTION_FILE_WIN_STRING
157                         '(' file_win ',' tSTRING ')'
158                         {if (! skip) (*$1)(filename, windowname, $5);} |
159                 VOID_FUNCTION_FILE_WIN_UINT
160                         '(' file_win ',' INTEGER ')'
161                         {if (! skip) (*$1)(filename, windowname, $5);} ;
162
163 file_win:       tSTRING
164                 {
165                   filename = windowname = $1;
166                   while (*windowname && *windowname != '>') windowname++;
167                   if (*windowname) *windowname++ = 0;
168                 } ;
169
170 bool_macro:     NOT '(' bool_macro ')' {$$ = ! $3;} |
171                 tSTRING {$$ = MACRO_IsMark($1);} |
172                 BOOL_FUNCTION_VOID '(' ')' {$$ = (*$1)();} |
173                 BOOL_FUNCTION_STRING '(' tSTRING ')' {$$ = (*$1)($3);} ;