2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linux Frame Buffer Device Configuration
|
|
|
|
|
*
|
|
|
|
|
* <20> Copyright 1995-1998 by Geert Uytterhoeven
|
|
|
|
|
* (Geert.Uytterhoeven@cs.kuleuven.ac.be)
|
|
|
|
|
*
|
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
|
* License. See the file COPYING in the main directory of the Linux
|
|
|
|
|
* distribution for more details.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%{
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#define Die Sys_Error
|
|
|
|
|
|
|
|
|
|
#include "fbset.h"
|
|
|
|
|
#include "fbset_modes_y.h"
|
|
|
|
|
|
2003-04-17 00:01:48 +00:00
|
|
|
|
#ifndef YY_PROTO
|
|
|
|
|
# define YY_PROTO(x) x
|
|
|
|
|
#else
|
|
|
|
|
# define YY_FLEX_REALLOC_HACK
|
|
|
|
|
#endif
|
|
|
|
|
int yyget_lineno (void);
|
|
|
|
|
FILE *yyget_in (void);
|
|
|
|
|
FILE *yyget_out (void);
|
|
|
|
|
int yyget_leng (void);
|
|
|
|
|
char *yyget_text (void);
|
|
|
|
|
void yyset_lineno (int line_number);
|
|
|
|
|
void yyset_in (FILE * in_str);
|
|
|
|
|
void yyset_out (FILE * out_str);
|
|
|
|
|
int yyget_debug (void);
|
|
|
|
|
void yyset_debug (int bdebug);
|
|
|
|
|
int yylex_destroy (void);
|
|
|
|
|
|
2001-11-20 23:22:19 +00:00
|
|
|
|
#define YY_NO_UNPUT
|
2003-01-06 18:28:13 +00:00
|
|
|
|
#define YY_DECL int yylex YY_PROTO(( void ))
|
|
|
|
|
YY_DECL;
|
2001-11-20 23:22:19 +00:00
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
|
struct keyword {
|
2002-05-14 06:12:29 +00:00
|
|
|
|
const char *name;
|
|
|
|
|
int token;
|
|
|
|
|
int value;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static struct keyword keywords[] = {
|
2002-05-14 06:12:29 +00:00
|
|
|
|
{ "mode", MODE, 0 },
|
|
|
|
|
{ "geometry", GEOMETRY, 0 },
|
|
|
|
|
{ "timings", TIMINGS, 0 },
|
|
|
|
|
{ "hsync", HSYNC, 0 },
|
|
|
|
|
{ "vsync", VSYNC, 0 },
|
|
|
|
|
{ "csync", CSYNC, 0 },
|
|
|
|
|
{ "gsync", GSYNC, 0 },
|
|
|
|
|
{ "extsync", EXTSYNC, 0 },
|
|
|
|
|
{ "bcast", BCAST, 0 },
|
|
|
|
|
{ "laced", LACED, 0 },
|
|
|
|
|
{ "double", DOUBLE, 0 },
|
|
|
|
|
{ "rgba", RGBA, 0 },
|
|
|
|
|
{ "nonstd", NONSTD, 0 },
|
|
|
|
|
{ "accel", ACCEL, 0 },
|
|
|
|
|
{ "grayscale", GRAYSCALE, 0 },
|
|
|
|
|
{ "endmode", ENDMODE, 0 },
|
|
|
|
|
{ "low", POLARITY, LOW },
|
|
|
|
|
{ "high", POLARITY, HIGH },
|
|
|
|
|
{ "false", BOOLEAN, FALSE },
|
|
|
|
|
{ "true", BOOLEAN, TRUE },
|
|
|
|
|
{ "", -1, 0 }
|
2001-04-15 04:18:22 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int line = 1;
|
|
|
|
|
|
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
|
void yyerror(const char *s);
|
2001-04-15 04:18:22 +00:00
|
|
|
|
void yyerror(const char *s)
|
|
|
|
|
{
|
2002-05-14 06:12:29 +00:00
|
|
|
|
Die("%s:%d: %s", Opt_modedb, line, s);
|
2001-04-15 04:18:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
|
static int yywrap(void)
|
2001-04-15 04:18:22 +00:00
|
|
|
|
{
|
2002-05-14 06:12:29 +00:00
|
|
|
|
return 1;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int FindToken(const char *s)
|
|
|
|
|
{
|
2002-05-14 06:12:29 +00:00
|
|
|
|
int i;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
2002-05-14 06:12:29 +00:00
|
|
|
|
for (i = 0; keywords[i].token > 0; i++)
|
2001-04-15 04:18:22 +00:00
|
|
|
|
if (!strcasecmp(s, keywords[i].name)) {
|
2001-11-02 06:43:41 +00:00
|
|
|
|
yylval.int_val = keywords[i].value;
|
2002-05-14 06:12:29 +00:00
|
|
|
|
return keywords[i].token;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
}
|
2002-05-14 06:12:29 +00:00
|
|
|
|
Die("%s:%d: Unknown keyword `%s'", Opt_modedb, line, s);
|
2001-04-15 04:18:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const char *CopyString(const char *s)
|
|
|
|
|
{
|
2002-05-14 06:12:29 +00:00
|
|
|
|
int len;
|
|
|
|
|
char *s2;
|
|
|
|
|
|
|
|
|
|
len = strlen(s)-2;
|
|
|
|
|
if (!(s2 = malloc(len+1)))
|
|
|
|
|
Die("No memory");
|
|
|
|
|
strncpy(s2, s+1, len);
|
|
|
|
|
s2[len] = '\0';
|
|
|
|
|
return s2;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
keyword [a-zA-Z][a-zA-Z0-9]*
|
|
|
|
|
number [0-9]*
|
|
|
|
|
string \"[^\"\n]*\"
|
|
|
|
|
comment \#([^\n]*)
|
|
|
|
|
space [ \t]+
|
|
|
|
|
junk .
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
{keyword} {
|
2001-11-02 06:43:41 +00:00
|
|
|
|
return FindToken(yytext);
|
2002-05-14 06:12:29 +00:00
|
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
|
|
{number} {
|
2001-11-02 06:43:41 +00:00
|
|
|
|
yylval.int_val = strtoul(yytext, NULL, 0);
|
2001-04-15 04:18:22 +00:00
|
|
|
|
return NUMBER;
|
2002-05-14 06:12:29 +00:00
|
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
|
|
{string} {
|
2001-11-02 06:43:41 +00:00
|
|
|
|
yylval.string = CopyString(yytext);
|
2001-04-15 04:18:22 +00:00
|
|
|
|
return STRING;
|
2002-05-14 06:12:29 +00:00
|
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
|
|
{comment}$ break;
|
|
|
|
|
|
|
|
|
|
{space} break;
|
|
|
|
|
|
|
|
|
|
\n {
|
|
|
|
|
line++;
|
|
|
|
|
break;
|
2002-05-14 06:12:29 +00:00
|
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
|
|
{junk} {
|
2002-05-14 06:12:29 +00:00
|
|
|
|
Die("%s:%d: Invalid token `%s'", Opt_modedb, line, yytext);
|
|
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
|
|
%%
|
2003-04-17 00:01:48 +00:00
|
|
|
|
|
2003-04-17 00:14:13 +00:00
|
|
|
|
#ifdef YY_FLEX_REALLOC_HACK
|
2003-04-17 00:25:55 +00:00
|
|
|
|
#else
|
2008-07-19 05:40:57 +00:00
|
|
|
|
static __attribute__ ((used)) void (*yyunput_hack)(int, char*) = yyunput;
|
|
|
|
|
static __attribute__ ((used)) int (*input_hack)(void) = input;
|
2003-04-17 00:14:13 +00:00
|
|
|
|
#endif
|