1
|
1
|
|
2 /*
|
|
3 * Linux Frame Buffer Device Configuration
|
|
4 *
|
|
5 * © Copyright 1995-1998 by Geert Uytterhoeven
|
|
6 * (Geert.Uytterhoeven@cs.kuleuven.ac.be)
|
|
7 *
|
|
8 * --------------------------------------------------------------------------
|
|
9 *
|
|
10 * This file is subject to the terms and conditions of the GNU General Public
|
|
11 * License. See the file COPYING in the main directory of the Linux
|
|
12 * distribution for more details.
|
|
13 */
|
|
14
|
|
15
|
|
16 %{
|
|
17
|
|
18 #define YYSTYPE long
|
|
19
|
|
20 #include <string.h>
|
|
21 #include <stdlib.h>
|
|
22
|
|
23 #include "fbset.h"
|
|
24 #include "modes.tab.h"
|
|
25
|
|
26 struct keyword {
|
|
27 const char *name;
|
|
28 int token;
|
|
29 int value;
|
|
30 };
|
|
31
|
|
32 static struct keyword keywords[] = {
|
|
33 { "mode", MODE, 0 },
|
|
34 { "geometry", GEOMETRY, 0 },
|
|
35 { "timings", TIMINGS, 0 },
|
|
36 { "hsync", HSYNC, 0 },
|
|
37 { "vsync", VSYNC, 0 },
|
|
38 { "csync", CSYNC, 0 },
|
|
39 { "gsync", GSYNC, 0 },
|
|
40 { "extsync", EXTSYNC, 0 },
|
|
41 { "bcast", BCAST, 0 },
|
|
42 { "laced", LACED, 0 },
|
|
43 { "double", DOUBLE, 0 },
|
|
44 { "rgba", RGBA, 0 },
|
|
45 { "nonstd", NONSTD, 0 },
|
|
46 { "accel", ACCEL, 0 },
|
|
47 { "grayscale", GRAYSCALE, 0 },
|
|
48 { "endmode", ENDMODE, 0 },
|
|
49 { "low", POLARITY, LOW },
|
|
50 { "high", POLARITY, HIGH },
|
|
51 { "false", BOOLEAN, FALSE },
|
|
52 { "true", BOOLEAN, TRUE },
|
|
53 { "", -1, 0 }
|
|
54 };
|
|
55
|
|
56 int line = 1;
|
|
57
|
|
58
|
|
59 void yyerror(const char *s)
|
|
60 {
|
|
61 Die("%s:%d: %s\n", Opt_modedb, line, s);
|
|
62 }
|
|
63
|
|
64
|
|
65 int yywrap(void)
|
|
66 {
|
|
67 return 1;
|
|
68 }
|
|
69
|
|
70
|
|
71 static int FindToken(const char *s)
|
|
72 {
|
|
73 int i;
|
|
74
|
|
75 for (i = 0; keywords[i].token > 0; i++)
|
|
76 if (!strcasecmp(s, keywords[i].name)) {
|
|
77 yylval = keywords[i].value;
|
|
78 return keywords[i].token;
|
|
79 }
|
|
80 Die("%s:%d: Unknown keyword `%s'\n", Opt_modedb, line, s);
|
|
81 }
|
|
82
|
|
83
|
|
84 static const char *CopyString(const char *s)
|
|
85 {
|
|
86 int len;
|
|
87 char *s2;
|
|
88
|
|
89 len = strlen(s)-2;
|
|
90 if (!(s2 = malloc(len+1)))
|
|
91 Die("No memory\n");
|
|
92 strncpy(s2, s+1, len);
|
|
93 s2[len] = '\0';
|
|
94 return s2;
|
|
95 }
|
|
96
|
|
97
|
|
98 %}
|
|
99
|
|
100 keyword [a-zA-Z][a-zA-Z0-9]*
|
|
101 number [0-9]*
|
|
102 string \"[^\"\n]*\"
|
|
103 comment \#([^\n]*)
|
|
104 space [ \t]+
|
|
105 junk .
|
|
106
|
|
107 %%
|
|
108
|
|
109 {keyword} {
|
|
110 return FindToken(yytext);
|
|
111 }
|
|
112
|
|
113 {number} {
|
|
114 yylval = strtoul(yytext, NULL, 0);
|
|
115 return NUMBER;
|
|
116 }
|
|
117
|
|
118 {string} {
|
|
119 yylval = (unsigned long)CopyString(yytext);
|
|
120 return STRING;
|
|
121 }
|
|
122
|
|
123 {comment}$ break;
|
|
124
|
|
125 {space} break;
|
|
126
|
|
127 \n {
|
|
128 line++;
|
|
129 break;
|
|
130 }
|
|
131
|
|
132 {junk} {
|
|
133 Die("%s:%d: Invalid token `%s'\n", Opt_modedb, line, yytext);
|
|
134 }
|
|
135
|
|
136 %%
|