1
/* Licensed to the Apache Software Foundation (ASF) under one or more
2
* contributor license agreements. See the NOTICE file distributed with
3
* this work for additional information regarding copyright ownership.
4
* The ASF licenses this file to You under the Apache License, Version 2.0
5
* (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
18
* _ __ ___ ___ __| | ___ ___| |
19
* | '_ ` _ \ / _ \ / _` | / __/ __| |
20
* | | | | | | (_) | (_| | \__ \__ \ | mod_ssl - Apache Interface to OpenSSL
21
* |_| |_| |_|\___/ \__,_|___|___/___/_| http://www.modssl.org/
24
* Expression LR(1) Parser
26
/* ``What you see is all you get.''
29
/* _________________________________________________________________
32
** _________________________________________________________________
36
#include "ssl_private.h"
47
%token <cpVal> T_DIGIT
49
%token <cpVal> T_STRING
50
%token <cpVal> T_REGEX
51
%token <cpVal> T_REGEX_I
75
%type <exVal> comparison
76
%type <exVal> funccall
79
%type <exVal> wordlist
84
root : expr { ssl_expr_info.expr = $1; }
87
expr : T_TRUE { $$ = ssl_expr_make(op_True, NULL, NULL); }
88
| T_FALSE { $$ = ssl_expr_make(op_False, NULL, NULL); }
89
| T_OP_NOT expr { $$ = ssl_expr_make(op_Not, $2, NULL); }
90
| expr T_OP_OR expr { $$ = ssl_expr_make(op_Or, $1, $3); }
91
| expr T_OP_AND expr { $$ = ssl_expr_make(op_And, $1, $3); }
92
| comparison { $$ = ssl_expr_make(op_Comp, $1, NULL); }
93
| '(' expr ')' { $$ = $2; }
96
comparison: word T_OP_EQ word { $$ = ssl_expr_make(op_EQ, $1, $3); }
97
| word T_OP_NE word { $$ = ssl_expr_make(op_NE, $1, $3); }
98
| word T_OP_LT word { $$ = ssl_expr_make(op_LT, $1, $3); }
99
| word T_OP_LE word { $$ = ssl_expr_make(op_LE, $1, $3); }
100
| word T_OP_GT word { $$ = ssl_expr_make(op_GT, $1, $3); }
101
| word T_OP_GE word { $$ = ssl_expr_make(op_GE, $1, $3); }
102
| word T_OP_IN wordlist { $$ = ssl_expr_make(op_IN, $1, $3); }
103
| word T_OP_REG regex { $$ = ssl_expr_make(op_REG, $1, $3); }
104
| word T_OP_NRE regex { $$ = ssl_expr_make(op_NRE, $1, $3); }
107
wordlist : T_OP_OID '(' word ')' { $$ = ssl_expr_make(op_OidListElement, $3, NULL); }
108
| '{' words '}' { $$ = $2 ; }
111
words : word { $$ = ssl_expr_make(op_ListElement, $1, NULL); }
112
| words ',' word { $$ = ssl_expr_make(op_ListElement, $3, $1); }
115
word : T_DIGIT { $$ = ssl_expr_make(op_Digit, $1, NULL); }
116
| T_STRING { $$ = ssl_expr_make(op_String, $1, NULL); }
117
| '%' '{' T_ID '}' { $$ = ssl_expr_make(op_Var, $3, NULL); }
118
| funccall { $$ = $1; }
123
if ((regex = ap_pregcomp(ssl_expr_info.pool, $1,
124
AP_REG_EXTENDED|AP_REG_NOSUB)) == NULL) {
125
ssl_expr_error = "Failed to compile regular expression";
128
$$ = ssl_expr_make(op_Regex, regex, NULL);
132
if ((regex = ap_pregcomp(ssl_expr_info.pool, $1,
133
AP_REG_EXTENDED|AP_REG_NOSUB|AP_REG_ICASE)) == NULL) {
134
ssl_expr_error = "Failed to compile regular expression";
137
$$ = ssl_expr_make(op_Regex, regex, NULL);
141
funccall : T_FUNC_FILE '(' T_STRING ')' {
142
ssl_expr *args = ssl_expr_make(op_ListElement, $3, NULL);
143
$$ = ssl_expr_make(op_Func, "file", args);