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]+
|
2008-01-01 18:03:05 +01:00
|
|
|
VALUE \"[^"]*\"
|
2004-01-05 02:25:38 +01:00
|
|
|
MALSTRING \"[^\"\n]*\n
|
2008-01-01 21:43:13 +01:00
|
|
|
COMMENT ^[\t ]*#.*
|
2004-01-05 02:25:38 +01:00
|
|
|
WHITE [\t ]*
|
|
|
|
|
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);
|
2011-10-10 21:06:20 +02:00
|
|
|
graceful_exit(13);
|
2004-02-02 02:03:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
{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 */
|
2014-08-28 21:08:48 +02:00
|
|
|
fprintf(stderr, "%s:%d:%d: unterminated string constant: %s\n", config, line, (int)(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 '='; }
|
2008-01-01 18:03:05 +01:00
|
|
|
"," { return ','; }
|
|
|
|
"[" { return '['; }
|
|
|
|
"]" { return ']'; }
|
|
|
|
"{" { return '{'; }
|
|
|
|
"}" { return '}'; }
|
2008-04-05 15:29:19 +02:00
|
|
|
"(" { return '('; }
|
|
|
|
")" { return ')'; }
|
2004-01-05 02:25:38 +01:00
|
|
|
"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; }
|
2007-04-09 18:42:14 +02:00
|
|
|
"allow_new_nicks" { return TYPE_ALLOW_REGISTRATION; }
|
2010-03-02 19:32:57 +01:00
|
|
|
"menu_max_idle_time" { return TYPE_MENU_MAX_IDLE_TIME; }
|
2004-01-05 02:25:38 +01:00
|
|
|
|
2007-03-29 22:14:55 +02:00
|
|
|
|
2008-04-05 15:29:19 +02:00
|
|
|
menu { return TYPE_DEFINE_MENU; }
|
|
|
|
bannerfile { return TYPE_BANNER_FILE; }
|
|
|
|
cursor { return TYPE_CURSOR; }
|
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; }
|
2015-12-07 17:11:58 +01:00
|
|
|
"game_id" { return TYPE_GAME_ID; }
|
2004-04-03 21:27:42 +02:00
|
|
|
"game_path" { return TYPE_PATH_GAME; }
|
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; }
|
2007-03-29 22:14:55 +02:00
|
|
|
"inprogressdir" { return TYPE_PATH_INPROGRESS; }
|
|
|
|
"game_args" { return TYPE_GAME_ARGS; }
|
2011-10-03 17:00:14 +02:00
|
|
|
extra_info_file { return TYPE_EXTRA_INFO_FILE; }
|
2010-03-02 19:02:51 +01:00
|
|
|
"max_idle_time" { return TYPE_MAX_IDLE_TIME; }
|
2007-03-29 22:14:55 +02:00
|
|
|
"rc_fmt" { return TYPE_RC_FMT; }
|
2009-10-17 22:26:56 +02:00
|
|
|
"ttyrecdir" { return TYPE_PATH_TTYREC; }
|
2011-10-09 17:31:34 +02:00
|
|
|
bannervars { return TYPE_BANNERVARS; }
|
2011-10-12 16:34:40 +02:00
|
|
|
timeformat { return TYPE_TIMEFORMAT; }
|
2008-04-06 11:13:50 +02:00
|
|
|
sortmode { return TYPE_WATCH_SORTMODE; }
|
2011-10-03 16:46:42 +02:00
|
|
|
watch_columns { return TYPE_WATCH_COLUMNS; }
|
2008-01-01 18:03:05 +01:00
|
|
|
commands { return TYPE_CMDQUEUE; }
|
2011-08-31 16:36:22 +02:00
|
|
|
postcommands { return TYPE_POSTCMDQUEUE; }
|
2011-10-03 17:23:14 +02:00
|
|
|
encoding { return TYPE_ENCODING; }
|
2011-10-04 16:03:15 +02:00
|
|
|
locale { return TYPE_LOCALE; }
|
2012-12-15 00:17:20 +01:00
|
|
|
default_term { return TYPE_DEFTERM; }
|
2011-10-05 15:57:32 +02:00
|
|
|
utf8esc { return TYPE_UTF8ESC; }
|
2012-12-18 17:34:06 +01:00
|
|
|
flowcontrol { return TYPE_FLOWCTRL; }
|
2011-10-09 21:09:43 +02:00
|
|
|
filemode { return TYPE_FILEMODE; }
|
2008-01-13 11:38:45 +01:00
|
|
|
yes { yylval.i = 1; return TYPE_BOOL; }
|
|
|
|
no { yylval.i = 0; return TYPE_BOOL; }
|
2008-01-01 18:03:05 +01:00
|
|
|
dglstart { yylval.i = DGLTIME_DGLSTART; return TYPE_CMDQUEUENAME; }
|
|
|
|
login { yylval.i = DGLTIME_LOGIN; return TYPE_CMDQUEUENAME; }
|
|
|
|
register { yylval.i = DGLTIME_REGISTER; return TYPE_CMDQUEUENAME; }
|
2008-08-23 14:41:17 +02:00
|
|
|
gamestart { yylval.i = DGLTIME_GAMESTART; return TYPE_CMDQUEUENAME; }
|
2009-10-02 19:41:12 +02:00
|
|
|
gameend { yylval.i = DGLTIME_GAMEEND; return TYPE_CMDQUEUENAME; }
|
2008-01-01 19:13:54 +01:00
|
|
|
mkdir { yylval.i = DGLCMD_MKDIR; return TYPE_DGLCMD1; }
|
|
|
|
chdir { yylval.i = DGLCMD_CHDIR; return TYPE_DGLCMD1; }
|
|
|
|
cp { yylval.i = DGLCMD_CP; return TYPE_DGLCMD2; }
|
2008-01-13 01:12:59 +01:00
|
|
|
ifnxcp { yylval.i = DGLCMD_IF_NX_CP; return TYPE_DGLCMD2; }
|
2008-01-01 19:13:54 +01:00
|
|
|
unlink { yylval.i = DGLCMD_UNLINK; return TYPE_DGLCMD1; }
|
|
|
|
setenv { yylval.i = DGLCMD_SETENV; return TYPE_DGLCMD2; }
|
2008-01-13 00:47:45 +01:00
|
|
|
exec { yylval.i = DGLCMD_EXEC; return TYPE_DGLCMD2; }
|
2008-01-13 19:12:20 +01:00
|
|
|
chpasswd { yylval.i = DGLCMD_CHPASSWD; return TYPE_DGLCMD0; }
|
2008-01-13 19:28:50 +01:00
|
|
|
chmail { yylval.i = DGLCMD_CHMAIL; return TYPE_DGLCMD0; }
|
2008-01-14 23:06:32 +01:00
|
|
|
watch_menu { yylval.i = DGLCMD_WATCH_MENU; return TYPE_DGLCMD0; }
|
|
|
|
ask_login { yylval.i = DGLCMD_LOGIN; return TYPE_DGLCMD0; }
|
|
|
|
ask_register { yylval.i = DGLCMD_REGISTER; return TYPE_DGLCMD0; }
|
|
|
|
quit { yylval.i = DGLCMD_QUIT; return TYPE_DGLCMD0; }
|
2008-04-05 15:29:19 +02:00
|
|
|
play_game { yylval.i = DGLCMD_PLAYGAME; return TYPE_DGLCMD1; }
|
2015-12-07 17:11:58 +01:00
|
|
|
play_if_exist { yylval.i = DGLCMD_PLAY_IF_EXIST; return TYPE_DGLCMD2; }
|
2008-04-05 15:29:19 +02:00
|
|
|
submenu { yylval.i = DGLCMD_SUBMENU; return TYPE_DGLCMD1; }
|
|
|
|
return { yylval.i = DGLCMD_RETURN; return TYPE_DGLCMD0; }
|
2012-06-04 17:11:56 +02:00
|
|
|
rawprint { yylval.i = DGLCMD_RAWPRINT; return TYPE_DGLCMD1; }
|
2008-01-01 18:03:05 +01:00
|
|
|
DEFINE { return TYPE_DEFINE_GAME; }
|
|
|
|
|
2004-01-05 02:25:38 +01:00
|
|
|
|
|
|
|
\n { line++; col = 0; }
|
|
|
|
|
2008-01-06 20:35:14 +01:00
|
|
|
[0-9a-zA-Z_]+ {
|
2004-02-02 02:03:57 +01:00
|
|
|
fprintf(stderr, "%s:%d:%d unrecognized token \"%s\"\n", config, line, col, yytext);
|
2011-10-10 21:06:20 +02:00
|
|
|
graceful_exit(12);
|
2004-01-05 02:25:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
%%
|