File: afsql-grammar.ym

package info (click to toggle)
syslog-ng 4.8.1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,456 kB
  • sloc: ansic: 177,631; python: 13,035; cpp: 11,611; makefile: 7,012; sh: 5,147; java: 3,651; xml: 3,344; yacc: 1,377; lex: 599; perl: 193; awk: 190; objc: 162
file content (146 lines) | stat: -rw-r--r-- 5,081 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
 * Copyright (c) 2002-2013 Balabit
 * Copyright (c) 1998-2013 Balázs Scheidler
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation, or (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * As an additional exemption you are allowed to compile & link against the
 * OpenSSL libraries as published by the OpenSSL project. See the file
 * COPYING for details.
 *
 */

%code top {
#include "afsql-parser.h"

}


%code {

#include "afsql.h"
#include "cfg-grammar-internal.h"
#include "cfg-helpers.h"
#include "cfg-parser.h"
#include "messages.h"
#include "plugin.h"

}

%define api.prefix {afsql_}

/* this parameter is needed in order to instruct bison to use a complete
 * argument list for yylex/yyerror */

%lex-param {CfgLexer *lexer}
%parse-param {CfgLexer *lexer}
%parse-param {LogDriver **instance}
%parse-param {gpointer arg}


/* INCLUDE_DECLS */

%token KW_DEFAULT
%token KW_DBD_OPTION
%token KW_DBI_DRIVER_DIR
%token KW_QUOTE_CHAR
%token KW_INDEXES
%token KW_VALUES
%token KW_SQL
%token KW_PASSWORD
%token KW_USERNAME
%token KW_DATABASE
%token KW_TABLE
%token KW_SESSION_STATEMENTS
%token KW_CREATE_STATEMENT_APPEND
%token KW_COLUMNS
%token KW_NULL
%token KW_IGNORE_TNS_CONFIG

%type   <ptr> dest_afsql
%type   <ptr> dest_afsql_params
%type   <ptr> dest_afsql_values
%type   <ptr> dest_afsql_values_build
%type   <num> dest_afsql_flags

%%

start
        : LL_CONTEXT_DESTINATION dest_afsql                        { YYACCEPT; }
        ;


dest_afsql
        : KW_SQL '(' _inner_dest_context_push dest_afsql_params _inner_dest_context_pop ')'	{ $$ = $4; }
        ;

dest_afsql_params
        :
          {
            last_driver = *instance = afsql_dd_new(configuration);
          }
          dest_afsql_options			{ $$ = last_driver; }
        ;

dest_afsql_options
        : dest_afsql_option dest_afsql_options
        |
        ;

dest_afsql_option
        : KW_TYPE '(' string ')'		{ afsql_dd_set_type(last_driver, $3); free($3); }
        | KW_HOST '(' string ')'		{ afsql_dd_set_host(last_driver, $3); free($3); }
        | KW_PORT '(' string_or_number ')' { CHECK_ERROR(cfg_check_port($3), @3, "Illegal port number: %s", $3); afsql_dd_set_port(last_driver, $3); free($3); }
        | KW_USERNAME '(' string ')'		{ afsql_dd_set_user(last_driver, $3); free($3); }
        | KW_DBD_OPTION '(' string LL_NUMBER ')' { afsql_dd_add_dbd_option_numeric(last_driver, $3, $4); free($3); }
        | KW_DBD_OPTION '(' string string ')'    { afsql_dd_add_dbd_option(last_driver, $3, $4); free($3); free($4); }
        | KW_DBI_DRIVER_DIR '(' path ')'        { afsql_dd_set_dbi_driver_dir(last_driver, $3); free($3); }
        | KW_QUOTE_CHAR '(' string ')'          { afsql_dd_set_quote_char(last_driver, $3); }
        | KW_PASSWORD '(' string ')'		{ afsql_dd_set_password(last_driver, $3); free($3); }
        | KW_DATABASE '(' string ')'		{ afsql_dd_set_database(last_driver, $3); free($3); }
        | KW_TABLE '(' template_content ')'	{ afsql_dd_set_table(last_driver, $3); }
        | KW_COLUMNS '(' string_list ')'	{ afsql_dd_set_columns(last_driver, $3); }
        | KW_INDEXES '(' string_list ')'        { afsql_dd_set_indexes(last_driver, $3); }
        | KW_VALUES '(' dest_afsql_values ')'   { afsql_dd_set_values(last_driver, $3); }
        | KW_IGNORE_TNS_CONFIG '(' yesno ')'    { afsql_dd_set_ignore_tns_config(last_driver,$3); }
        | KW_NULL '(' string ')'                { afsql_dd_set_null_value(last_driver, $3); free($3); }
        | KW_SESSION_STATEMENTS '(' string_list ')' { afsql_dd_set_session_statements(last_driver, $3); }
	| KW_FLAGS '(' dest_afsql_flags ')'
	| KW_CREATE_STATEMENT_APPEND '(' string ')' { afsql_dd_set_create_statement_append(last_driver, $3); free($3); }

	| { last_template_options = &((AFSqlDestDriver *) last_driver)->template_options; } template_option
	| threaded_dest_driver_general_option_noflags
        | threaded_dest_driver_batch_option
        ;

dest_afsql_values
        : dest_afsql_values_build               { $$ = g_list_reverse($1); }
        ;

dest_afsql_values_build
        : template_content dest_afsql_values_build	{ $$ = g_list_append($2, log_template_ref($1)); log_template_unref($1); }
        | KW_DEFAULT dest_afsql_values_build	{ $$ = g_list_append($2, NULL); }
        |					{ $$ = NULL; }
        ;

dest_afsql_flags
        : string dest_afsql_flags     { CHECK_ERROR(afsql_dd_process_flag(last_driver, $1), @1, "Unknown flag \"%s\"", $1); free($1); }
        |
        ;


/* INCLUDE_RULES */

%%