/* -*- 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
.
----------------------------------------------------------------------------
*/
%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
#include
#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
#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 TOK_BOOLEAN TOK_INTEGER TOK_HEX
%token TOK_INTEGER64 TOK_HEX64
%token TOK_FLOAT
%token 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 =
#!/bin/shfor f in $@do /usr/X11R6/bin/convert -geomtry 702x576 $f test.mpg
test_video test.mpg
rm test.mpg
done