2004-01-05 02:25:38 +01:00
|
|
|
/* Lexical analyzer for dgamelaunch's configuration file. */
|
|
|
|
|
|
|
|
%{
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2004-02-02 01:30:06 +01:00
|
|
|
#include <errno.h>
|
2004-01-05 02:25:38 +01:00
|
|
|
|
|
|
|
#include "y.tab.h"
|
|
|
|
#include "dgamelaunch.h"
|
|
|
|
|
|
|
|
unsigned int line = 1, col = 0;
|
|
|
|
|
|
|
|
#define YY_USER_ACTION col += yyleng;
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
2004-02-02 02:03:57 +01:00
|
|
|
NEGNUMBER -[0-9]+
|
2004-02-02 02:31:48 +01:00
|
|
|
NUMBER [0-9]+
|
2004-01-05 02:25:38 +01:00
|
|
|
VALUE \".*\"
|
|
|
|
MALSTRING \"[^\"\n]*\n
|
|
|
|
WHITE [\t ]*
|
|
|
|
COMMENT ^#.*
|
|
|
|
|
2004-01-16 03:32:33 +01:00
|
|
|
%%
|
2004-01-05 02:25:38 +01:00
|
|
|
|
2004-02-02 02:03:57 +01:00
|
|
|
{NEGNUMBER} {
|
|
|
|
fprintf(stderr,"%s:%d: negative value not accepted! Fix it now!\n",
|
2004-02-01 09:10:18 +01:00
|
|
|
config, line);
|
2004-02-02 02:03:57 +01:00
|
|
|
graceful_exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
{NUMBER} {
|
|
|
|
yylval.i = strtoul(yytext, NULL, 10);
|
2004-02-01 09:10:18 +01:00
|
|
|
return TYPE_NUMBER;
|
|
|
|
}
|
|
|
|
|
2004-01-05 02:25:38 +01:00
|
|
|
{VALUE} {
|
|
|
|
yytext[yyleng - 1] = '\0'; /* Kill the trailing quote */
|
2004-01-16 03:32:33 +01:00
|
|
|
yylval.s = strdup(yytext + 1); /* kill leading quote */
|
2004-01-05 02:25:38 +01:00
|
|
|
return TYPE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
{MALSTRING} {
|
2004-02-02 02:03:57 +01:00
|
|
|
yytext[yyleng - 1] = '\0'; /* remove trailing newline */
|
2004-02-01 21:45:55 +01:00
|
|
|
fprintf(stderr, "%s:%d:%d: unterminated string constant: %s\n", config, line, col - yyleng + 1, yytext);
|
2004-02-02 02:03:57 +01:00
|
|
|
return TYPE_MALSTRING;
|
2004-01-05 02:25:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
{WHITE} { }
|
|
|
|
{COMMENT} { }
|
|
|
|
|
|
|
|
"=" { return '='; }
|
|
|
|
"shed_user" { return TYPE_SUSER; }
|
|
|
|
"shed_group" { return TYPE_SGROUP; }
|
|
|
|
"shed_uid" { return TYPE_SUID; }
|
|
|
|
"shed_gid" { return TYPE_SGID; }
|
|
|
|
"maxusers" { return TYPE_MAX; }
|
2007-03-31 13:10:07 +02:00
|
|
|
"maxnicklen" { return TYPE_MAXNICKLEN; }
|
2004-01-05 02:25:38 +01:00
|
|
|
|
2007-03-29 22:14:55 +02:00
|
|
|
"game_num" { return TYPE_GAMENUM; }
|
|
|
|
|
2004-01-05 02:25:38 +01:00
|
|
|
"chroot_path" { return TYPE_PATH_CHROOT; }
|
2004-04-03 21:27:42 +02:00
|
|
|
"game_name" { return TYPE_NAME_GAME; }
|
2007-04-01 12:11:38 +02:00
|
|
|
"short_name" { return TYPE_GAME_SHORT_NAME; }
|
2004-04-03 21:27:42 +02:00
|
|
|
"game_path" { return TYPE_PATH_GAME; }
|
2007-03-31 23:05:12 +02:00
|
|
|
"chdir" { return TYPE_PATH_CHDIR; }
|
2007-04-01 14:09:42 +02:00
|
|
|
"mkdir" { return TYPE_PATH_MKDIR; }
|
2004-01-05 02:25:38 +01:00
|
|
|
"dglroot" { return TYPE_PATH_DGLDIR; }
|
|
|
|
"spooldir" { return TYPE_PATH_SPOOL; }
|
|
|
|
"banner" { return TYPE_PATH_BANNER; }
|
|
|
|
"rc_template" { return TYPE_PATH_CANNED; }
|
2004-01-21 02:57:44 +01:00
|
|
|
"passwd" { return TYPE_PATH_PASSWD; }
|
|
|
|
"lockfile" { return TYPE_PATH_LOCKFILE; }
|
2004-03-17 15:04:31 +01:00
|
|
|
"savefilefmt" { return TYPE_PATH_SAVEFILEFMT; }
|
2007-03-29 22:14:55 +02:00
|
|
|
"inprogressdir" { return TYPE_PATH_INPROGRESS; }
|
|
|
|
"game_args" { return TYPE_GAME_ARGS; }
|
|
|
|
"rc_fmt" { return TYPE_RC_FMT; }
|
2004-01-05 02:25:38 +01:00
|
|
|
|
|
|
|
\n { line++; col = 0; }
|
|
|
|
|
|
|
|
. {
|
2004-02-02 02:03:57 +01:00
|
|
|
fprintf(stderr, "%s:%d:%d unrecognized token \"%s\"\n", config, line, col, yytext);
|
2004-01-05 02:25:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
%%
|