Update libconfig to 1.4.9

This commit is contained in:
lighta 2014-12-19 03:10:07 -05:00
parent 09b0898e60
commit 78bcd82039
12 changed files with 748 additions and 143 deletions

6
.gitignore vendored
View File

@ -127,3 +127,9 @@ Thumbs.db
/vcproj-9/login-server /vcproj-9/login-server
/vcproj-9/map-server /vcproj-9/map-server
/vcproj-9/mapcache /vcproj-9/mapcache
/.idea/.name
/.idea/misc.xml
/.idea/modules.xml
/.idea/rathena.iml
/.idea/vcs.xml
/.idea/workspace.xml

395
3rdparty/libconfig/grammar.y vendored Normal file
View File

@ -0,0 +1,395 @@
/* -*- mode: C -*- */
/* ----------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
Copyright (C) 2005-2010 Mark A Lindner
This file is part of libconfig.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, see
<http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------
*/
%defines
%output="y.tab.c"
%pure-parser
%lex-param{void *scanner}
%parse-param{void *scanner}
%parse-param{struct parse_context *ctx}
%parse-param{struct scan_context *scan_ctx}
%{
#include <string.h>
#include <stdlib.h>
#include "libconfig.h"
#ifdef WIN32
#include "wincompat.h"
/* prevent warnings about redefined malloc/free in generated code: */
#ifndef _STDLIB_H
#define _STDLIB_H
#endif
#include <malloc.h>
#endif
#include "parsectx.h"
#include "scanctx.h"
/* these delcarations are provided to suppress compiler warnings */
extern int libconfig_yylex();
extern int libconfig_yyget_lineno();
static const char *err_array_elem_type = "mismatched element type in array";
static const char *err_duplicate_setting = "duplicate setting name";
#define _delete(P) free((void *)(P))
#define IN_ARRAY() \
(ctx->parent && (ctx->parent->type == CONFIG_TYPE_ARRAY))
#define IN_LIST() \
(ctx->parent && (ctx->parent->type == CONFIG_TYPE_LIST))
static void capture_parse_pos(void *scanner, struct scan_context *scan_ctx,
config_setting_t *setting)
{
setting->line = (unsigned int)libconfig_yyget_lineno(scanner);
setting->file = scanctx_current_filename(scan_ctx);
}
#define CAPTURE_PARSE_POS(S) \
capture_parse_pos(scanner, scan_ctx, (S))
void libconfig_yyerror(void *scanner, struct parse_context *ctx,
struct scan_context *scan_ctx, char const *s)
{
if(ctx->config->error_text) return;
ctx->config->error_line = libconfig_yyget_lineno(scanner);
ctx->config->error_text = s;
}
%}
%union
{
int ival;
long long llval;
double fval;
char *sval;
}
%token <ival> TOK_BOOLEAN TOK_INTEGER TOK_HEX
%token <llval> TOK_INTEGER64 TOK_HEX64
%token <fval> TOK_FLOAT
%token <sval> TOK_STRING TOK_NAME
%token TOK_EQUALS TOK_NEWLINE TOK_ARRAY_START TOK_ARRAY_END TOK_LIST_START TOK_LIST_END TOK_COMMA TOK_GROUP_START TOK_GROUP_END TOK_SEMICOLON TOK_GARBAGE TOK_ERROR
%%
configuration:
/* empty */
| setting_list
;
setting_list:
setting
| setting_list setting
;
setting_list_optional:
/* empty */
| setting_list
;
setting_terminator:
/* empty */
| TOK_SEMICOLON
| TOK_COMMA
;
setting:
TOK_NAME
{
ctx->setting = config_setting_add(ctx->parent, $1, CONFIG_TYPE_NONE);
if(ctx->setting == NULL)
{
libconfig_yyerror(scanner, ctx, scan_ctx, err_duplicate_setting);
YYABORT;
}
else
{
CAPTURE_PARSE_POS(ctx->setting);
}
}
TOK_EQUALS value setting_terminator
;
array:
TOK_ARRAY_START
{
if(IN_LIST())
{
ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_ARRAY);
CAPTURE_PARSE_POS(ctx->parent);
}
else
{
ctx->setting->type = CONFIG_TYPE_ARRAY;
ctx->parent = ctx->setting;
ctx->setting = NULL;
}
}
simple_value_list_optional
TOK_ARRAY_END
{
if(ctx->parent)
ctx->parent = ctx->parent->parent;
}
;
list:
TOK_LIST_START
{
if(IN_LIST())
{
ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_LIST);
CAPTURE_PARSE_POS(ctx->parent);
}
else
{
ctx->setting->type = CONFIG_TYPE_LIST;
ctx->parent = ctx->setting;
ctx->setting = NULL;
}
}
value_list_optional
TOK_LIST_END
{
if(ctx->parent)
ctx->parent = ctx->parent->parent;
}
;
value:
simple_value
| array
| list
| group
;
string:
TOK_STRING { parsectx_append_string(ctx, $1); free($1); }
| string TOK_STRING { parsectx_append_string(ctx, $2); free($2); }
;
simple_value:
TOK_BOOLEAN
{
if(IN_ARRAY() || IN_LIST())
{
config_setting_t *e = config_setting_set_bool_elem(ctx->parent, -1,
(int)$1);
if(! e)
{
libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
YYABORT;
}
else
{
CAPTURE_PARSE_POS(e);
}
}
else
config_setting_set_bool(ctx->setting, (int)$1);
}
| TOK_INTEGER
{
if(IN_ARRAY() || IN_LIST())
{
config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, $1);
if(! e)
{
libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
YYABORT;
}
else
{
config_setting_set_format(e, CONFIG_FORMAT_DEFAULT);
CAPTURE_PARSE_POS(e);
}
}
else
{
config_setting_set_int(ctx->setting, $1);
config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT);
}
}
| TOK_INTEGER64
{
if(IN_ARRAY() || IN_LIST())
{
config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, $1);
if(! e)
{
libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
YYABORT;
}
else
{
config_setting_set_format(e, CONFIG_FORMAT_DEFAULT);
CAPTURE_PARSE_POS(e);
}
}
else
{
config_setting_set_int64(ctx->setting, $1);
config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT);
}
}
| TOK_HEX
{
if(IN_ARRAY() || IN_LIST())
{
config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, $1);
if(! e)
{
libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
YYABORT;
}
else
{
config_setting_set_format(e, CONFIG_FORMAT_HEX);
CAPTURE_PARSE_POS(e);
}
}
else
{
config_setting_set_int(ctx->setting, $1);
config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX);
}
}
| TOK_HEX64
{
if(IN_ARRAY() || IN_LIST())
{
config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, $1);
if(! e)
{
libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
YYABORT;
}
else
{
config_setting_set_format(e, CONFIG_FORMAT_HEX);
CAPTURE_PARSE_POS(e);
}
}
else
{
config_setting_set_int64(ctx->setting, $1);
config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX);
}
}
| TOK_FLOAT
{
if(IN_ARRAY() || IN_LIST())
{
config_setting_t *e = config_setting_set_float_elem(ctx->parent, -1, $1);
if(! e)
{
libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
YYABORT;
}
else
{
CAPTURE_PARSE_POS(e);
}
}
else
config_setting_set_float(ctx->setting, $1);
}
| string
{
if(IN_ARRAY() || IN_LIST())
{
const char *s = parsectx_take_string(ctx);
config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, s);
_delete(s);
if(! e)
{
libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
YYABORT;
}
else
{
CAPTURE_PARSE_POS(e);
}
}
else
{
const char *s = parsectx_take_string(ctx);
config_setting_set_string(ctx->setting, s);
_delete(s);
}
}
;
value_list:
value
| value_list TOK_COMMA value
;
value_list_optional:
/* empty */
| value_list
;
simple_value_list:
simple_value
| simple_value_list TOK_COMMA simple_value
;
simple_value_list_optional:
/* empty */
| simple_value_list
;
group:
TOK_GROUP_START
{
if(IN_LIST())
{
ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_GROUP);
CAPTURE_PARSE_POS(ctx->parent);
}
else
{
ctx->setting->type = CONFIG_TYPE_GROUP;
ctx->parent = ctx->setting;
ctx->setting = NULL;
}
}
setting_list_optional
TOK_GROUP_END
{
if(ctx->parent)
ctx->parent = ctx->parent->parent;
}
;
%%

