annotate TVout/fbset/modes.l @ 11976:4e70e9ea29c4

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