Add patch that contain Mali fixes.
[deb_xorg-server.git] / config / parser.y
... / ...
CommitLineData
1/* $XFree86$ */
2/*
3 * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
4 *
5 * All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation on the rights to use, copy, modify, merge,
11 * publish, distribute, sublicense, and/or sell copies of the Software,
12 * and to permit persons to whom the Software is furnished to do so,
13 * subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial
17 * portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
23 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * SOFTWARE.
27 */
28
29/*
30 * Authors:
31 * Rickard E. (Rik) Faith <faith@redhat.com>
32 *
33 */
34
35%{
36#ifdef HAVE_DMX_CONFIG_H
37#include <dmx-config.h>
38#endif
39
40#include "dmxparse.h"
41#include <string.h>
42#include <stdlib.h>
43#define YYDEBUG 1
44#define YYERROR_VERBOSE
45#define YY_USE_PROTOS
46
47DMXConfigEntryPtr dmxConfigEntry = NULL;
48#define APPEND(type, h, t) \
49{ \
50 type pt; \
51 for (pt = h; pt->next; pt = pt->next); \
52 pt->next = t; \
53}
54%}
55
56%union {
57 DMXConfigTokenPtr token;
58 DMXConfigStringPtr string;
59 DMXConfigNumberPtr number;
60 DMXConfigPairPtr pair;
61 DMXConfigFullDimPtr fdim;
62 DMXConfigPartDimPtr pdim;
63 DMXConfigDisplayPtr display;
64 DMXConfigWallPtr wall;
65 DMXConfigOptionPtr option;
66 DMXConfigParamPtr param;
67 DMXConfigCommentPtr comment;
68 DMXConfigSubPtr subentry;
69 DMXConfigVirtualPtr virtual;
70 DMXConfigEntryPtr entry;
71}
72
73 /* Terminals */
74%token <token> '{' '}' ';' '/' T_VIRTUAL T_DISPLAY T_WALL T_OPTION T_PARAM
75%token <string> T_STRING
76%token <pair> T_DIMENSION T_OFFSET T_ORIGIN
77%token <comment> T_COMMENT T_LINE_COMMENT
78
79 /* Non-termials */
80%type <token> Display Wall Terminal Open Close
81%type <string> NameList Name
82%type <pair> Dimension Offset Origin
83%type <pdim> PartialDim
84%type <fdim> FullDim
85%type <display> DisplayEntry
86%type <option> OptionEntry
87%type <param> ParamEntry ParamList Param
88%type <subentry> SubList Sub
89%type <wall> WallEntry
90%type <virtual> Virtual
91%type <entry> Program EntryList Entry
92
93%%
94
95Program : EntryList { dmxConfigEntry = $1; }
96 ;
97
98EntryList : Entry
99 | EntryList Entry { APPEND(DMXConfigEntryPtr,$1,$2); $$ = $1; }
100 ;
101
102Entry : Virtual { $$ = dmxConfigEntryVirtual($1); }
103 | T_LINE_COMMENT { $$ = dmxConfigEntryComment($1); }
104 ;
105
106Virtual : T_VIRTUAL Open SubList Close
107 { $$ = dmxConfigCreateVirtual($1, NULL, NULL, $2, $3, $4); }
108 | T_VIRTUAL Dimension Open SubList Close
109 { $$ = dmxConfigCreateVirtual($1, NULL, $2, $3, $4, $5); }
110 | T_VIRTUAL Name Open SubList Close
111 { $$ = dmxConfigCreateVirtual($1, $2, NULL, $3, $4, $5); }
112 | T_VIRTUAL Name Dimension Open SubList Close
113 { $$ = dmxConfigCreateVirtual($1, $2, $3, $4, $5, $6 ); }
114 ;
115
116SubList : Sub
117 | SubList Sub { APPEND(DMXConfigSubPtr,$1,$2); $$ = $1; }
118 ;
119
120Sub : T_LINE_COMMENT { $$ = dmxConfigSubComment($1); }
121 | DisplayEntry { $$ = dmxConfigSubDisplay($1); }
122 | WallEntry { $$ = dmxConfigSubWall($1); }
123 | OptionEntry { $$ = dmxConfigSubOption($1); }
124 | ParamEntry { $$ = dmxConfigSubParam($1); }
125 ;
126
127OptionEntry : T_OPTION NameList Terminal
128 { $$ = dmxConfigCreateOption($1, $2, $3); }
129 ;
130
131ParamEntry : T_PARAM NameList Terminal
132 { $$ = dmxConfigCreateParam($1, NULL, $2, NULL, $3); }
133 | T_PARAM Open ParamList Close
134 { $$ = dmxConfigCreateParam($1, $2, NULL, $4, NULL);
135 $$->next = $3;
136 }
137 ;
138
139ParamList : Param
140 | ParamList Param { APPEND(DMXConfigParamPtr,$1,$2); $$ = $1; }
141 ;
142
143Param : NameList Terminal
144 { $$ = dmxConfigCreateParam(NULL, NULL, $1, NULL, $2); }
145 ;
146
147PartialDim : Dimension Offset
148 { $$ = dmxConfigCreatePartDim($1, $2); }
149 | Dimension
150 { $$ = dmxConfigCreatePartDim($1, NULL); }
151 | Offset
152 { $$ = dmxConfigCreatePartDim(NULL, $1); }
153 ;
154
155FullDim : PartialDim '/' PartialDim
156 { $$ = dmxConfigCreateFullDim($1, $3); }
157 | '/' PartialDim
158 { $$ = dmxConfigCreateFullDim(NULL, $2); }
159 | PartialDim
160 { $$ = dmxConfigCreateFullDim($1, NULL); }
161 ;
162
163DisplayEntry : Display Name FullDim Origin Terminal
164 { $$ = dmxConfigCreateDisplay($1, $2, $3, $4, $5); }
165 | Display FullDim Origin Terminal
166 { $$ = dmxConfigCreateDisplay($1, NULL, $2, $3, $4); }
167 | Display Name Origin Terminal
168 { $$ = dmxConfigCreateDisplay($1, $2, NULL, $3, $4); }
169
170 | Display Name FullDim Terminal
171 { $$ = dmxConfigCreateDisplay($1, $2, $3, NULL, $4); }
172 | Display FullDim Terminal
173 { $$ = dmxConfigCreateDisplay($1, NULL, $2, NULL, $3); }
174 | Display Name Terminal
175 { $$ = dmxConfigCreateDisplay($1, $2, NULL, NULL, $3); }
176 | Display Terminal
177 { $$ = dmxConfigCreateDisplay($1, NULL, NULL, NULL, $2); }
178 ;
179
180WallEntry : Wall Dimension Dimension NameList Terminal
181 { $$ = dmxConfigCreateWall($1, $2, $3, $4, $5); }
182 | Wall Dimension NameList Terminal
183 { $$ = dmxConfigCreateWall($1, $2, NULL, $3, $4); }
184 | Wall NameList Terminal
185 { $$ = dmxConfigCreateWall($1, NULL, NULL, $2, $3); }
186 ;
187
188Display : T_DISPLAY
189 | T_DISPLAY T_COMMENT { $$ = $1; $$->comment = $2->comment; }
190 ;
191
192Name : T_STRING
193 | T_STRING T_COMMENT { $$ = $1; $$->comment = $2->comment; }
194 ;
195
196Dimension : T_DIMENSION
197 | T_DIMENSION T_COMMENT { $$ = $1; $$->comment = $2->comment; }
198 ;
199
200Offset : T_OFFSET
201 | T_OFFSET T_COMMENT { $$ = $1; $$->comment = $2->comment; }
202 ;
203
204Origin : T_ORIGIN
205 | T_ORIGIN T_COMMENT { $$ = $1; $$->comment = $2->comment; }
206 ;
207
208Terminal : ';'
209 | ';' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
210 ;
211
212Open : '{'
213 | '{' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
214 ;
215
216Close : '}'
217 | '}' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
218 ;
219
220Wall : T_WALL
221 | T_WALL T_COMMENT { $$ = $1; $$->comment = $2->comment; }
222 ;
223
224NameList : Name
225 | NameList Name { APPEND(DMXConfigStringPtr, $1, $2); $$ = $1; }
226 ;