File: timestamp-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 (165 lines) | stat: -rw-r--r-- 4,564 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
 * Copyright (c) 2015 Balabit
 * Copyright (c) 2015 Vincent Bernat <Vincent.Bernat@exoscale.ch>
 *
 * 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 requires {

#include "timestamp-parser.h"

}

%code {

#include "cfg-grammar-internal.h"
#include "cfg-parser.h"
#include "plugin.h"
#include "parser/parser-expr.h"
#include "date-parser.h"
#include "rewrite-fix-timezone.h"
#include "rewrite-set-timezone.h"
#include "rewrite-guess-timezone.h"

}

%define api.prefix {timestamp_}
%lex-param {CfgLexer *lexer}
%parse-param {CfgLexer *lexer}
%parse-param {gpointer *instance}
%parse-param {gpointer arg}

/* INCLUDE_DECLS */

%token KW_DATE_PARSER
%token KW_TIME_STAMP
%token KW_FIX_TIME_ZONE
%token KW_SET_TIME_ZONE
%token KW_GUESS_TIME_ZONE

%type <num> date_parser_stamp

%%

start
        : LL_CONTEXT_PARSER date_parser { YYACCEPT; }
	| LL_CONTEXT_REWRITE fix_timezone { YYACCEPT; }
	| LL_CONTEXT_REWRITE set_timezone { YYACCEPT; }
	| LL_CONTEXT_REWRITE guess_timezone { YYACCEPT; }
        ;

date_parser
        : KW_DATE_PARSER '('
          {
            last_parser = *instance = date_parser_new(configuration);
          }
          date_parser_options ')'
        ;

date_parser_options
        : date_parser_option date_parser_options
        |
        ;

date_parser_option
        : KW_FORMAT '(' string_list ')'             { date_parser_set_formats(last_parser, $3); }
        | KW_TIME_ZONE '(' string ')'               { date_parser_set_timezone(last_parser, $3); free($3); }
        | KW_TIME_STAMP '(' date_parser_stamp ')'   { date_parser_set_time_stamp(last_parser, $3); }
	| KW_VALUE '(' string ')'                   { date_parser_set_value(last_parser, $3); free($3); }
        | KW_FLAGS '(' date_parser_flags ')'
        | parser_opt
        ;

date_parser_stamp
        : string
          {
            $$ = log_msg_lookup_time_stamp_name($1);
            CHECK_ERROR($$ != -1, @1, "unknown time stamp name %s", $1);
            free($1);
          }

date_parser_flags
        : string date_parser_flags         { CHECK_ERROR(date_parser_process_flag(last_parser, $1), @1, "Unknown flag %s", $1); free($1); }
        |
        ;

fix_timezone
        : KW_FIX_TIME_ZONE
          {
            last_rewrite = *instance = rewrite_fix_time_zone_new(configuration);
          }
          '(' template_content fix_timezone_opts ')'
          {
            rewrite_fix_time_zone_set_zone_template_ref(*instance, $4);
          }
        ;

fix_timezone_opts
        : fix_timezone_opt fix_timezone_opts
        |
        ;

fix_timezone_opt
        : KW_TIME_STAMP '(' date_parser_stamp ')'  { rewrite_fix_time_zone_set_time_stamp(*instance, $3); }
	| rewrite_condition_opt
        ;

set_timezone
        : KW_SET_TIME_ZONE
          {
            last_rewrite = *instance = rewrite_set_time_zone_new(configuration);
          }
          '(' template_content set_timezone_opts ')'
          {
            rewrite_set_time_zone_set_zone_template_ref(*instance, $4);
          }
        ;

set_timezone_opts
        : set_timezone_opt set_timezone_opts
        |
        ;

set_timezone_opt
        : KW_TIME_STAMP '(' date_parser_stamp ')'  { rewrite_set_time_zone_set_time_stamp(*instance, $3); }
	| rewrite_condition_opt
        ;

guess_timezone
        : KW_GUESS_TIME_ZONE
          {
            last_rewrite = *instance = rewrite_guess_time_zone_new(configuration);
          }
          '(' guess_timezone_opts ')'
        ;

guess_timezone_opts
        : guess_timezone_opt guess_timezone_opts
        |
        ;

guess_timezone_opt
        : KW_TIME_STAMP '(' date_parser_stamp ')'  { rewrite_guess_time_zone_set_time_stamp(*instance, $3); }
	| rewrite_condition_opt
        ;

/* INCLUDE_RULES */

%%