View File

@ -4,18 +4,19 @@
This file is part of libconfig. This file is part of libconfig.
This library is free software; you can redistribute it and/or modify This library is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU Lesser General Public License
the Free Software Foundation, either version 3 of the License, or as published by the Free Software Foundation; either version 2.1 of
(at your option) any later version. the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU Library General Public
along with this library. If not, see <http://www.gnu.org/licenses/>. License along with this library; if not, see
<http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
*/ */
@ -535,12 +536,12 @@ static int __config_validate_name(const char *name)
if(*p == '\0') if(*p == '\0')
return(CONFIG_FALSE); return(CONFIG_FALSE);
if(! isalpha((unsigned char)*p) && (*p != '*')) if(! isalpha((int)*p) && (*p != '*'))
return(CONFIG_FALSE); return(CONFIG_FALSE);
for(++p; *p; ++p) for(++p; *p; ++p)
{ {
if(! (isalpha((unsigned char)*p) || isdigit((unsigned char)*p) || strchr("*_-", (int)*p))) if(! (isalpha((int)*p) || isdigit((int)*p) || strchr("*_-", (int)*p)))
return(CONFIG_FALSE); return(CONFIG_FALSE);
} }

View File

@ -4,18 +4,19 @@
This file is part of libconfig. This file is part of libconfig.
This library is free software; you can redistribute it and/or modify This library is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU Lesser General Public License
the Free Software Foundation, either version 3 of the License, or as published by the Free Software Foundation; either version 2.1 of
(at your option) any later version. the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU Library General Public
along with this library. If not, see <http://www.gnu.org/licenses/>. License along with this library; if not, see
<http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
*/ */
@ -40,7 +41,7 @@ extern "C" {
#define LIBCONFIG_VER_MAJOR 1 #define LIBCONFIG_VER_MAJOR 1
#define LIBCONFIG_VER_MINOR 4 #define LIBCONFIG_VER_MINOR 4
#define LIBCONFIG_VER_REVISION 8 #define LIBCONFIG_VER_REVISION 9
#include <stdio.h> #include <stdio.h>

View File

@ -4,18 +4,19 @@
This file is part of libconfig. This file is part of libconfig.
This library is free software; you can redistribute it and/or modify This library is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU Lesser General Public License
the Free Software Foundation, either version 3 of the License, or as published by the Free Software Foundation; either version 2.1 of
(at your option) any later version. the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU Library General Public
along with this library. If not, see <http://www.gnu.org/licenses/>. License along with this library; if not, see
<http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
*/ */

View File

@ -4,18 +4,19 @@
This file is part of libconfig. This file is part of libconfig.
This library is free software; you can redistribute it and/or modify This library is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU Lesser General Public License
the Free Software Foundation, either version 3 of the License, or as published by the Free Software Foundation; either version 2.1 of
(at your option) any later version. the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU Library General Public
along with this library. If not, see <http://www.gnu.org/licenses/>. License along with this library; if not, see
<http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
*/ */

View File

@ -4,18 +4,19 @@
This file is part of libconfig. This file is part of libconfig.
This library is free software; you can redistribute it and/or modify This library is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU Lesser General Public License
the Free Software Foundation, either version 3 of the License, or as published by the Free Software Foundation; either version 2.1 of
(at your option) any later version. the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU Library General Public
along with this library. If not, see <http://www.gnu.org/licenses/>. License along with this library; if not, see
<http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
*/ */

View File

@ -369,8 +369,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
*yy_cp = '\0'; \ *yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp; yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 41 #define YY_NUM_RULES 42
#define YY_END_OF_BUFFER 42 #define YY_END_OF_BUFFER 43
/* This struct is not used in this scanner, /* This struct is not used in this scanner,
but its presence is necessary. */ but its presence is necessary. */
struct yy_trans_info struct yy_trans_info
@ -380,18 +380,18 @@ struct yy_trans_info
}; };
static yyconst flex_int16_t yy_accept[103] = static yyconst flex_int16_t yy_accept[103] =
{ 0, { 0,
0, 0, 0, 0, 0, 0, 0, 0, 42, 40, 0, 0, 0, 0, 0, 0, 0, 0, 43, 41,
21, 20, 20, 5, 40, 36, 37, 28, 40, 23, 22, 21, 21, 5, 41, 37, 38, 29, 41, 24,
29, 40, 30, 30, 22, 38, 28, 28, 34, 35, 30, 41, 31, 31, 23, 39, 29, 29, 35, 36,
24, 25, 21, 40, 3, 4, 3, 6, 14, 41, 25, 26, 22, 41, 3, 4, 3, 6, 15, 14,
16, 19, 41, 21, 0, 39, 28, 29, 30, 29, 17, 20, 42, 22, 0, 40, 29, 30, 31, 30,
0, 1, 0, 29, 0, 31, 0, 28, 28, 21, 0, 1, 0, 30, 0, 32, 0, 29, 29, 22,
0, 0, 2, 6, 12, 0, 11, 10, 7, 8, 0, 0, 2, 6, 12, 0, 11, 10, 7, 8,
9, 16, 18, 17, 0, 29, 29, 0, 0, 29, 9, 17, 19, 18, 0, 30, 30, 0, 0, 30,
31, 32, 28, 28, 0, 0, 0, 29, 33, 28, 32, 33, 29, 29, 0, 0, 0, 30, 34, 29,
26, 0, 13, 33, 27, 0, 0, 0, 0, 0, 27, 0, 13, 34, 28, 0, 0, 0, 0, 0,
15, 0 16, 0
} ; } ;
static yyconst flex_int32_t yy_ec[256] = static yyconst flex_int32_t yy_ec[256] =
@ -534,11 +534,11 @@ static yyconst flex_int16_t yy_chk[253] =
} ; } ;
/* Table of booleans, true if rule could match eol. */ /* Table of booleans, true if rule could match eol. */
static yyconst flex_int32_t yy_rule_can_match_eol[42] = static yyconst flex_int32_t yy_rule_can_match_eol[43] =
{ 0, { 0,
0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, }; 0, 0, 0, };
/* The intent behind this definition is that it'll catch /* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed. * any uses of REJECT which flex missed.
@ -1037,36 +1037,41 @@ YY_RULE_SETUP
case 14: case 14:
YY_RULE_SETUP YY_RULE_SETUP
#line 120 "scanner.l" #line 120 "scanner.l"
{ scanctx_append_string(yyextra, "\\"); }
YY_BREAK
case 15:
YY_RULE_SETUP
#line 121 "scanner.l"
{ {
yylval->sval = scanctx_take_string(yyextra); yylval->sval = scanctx_take_string(yyextra);
BEGIN INITIAL; BEGIN INITIAL;
return(TOK_STRING); return(TOK_STRING);
} }
YY_BREAK YY_BREAK
case 15:
YY_RULE_SETUP
#line 126 "scanner.l"
{ BEGIN INCLUDE; }
YY_BREAK
case 16: case 16:
/* rule 16 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 127 "scanner.l" #line 127 "scanner.l"
{ scanctx_append_string(yyextra, yytext); } { BEGIN INCLUDE; }
YY_BREAK YY_BREAK
case 17: case 17:
/* rule 17 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 128 "scanner.l" #line 128 "scanner.l"
{ scanctx_append_string(yyextra, "\\"); } { scanctx_append_string(yyextra, yytext); }
YY_BREAK YY_BREAK
case 18: case 18:
YY_RULE_SETUP YY_RULE_SETUP
#line 129 "scanner.l" #line 129 "scanner.l"
{ scanctx_append_string(yyextra, "\""); } { scanctx_append_string(yyextra, "\\"); }
YY_BREAK YY_BREAK
case 19: case 19:
YY_RULE_SETUP YY_RULE_SETUP
#line 130 "scanner.l" #line 130 "scanner.l"
{ scanctx_append_string(yyextra, "\""); }
YY_BREAK
case 20:
YY_RULE_SETUP
#line 131 "scanner.l"
{ {
const char *error; const char *error;
FILE *fp = scanctx_push_include(yyextra, FILE *fp = scanctx_push_include(yyextra,
@ -1089,123 +1094,123 @@ YY_RULE_SETUP
BEGIN INITIAL; BEGIN INITIAL;
} }
YY_BREAK YY_BREAK
case 20:
/* rule 20 can match eol */
YY_RULE_SETUP
#line 154 "scanner.l"
{ /* ignore */ }
YY_BREAK
case 21: case 21:
/* rule 21 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 155 "scanner.l" #line 155 "scanner.l"
{ /* ignore */ } { /* ignore */ }
YY_BREAK YY_BREAK
case 22: case 22:
YY_RULE_SETUP YY_RULE_SETUP
#line 157 "scanner.l" #line 156 "scanner.l"
{ return(TOK_EQUALS); } { /* ignore */ }
YY_BREAK YY_BREAK
case 23: case 23:
YY_RULE_SETUP YY_RULE_SETUP
#line 158 "scanner.l" #line 158 "scanner.l"
{ return(TOK_COMMA); } { return(TOK_EQUALS); }
YY_BREAK YY_BREAK
case 24: case 24:
YY_RULE_SETUP YY_RULE_SETUP
#line 159 "scanner.l" #line 159 "scanner.l"
{ return(TOK_GROUP_START); } { return(TOK_COMMA); }
YY_BREAK YY_BREAK
case 25: case 25:
YY_RULE_SETUP YY_RULE_SETUP
#line 160 "scanner.l" #line 160 "scanner.l"
{ return(TOK_GROUP_END); } { return(TOK_GROUP_START); }
YY_BREAK YY_BREAK
case 26: case 26:
YY_RULE_SETUP YY_RULE_SETUP
#line 161 "scanner.l" #line 161 "scanner.l"
{ yylval->ival = 1; return(TOK_BOOLEAN); } { return(TOK_GROUP_END); }
YY_BREAK YY_BREAK
case 27: case 27:
YY_RULE_SETUP YY_RULE_SETUP
#line 162 "scanner.l" #line 162 "scanner.l"
{ yylval->ival = 0; return(TOK_BOOLEAN); } { yylval->ival = 1; return(TOK_BOOLEAN); }
YY_BREAK YY_BREAK
case 28: case 28:
YY_RULE_SETUP YY_RULE_SETUP
#line 163 "scanner.l" #line 163 "scanner.l"
{ yylval->sval = yytext; return(TOK_NAME); } { yylval->ival = 0; return(TOK_BOOLEAN); }
YY_BREAK YY_BREAK
case 29: case 29:
YY_RULE_SETUP YY_RULE_SETUP
#line 164 "scanner.l" #line 164 "scanner.l"
{ yylval->fval = atof(yytext); return(TOK_FLOAT); } { yylval->sval = yytext; return(TOK_NAME); }
YY_BREAK YY_BREAK
case 30: case 30:
YY_RULE_SETUP YY_RULE_SETUP
#line 165 "scanner.l" #line 165 "scanner.l"
{ yylval->ival = atoi(yytext); return(TOK_INTEGER); } { yylval->fval = atof(yytext); return(TOK_FLOAT); }
YY_BREAK YY_BREAK
case 31: case 31:
YY_RULE_SETUP YY_RULE_SETUP
#line 166 "scanner.l" #line 166 "scanner.l"
{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); } { yylval->ival = atoi(yytext); return(TOK_INTEGER); }
YY_BREAK YY_BREAK
case 32: case 32:
YY_RULE_SETUP YY_RULE_SETUP
#line 167 "scanner.l" #line 167 "scanner.l"
{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
YY_BREAK
case 33:
YY_RULE_SETUP
#line 168 "scanner.l"
{ {
yylval->ival = strtoul(yytext, NULL, 16); yylval->ival = strtoul(yytext, NULL, 16);
return(TOK_HEX); return(TOK_HEX);
} }
YY_BREAK YY_BREAK
case 33:
YY_RULE_SETUP
#line 171 "scanner.l"
{ yylval->llval = fromhex(yytext); return(TOK_HEX64); }
YY_BREAK
case 34: case 34:
YY_RULE_SETUP YY_RULE_SETUP
#line 172 "scanner.l" #line 172 "scanner.l"
{ return(TOK_ARRAY_START); } { yylval->llval = fromhex(yytext); return(TOK_HEX64); }
YY_BREAK YY_BREAK
case 35: case 35:
YY_RULE_SETUP YY_RULE_SETUP
#line 173 "scanner.l" #line 173 "scanner.l"
{ return(TOK_ARRAY_END); } { return(TOK_ARRAY_START); }
YY_BREAK YY_BREAK
case 36: case 36:
YY_RULE_SETUP YY_RULE_SETUP
#line 174 "scanner.l" #line 174 "scanner.l"
{ return(TOK_LIST_START); } { return(TOK_ARRAY_END); }
YY_BREAK YY_BREAK
case 37: case 37:
YY_RULE_SETUP YY_RULE_SETUP
#line 175 "scanner.l" #line 175 "scanner.l"
{ return(TOK_LIST_END); } { return(TOK_LIST_START); }
YY_BREAK YY_BREAK
case 38: case 38:
YY_RULE_SETUP YY_RULE_SETUP
#line 176 "scanner.l" #line 176 "scanner.l"
{ return(TOK_SEMICOLON); } { return(TOK_LIST_END); }
YY_BREAK YY_BREAK
case 39: case 39:
YY_RULE_SETUP
#line 177 "scanner.l"
{ return(TOK_SEMICOLON); }
YY_BREAK
case 40:
*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
yyg->yy_c_buf_p = yy_cp -= 1; yyg->yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP YY_RULE_SETUP
#line 177 "scanner.l" #line 178 "scanner.l"
{ /* ignore */ } { /* ignore */ }
YY_BREAK YY_BREAK
case 40: case 41:
YY_RULE_SETUP YY_RULE_SETUP
#line 178 "scanner.l" #line 179 "scanner.l"
{ return(TOK_GARBAGE); } { return(TOK_GARBAGE); }
YY_BREAK YY_BREAK
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(COMMENT):
case YY_STATE_EOF(STRING): case YY_STATE_EOF(STRING):
case YY_STATE_EOF(INCLUDE): case YY_STATE_EOF(INCLUDE):
#line 180 "scanner.l" #line 181 "scanner.l"
{ {
YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include( YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include(
yyextra); yyextra);
@ -1218,12 +1223,12 @@ case YY_STATE_EOF(INCLUDE):
yyterminate(); yyterminate();
} }
YY_BREAK YY_BREAK
case 41: case 42:
YY_RULE_SETUP YY_RULE_SETUP
#line 191 "scanner.l" #line 192 "scanner.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1227 "scanner.c" #line 1232 "scanner.c"
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
{ {
@ -2359,4 +2364,4 @@ void libconfig_yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables" #define YYTABLES_NAME "yytables"
#line 191 "scanner.l" #line 192 "scanner.l"

191
3rdparty/libconfig/scanner.l vendored Normal file
View File

@ -0,0 +1,191 @@
/* -*- mode: C -*- */
/* --------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
Copyright (C) 2005-2010 Mark A Lindner
This file is part of libconfig.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, see
<http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------
*/
%option nounistd
%option reentrant
%option noyywrap
%option yylineno
%option nounput
%option bison-bridge
%option header-file="scanner.h"
%option outfile="lex.yy.c"
%option extra-type="struct scan_context *"
%{
#ifdef _MSC_VER
#pragma warning (disable: 4996)
#endif
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "grammar.h"
#include "wincompat.h"
#include "parsectx.h"
#include "scanctx.h"
#define YY_NO_INPUT // Suppress generation of useless input() function
static unsigned long long fromhex(const char *s)
{
#ifdef __MINGW32__
/* MinGW's strtoull() seems to be broken; it only returns the lower
* 32 bits...
*/
const char *p = s;
unsigned long long val = 0;
if(*p != '0')
return(0);
++p;
if(*p != 'x' && *p != 'X')
return(0);
for(++p; isxdigit(*p); ++p)
{
val <<= 4;
val |= ((*p < 'A') ? (*p & 0xF) : (9 + (*p & 0x7)));
}
return(val);
#else /* ! __MINGW32__ */
return(strtoull(s, NULL, 16));
#endif /* __MINGW32__ */
}
%}
true [Tt][Rr][Uu][Ee]
false [Ff][Aa][Ll][Ss][Ee]
name [A-Za-z\*][-A-Za-z0-9_\*]*
integer [-+]?[0-9]+
integer64 [-+]?[0-9]+L(L)?
hex 0[Xx][0-9A-Fa-f]+
hex64 0[Xx][0-9A-Fa-f]+L(L)?
hexchar \\[Xx][0-9A-Fa-f]{2}
float ([-+]?([0-9]*)?\.[0-9]*([eE][-+]?[0-9]+)?)|([-+]?([0-9]+)(\.[0-9]*)?[eE][-+]?[0-9]+)
comment (#|\/\/).*$
include_open ^[ \t]*@include[ \t]+\"
%x COMMENT STRING INCLUDE
%%
\/\* { BEGIN COMMENT; }
<COMMENT>\*\/ { BEGIN INITIAL; }
<COMMENT>. { /* ignore */ }
<COMMENT>\n { /* ignore */ }
\" { BEGIN STRING; }
<STRING>[^\"\\]+ { scanctx_append_string(yyextra, yytext); }
<STRING>\\n { scanctx_append_string(yyextra, "\n"); }
<STRING>\\r { scanctx_append_string(yyextra, "\r"); }
<STRING>\\t { scanctx_append_string(yyextra, "\t"); }
<STRING>\\f { scanctx_append_string(yyextra, "\f"); }
<STRING>\\\\ { scanctx_append_string(yyextra, "\\"); }
<STRING>\\\" { scanctx_append_string(yyextra, "\""); }
<STRING>{hexchar} {
char c[2] = { (char)(strtol(yytext + 2, NULL, 16) & 0xFF),
0 };
scanctx_append_string(yyextra, c);
}
<STRING>\\ { scanctx_append_string(yyextra, "\\"); }
<STRING>\" {
yylval->sval = scanctx_take_string(yyextra);
BEGIN INITIAL;
return(TOK_STRING);
}
{include_open} { BEGIN INCLUDE; }
<INCLUDE>[^\"\\]+ { scanctx_append_string(yyextra, yytext); }
<INCLUDE>\\\\ { scanctx_append_string(yyextra, "\\"); }
<INCLUDE>\\\" { scanctx_append_string(yyextra, "\""); }
<INCLUDE>\" {
const char *error;
FILE *fp = scanctx_push_include(yyextra,
(void *)YY_CURRENT_BUFFER,
&error);
if(fp)
{
yyin = fp;
yy_switch_to_buffer(
yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner),
yyscanner);
}
else
{
yyextra->config->error_text = error;
yyextra->config->error_file = scanctx_current_filename(
yyextra);
yyextra->config->error_line = libconfig_yyget_lineno(
yyscanner);
return TOK_ERROR;
}
BEGIN INITIAL;
}
\n|\r|\f { /* ignore */ }
[ \t]+ { /* ignore */ }
\=|\: { return(TOK_EQUALS); }
, { return(TOK_COMMA); }
\{ { return(TOK_GROUP_START); }
\} { return(TOK_GROUP_END); }
{true} { yylval->ival = 1; return(TOK_BOOLEAN); }
{false} { yylval->ival = 0; return(TOK_BOOLEAN); }
{name} { yylval->sval = yytext; return(TOK_NAME); }
{float} { yylval->fval = atof(yytext); return(TOK_FLOAT); }
{integer} { yylval->ival = atoi(yytext); return(TOK_INTEGER); }
{integer64} { yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
{hex} {
yylval->ival = strtoul(yytext, NULL, 16);
return(TOK_HEX);
}
{hex64} { yylval->llval = fromhex(yytext); return(TOK_HEX64); }
\[ { return(TOK_ARRAY_START); }
\] { return(TOK_ARRAY_END); }
\( { return(TOK_LIST_START); }
\) { return(TOK_LIST_END); }
; { return(TOK_SEMICOLON); }
{comment} { /* ignore */ }
. { return(TOK_GARBAGE); }
<<EOF>> {
YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include(
yyextra);
if(buf)
{
yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);
yy_switch_to_buffer(buf, yyscanner);
}
else
yyterminate();
}

