1706f2543Smrg/* $XFree86$ */
2706f2543Smrg/*
3706f2543Smrg * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
4706f2543Smrg *
5706f2543Smrg * All Rights Reserved.
6706f2543Smrg *
7706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining
8706f2543Smrg * a copy of this software and associated documentation files (the
9706f2543Smrg * "Software"), to deal in the Software without restriction, including
10706f2543Smrg * without limitation on the rights to use, copy, modify, merge,
11706f2543Smrg * publish, distribute, sublicense, and/or sell copies of the Software,
12706f2543Smrg * and to permit persons to whom the Software is furnished to do so,
13706f2543Smrg * subject to the following conditions:
14706f2543Smrg *
15706f2543Smrg * The above copyright notice and this permission notice (including the
16706f2543Smrg * next paragraph) shall be included in all copies or substantial
17706f2543Smrg * portions of the Software.
18706f2543Smrg *
19706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20706f2543Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21706f2543Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22706f2543Smrg * NON-INFRINGEMENT.  IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
23706f2543Smrg * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24706f2543Smrg * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25706f2543Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26706f2543Smrg * SOFTWARE.
27706f2543Smrg */
28706f2543Smrg
29706f2543Smrg/*
30706f2543Smrg * Authors:
31706f2543Smrg *   Rickard E. (Rik) Faith <faith@redhat.com>
32706f2543Smrg *
33706f2543Smrg */
34706f2543Smrg
35706f2543Smrg%{
36706f2543Smrg#ifdef HAVE_DMX_CONFIG_H
37706f2543Smrg#include <dmx-config.h>
38706f2543Smrg#endif
39706f2543Smrg
40706f2543Smrg#include "dmxparse.h"
41706f2543Smrg#include <string.h>
42706f2543Smrg#include <stdlib.h>
43706f2543Smrg#define YYDEBUG 1
44706f2543Smrg#define YYERROR_VERBOSE
45706f2543Smrg#define YY_USE_PROTOS
46706f2543Smrg
47706f2543SmrgDMXConfigEntryPtr dmxConfigEntry = NULL;
48706f2543Smrg#define APPEND(type, h, t)                 \
49706f2543Smrg{                                          \
50706f2543Smrg    type pt;                               \
51706f2543Smrg    for (pt = h; pt->next; pt = pt->next); \
52706f2543Smrg    pt->next = t;                          \
53706f2543Smrg}
54706f2543Smrg%}
55706f2543Smrg
56706f2543Smrg%union {
57706f2543Smrg    DMXConfigTokenPtr      token;
58706f2543Smrg    DMXConfigStringPtr     string;
59706f2543Smrg    DMXConfigNumberPtr     number;
60706f2543Smrg    DMXConfigPairPtr       pair;
61706f2543Smrg    DMXConfigFullDimPtr    fdim;
62706f2543Smrg    DMXConfigPartDimPtr    pdim;
63706f2543Smrg    DMXConfigDisplayPtr    display;
64706f2543Smrg    DMXConfigWallPtr       wall;
65706f2543Smrg    DMXConfigOptionPtr     option;
66706f2543Smrg    DMXConfigParamPtr      param;
67706f2543Smrg    DMXConfigCommentPtr    comment;
68706f2543Smrg    DMXConfigSubPtr        subentry;
69706f2543Smrg    DMXConfigVirtualPtr    virtual;
70706f2543Smrg    DMXConfigEntryPtr      entry;
71706f2543Smrg}
72706f2543Smrg
73706f2543Smrg				/* Terminals */
74706f2543Smrg%token <token>   '{' '}' ';' '/' T_VIRTUAL T_DISPLAY T_WALL T_OPTION T_PARAM
75706f2543Smrg%token <string>  T_STRING
76706f2543Smrg%token <pair>    T_DIMENSION T_OFFSET T_ORIGIN
77706f2543Smrg%token <comment> T_COMMENT T_LINE_COMMENT
78706f2543Smrg
79706f2543Smrg                                /* Non-termials */
80706f2543Smrg%type  <token>    Display Wall Terminal Open Close
81706f2543Smrg%type  <string>   NameList Name
82706f2543Smrg%type  <pair>     Dimension Offset Origin
83706f2543Smrg%type  <pdim>     PartialDim
84706f2543Smrg%type  <fdim>     FullDim
85706f2543Smrg%type  <display>  DisplayEntry
86706f2543Smrg%type  <option>   OptionEntry
87706f2543Smrg%type  <param>    ParamEntry ParamList Param
88706f2543Smrg%type  <subentry> SubList Sub
89706f2543Smrg%type  <wall>     WallEntry
90706f2543Smrg%type  <virtual>  Virtual
91706f2543Smrg%type  <entry>    Program EntryList Entry
92706f2543Smrg
93706f2543Smrg%%
94706f2543Smrg
95706f2543SmrgProgram : EntryList { dmxConfigEntry = $1; }
96706f2543Smrg        ;
97706f2543Smrg
98706f2543SmrgEntryList : Entry
99706f2543Smrg          | EntryList Entry { APPEND(DMXConfigEntryPtr,$1,$2); $$ = $1; }
100706f2543Smrg          ;
101706f2543Smrg
102706f2543SmrgEntry : Virtual        { $$ = dmxConfigEntryVirtual($1); }
103706f2543Smrg      | T_LINE_COMMENT { $$ = dmxConfigEntryComment($1); }
104706f2543Smrg      ;
105706f2543Smrg
106706f2543SmrgVirtual : T_VIRTUAL Open SubList Close
107706f2543Smrg          { $$ = dmxConfigCreateVirtual($1, NULL, NULL, $2, $3, $4); }
108706f2543Smrg        | T_VIRTUAL Dimension Open SubList Close
109706f2543Smrg          { $$ = dmxConfigCreateVirtual($1, NULL, $2, $3, $4, $5); }
110706f2543Smrg        | T_VIRTUAL Name Open SubList Close
111706f2543Smrg          { $$ = dmxConfigCreateVirtual($1, $2, NULL, $3, $4, $5); }
112706f2543Smrg        | T_VIRTUAL Name Dimension Open SubList Close
113706f2543Smrg          { $$ = dmxConfigCreateVirtual($1, $2, $3, $4, $5, $6 ); }
114706f2543Smrg        ;
115706f2543Smrg
116706f2543SmrgSubList : Sub
117706f2543Smrg        | SubList Sub { APPEND(DMXConfigSubPtr,$1,$2); $$ = $1; }
118706f2543Smrg        ;
119706f2543Smrg
120706f2543SmrgSub : T_LINE_COMMENT { $$ = dmxConfigSubComment($1); }
121706f2543Smrg    | DisplayEntry   { $$ = dmxConfigSubDisplay($1); }
122706f2543Smrg    | WallEntry      { $$ = dmxConfigSubWall($1); }
123706f2543Smrg    | OptionEntry    { $$ = dmxConfigSubOption($1); }
124706f2543Smrg    | ParamEntry     { $$ = dmxConfigSubParam($1); }
125706f2543Smrg    ;
126706f2543Smrg
127706f2543SmrgOptionEntry : T_OPTION NameList Terminal
128706f2543Smrg              { $$ = dmxConfigCreateOption($1, $2, $3); }
129706f2543Smrg            ;
130706f2543Smrg
131706f2543SmrgParamEntry : T_PARAM NameList Terminal
132706f2543Smrg             { $$ = dmxConfigCreateParam($1, NULL, $2, NULL, $3); }
133706f2543Smrg           | T_PARAM Open ParamList Close
134706f2543Smrg             { $$ = dmxConfigCreateParam($1, $2, NULL, $4, NULL);
135706f2543Smrg               $$->next = $3;
136706f2543Smrg             }
137706f2543Smrg           ;
138706f2543Smrg
139706f2543SmrgParamList : Param
140706f2543Smrg          | ParamList Param { APPEND(DMXConfigParamPtr,$1,$2); $$ = $1; }
141706f2543Smrg          ;
142706f2543Smrg
143706f2543SmrgParam : NameList Terminal
144706f2543Smrg        { $$ = dmxConfigCreateParam(NULL, NULL, $1, NULL, $2); }
145706f2543Smrg      ;
146706f2543Smrg
147706f2543SmrgPartialDim : Dimension Offset
148706f2543Smrg             { $$ = dmxConfigCreatePartDim($1, $2); }
149706f2543Smrg           | Dimension
150706f2543Smrg             { $$ = dmxConfigCreatePartDim($1, NULL); }
151706f2543Smrg           | Offset
152706f2543Smrg             { $$ = dmxConfigCreatePartDim(NULL, $1); }
153706f2543Smrg           ;
154706f2543Smrg
155706f2543SmrgFullDim : PartialDim '/' PartialDim
156706f2543Smrg          { $$ = dmxConfigCreateFullDim($1, $3); }
157706f2543Smrg        | '/' PartialDim
158706f2543Smrg          { $$ = dmxConfigCreateFullDim(NULL, $2); }
159706f2543Smrg        | PartialDim
160706f2543Smrg          { $$ = dmxConfigCreateFullDim($1, NULL); }
161706f2543Smrg        ;
162706f2543Smrg
163706f2543SmrgDisplayEntry : Display Name FullDim Origin Terminal
164706f2543Smrg               { $$ = dmxConfigCreateDisplay($1, $2, $3, $4, $5); }
165706f2543Smrg             | Display FullDim Origin Terminal
166706f2543Smrg               { $$ = dmxConfigCreateDisplay($1, NULL, $2, $3, $4); }
167706f2543Smrg             | Display Name Origin Terminal
168706f2543Smrg               { $$ = dmxConfigCreateDisplay($1, $2, NULL, $3, $4); }
169706f2543Smrg
170706f2543Smrg             | Display Name FullDim Terminal
171706f2543Smrg               { $$ = dmxConfigCreateDisplay($1, $2, $3, NULL, $4); }
172706f2543Smrg             | Display FullDim Terminal
173706f2543Smrg               { $$ = dmxConfigCreateDisplay($1, NULL, $2, NULL, $3); }
174706f2543Smrg             | Display Name Terminal
175706f2543Smrg               { $$ = dmxConfigCreateDisplay($1, $2, NULL, NULL, $3); }
176706f2543Smrg             | Display Terminal
177706f2543Smrg               { $$ = dmxConfigCreateDisplay($1, NULL, NULL, NULL, $2); }
178706f2543Smrg             ;
179706f2543Smrg
180706f2543SmrgWallEntry : Wall Dimension Dimension NameList Terminal
181706f2543Smrg            { $$ = dmxConfigCreateWall($1, $2, $3, $4, $5); }
182706f2543Smrg          | Wall Dimension NameList Terminal
183706f2543Smrg            { $$ = dmxConfigCreateWall($1, $2, NULL, $3, $4); }
184706f2543Smrg          | Wall NameList Terminal
185706f2543Smrg            { $$ = dmxConfigCreateWall($1, NULL, NULL, $2, $3); }
186706f2543Smrg          ;
187706f2543Smrg
188706f2543SmrgDisplay : T_DISPLAY
189706f2543Smrg        | T_DISPLAY T_COMMENT { $$ = $1; $$->comment = $2->comment; }
190706f2543Smrg        ;
191706f2543Smrg
192706f2543SmrgName : T_STRING
193706f2543Smrg     | T_STRING T_COMMENT { $$ = $1; $$->comment = $2->comment; }
194706f2543Smrg     ;
195706f2543Smrg
196706f2543SmrgDimension : T_DIMENSION
197706f2543Smrg          | T_DIMENSION T_COMMENT { $$ = $1; $$->comment = $2->comment; }
198706f2543Smrg          ;
199706f2543Smrg
200706f2543SmrgOffset : T_OFFSET
201706f2543Smrg       | T_OFFSET T_COMMENT { $$ = $1; $$->comment = $2->comment; }
202706f2543Smrg       ;
203706f2543Smrg
204706f2543SmrgOrigin : T_ORIGIN
205706f2543Smrg       | T_ORIGIN T_COMMENT { $$ = $1; $$->comment = $2->comment; }
206706f2543Smrg       ;
207706f2543Smrg
208706f2543SmrgTerminal : ';'
209706f2543Smrg         | ';' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
210706f2543Smrg         ;
211706f2543Smrg
212706f2543SmrgOpen : '{'
213706f2543Smrg     | '{' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
214706f2543Smrg     ;
215706f2543Smrg
216706f2543SmrgClose : '}'
217706f2543Smrg      | '}' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
218706f2543Smrg      ;
219706f2543Smrg
220706f2543SmrgWall : T_WALL
221706f2543Smrg     | T_WALL T_COMMENT { $$ = $1; $$->comment = $2->comment; }
222706f2543Smrg     ;
223706f2543Smrg
224706f2543SmrgNameList : Name
225706f2543Smrg         | NameList Name { APPEND(DMXConfigStringPtr, $1, $2); $$ = $1; }
226706f2543Smrg         ;
227