3 * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
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:
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.
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
31 * Rickard E. (Rik) Faith <faith@redhat.com>
36 #ifdef HAVE_DMX_CONFIG_H
37 #include <dmx-config.h>
44 #define YYERROR_VERBOSE
47 DMXConfigEntryPtr dmxConfigEntry = NULL;
48 #define APPEND(type, h, t) \
51 for (pt = h; pt->next; pt = pt->next); \
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;
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
80 %type <token> Display Wall Terminal Open Close
81 %type <string> NameList Name
82 %type <pair> Dimension Offset Origin
83 %type <pdim> PartialDim
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
95 Program : EntryList { dmxConfigEntry = $1; }
99 | EntryList Entry { APPEND(DMXConfigEntryPtr,$1,$2); $$ = $1; }
102 Entry : Virtual { $$ = dmxConfigEntryVirtual($1); }
103 | T_LINE_COMMENT { $$ = dmxConfigEntryComment($1); }
106 Virtual : 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 ); }
117 | SubList Sub { APPEND(DMXConfigSubPtr,$1,$2); $$ = $1; }
120 Sub : T_LINE_COMMENT { $$ = dmxConfigSubComment($1); }
121 | DisplayEntry { $$ = dmxConfigSubDisplay($1); }
122 | WallEntry { $$ = dmxConfigSubWall($1); }
123 | OptionEntry { $$ = dmxConfigSubOption($1); }
124 | ParamEntry { $$ = dmxConfigSubParam($1); }
127 OptionEntry : T_OPTION NameList Terminal
128 { $$ = dmxConfigCreateOption($1, $2, $3); }
131 ParamEntry : T_PARAM NameList Terminal
132 { $$ = dmxConfigCreateParam($1, NULL, $2, NULL, $3); }
133 | T_PARAM Open ParamList Close
134 { $$ = dmxConfigCreateParam($1, $2, NULL, $4, NULL);
140 | ParamList Param { APPEND(DMXConfigParamPtr,$1,$2); $$ = $1; }
143 Param : NameList Terminal
144 { $$ = dmxConfigCreateParam(NULL, NULL, $1, NULL, $2); }
147 PartialDim : Dimension Offset
148 { $$ = dmxConfigCreatePartDim($1, $2); }
150 { $$ = dmxConfigCreatePartDim($1, NULL); }
152 { $$ = dmxConfigCreatePartDim(NULL, $1); }
155 FullDim : PartialDim '/' PartialDim
156 { $$ = dmxConfigCreateFullDim($1, $3); }
158 { $$ = dmxConfigCreateFullDim(NULL, $2); }
160 { $$ = dmxConfigCreateFullDim($1, NULL); }
163 DisplayEntry : 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); }
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); }
177 { $$ = dmxConfigCreateDisplay($1, NULL, NULL, NULL, $2); }
180 WallEntry : 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); }
189 | T_DISPLAY T_COMMENT { $$ = $1; $$->comment = $2->comment; }
193 | T_STRING T_COMMENT { $$ = $1; $$->comment = $2->comment; }
196 Dimension : T_DIMENSION
197 | T_DIMENSION T_COMMENT { $$ = $1; $$->comment = $2->comment; }
201 | T_OFFSET T_COMMENT { $$ = $1; $$->comment = $2->comment; }
205 | T_ORIGIN T_COMMENT { $$ = $1; $$->comment = $2->comment; }
209 | ';' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
213 | '{' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
217 | '}' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
221 | T_WALL T_COMMENT { $$ = $1; $$->comment = $2->comment; }
225 | NameList Name { APPEND(DMXConfigStringPtr, $1, $2); $$ = $1; }