View File

@ -4,18 +4,19 @@
This file is part of libconfig. This file is part of libconfig.
This library is free software; you can redistribute it and/or modify This library is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU Lesser General Public License
the Free Software Foundation, either version 3 of the License, or as published by the Free Software Foundation; either version 2.1 of
(at your option) any later version. the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU Library General Public
along with this library. If not, see <http://www.gnu.org/licenses/>. License along with this library; if not, see
<http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
*/ */

View File

@ -4,18 +4,19 @@
This file is part of libconfig. This file is part of libconfig.
This library is free software; you can redistribute it and/or modify This library is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU Lesser General Public License
the Free Software Foundation, either version 3 of the License, or as published by the Free Software Foundation; either version 2.1 of
(at your option) any later version. the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU Library General Public
along with this library. If not, see <http://www.gnu.org/licenses/>. License along with this library; if not, see
<http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
*/ */

View File

@ -4,18 +4,19 @@
This file is part of libconfig. This file is part of libconfig.
This library is free software; you can redistribute it and/or modify This library is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU Lesser General Public License
the Free Software Foundation, either version 3 of the License, or as published by the Free Software Foundation; either version 2.1 of
(at your option) any later version. the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU Library General Public
along with this library. If not, see <http://www.gnu.org/licenses/>. License along with this library; if not, see
<http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
*/ */