3
* Copyright 2002 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>
46
static int getdimension(int token, const char *text, int leng);
47
static int getstring(int token, const char *text, int leng);
48
static int gettoken(int token, const char *text, int leng);
49
static int getcomment(int token, const char *text, int leng);
50
static int lineno = 1;
54
word ([[:alpha:]_/:\-\+\.\*][[:alnum:]_/:\-\+\.\*]+)
55
string \"(([^\"\n])|\"\")*\"
56
badstring \"(([^\"\n])|\"\")*
58
dimension [[:digit:]]+[[:blank:]]*x[[:blank:]]*[[:digit:]]+
59
offset [+-][[:digit:]]+[[:blank:]]*[+-][[:blank:]]*[[:digit:]]+
60
origin @[[:blank:]]*[[:digit:]]+[[:blank:]]*[[:blank:]]*x[[:digit:]]+
64
virtual return gettoken(T_VIRTUAL, yytext, yyleng);
65
display return gettoken(T_DISPLAY, yytext, yyleng);
66
wall return gettoken(T_WALL, yytext, yyleng);
67
option return gettoken(T_OPTION, yytext, yyleng);
68
param return gettoken(T_PARAM, yytext, yyleng);
69
{dimension} return getdimension(T_DIMENSION, yytext, yyleng);
70
{offset} return getdimension(T_OFFSET, yytext+1, yyleng-1);
71
{origin} return getdimension(T_ORIGIN, yytext+1, yyleng-1);
72
{word} return getstring(T_STRING, yytext, yyleng);
73
{string} return getstring(T_STRING, yytext+1, yyleng-2);
76
\{ return gettoken(yytext[0], yytext, yyleng);
77
\} return gettoken(yytext[0], yytext, yyleng);
78
\; return gettoken(yytext[0], yytext, yyleng);
79
\/ return gettoken(yytext[0], yytext, yyleng);
80
^{comment} return getcomment(T_LINE_COMMENT, yytext, yyleng);
81
{comment} return getcomment(T_COMMENT, yytext, yyleng);
82
. return getstring(T_STRING, yytext, yyleng);
90
void yyerror(const char *message)
97
{ "T_VIRTUAL", "\"virtual\"" },
98
{ "T_DISPLAY", "\"display\"" },
99
{ "T_WALL", "\"wall\"" },
100
{ "T_OPTION", "\"option\"" },
101
{ "T_PARAM", "\"param\"" },
102
{ "T_DIMENSION", "dimension (e.g., 2x2 or 1024x768)" },
103
{ "T_OFFSET", "display offset (e.g., +10-10)" },
104
{ "T_ORIGIN", "tile origin (e.g., @1280x1024)" },
105
{ "T_STRING", "string" },
106
{ "T_COMMENT", "comment (e.g., #...)" },
107
{ "T_LINE_COMMENT", "comment (e.g., #...)" },
111
fprintf(stderr, "parse error on line %d at token \"%*.*s\"\n",
112
lineno, yyleng, yyleng, yytext);
113
end = message + strlen(message);
114
for (pt = message; *pt; pt++) {
115
if (pt[0] == 'T' && pt[1] == '_') {
116
const char *next = strchr(pt, ' ');
117
if (!next || !*next) next = strchr(pt, '\0');
118
if (!next) goto bail;
120
if (next-pt == 1 && next[1]
121
&& next[2] == '\'' && next[3] == '\'') {
122
fprintf(stderr, "\"%c\"", next[1]);
126
for (entry = list; entry->from; ++entry) {
127
if (!strncmp(entry->from, pt, strlen(entry->from))) {
128
fprintf(stderr, "%s", entry->to);
133
} else if (end-pt >= 5 && pt[0] == '\'' && pt[1] == '\'' && pt[3]
134
&& pt[4] == '\'' && pt[5] == '\'') {
135
fprintf(stderr, "\"%c\"", pt[3]);
137
} else if (end-pt >= 3 && pt[0] == '\'' && pt[1] && pt[2] == '\'') {
138
fprintf(stderr, "\"%c\"", pt[1]);
146
fprintf(stderr, "\n");
150
static int getdimension(int token, const char *text, int leng)
153
char *tmp = dmxConfigAlloc(leng+1);
156
strlcpy(tmp, text, leng+1);
157
x = strtol(tmp, &endptr, 10);
158
while (*endptr && !isdigit(*endptr)) ++endptr;
159
y = strtol(endptr, NULL, 10);
161
yylval.pair = dmxConfigCreatePair(token, lineno, NULL, x, y, 1, 1);
165
static int getstring(int token, const char *text, int leng)
167
yylval.string = dmxConfigCreateString(token, lineno, NULL,
168
dmxConfigCopyString(leng ? text : "",
173
static int gettoken(int token, const char *text, int leng)
175
yylval.token = dmxConfigCreateToken(token, lineno, NULL);
179
static int getcomment(int token, const char *text, int leng)
181
yylval.comment = dmxConfigCreateComment(token, lineno,
182
dmxConfigCopyString(text + 1,