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 ** _________________________________________________________________
47 %token <cpVal> T_DIGIT
49 %token <cpVal> T_STRING
50 %token <cpVal> T_REGEX
51 %token <cpVal> T_REGEX_I
74 %type <exVal> comparison
75 %type <exVal> funccall
82 root : expr { ssl_expr_info.expr = $1; }
85 expr : T_TRUE { $$ = ssl_expr_make(op_True, NULL, NULL); }
86 | T_FALSE { $$ = ssl_expr_make(op_False, NULL, NULL); }
87 | T_OP_NOT expr { $$ = ssl_expr_make(op_Not, $2, NULL); }
88 | expr T_OP_OR expr { $$ = ssl_expr_make(op_Or, $1, $3); }
89 | expr T_OP_AND expr { $$ = ssl_expr_make(op_And, $1, $3); }
90 | comparison { $$ = ssl_expr_make(op_Comp, $1, NULL); }
91 | '(' expr ')' { $$ = $2; }
94 comparison: word T_OP_EQ word { $$ = ssl_expr_make(op_EQ, $1, $3); }
95 | word T_OP_NE word { $$ = ssl_expr_make(op_NE, $1, $3); }
96 | word T_OP_LT word { $$ = ssl_expr_make(op_LT, $1, $3); }
97 | word T_OP_LE word { $$ = ssl_expr_make(op_LE, $1, $3); }
98 | word T_OP_GT word { $$ = ssl_expr_make(op_GT, $1, $3); }
99 | word T_OP_GE word { $$ = ssl_expr_make(op_GE, $1, $3); }
100 | word T_OP_IN '{' words '}' { $$ = ssl_expr_make(op_IN, $1, $4); }
101 | word T_OP_REG regex { $$ = ssl_expr_make(op_REG, $1, $3); }
102 | word T_OP_NRE regex { $$ = ssl_expr_make(op_NRE, $1, $3); }
105 words : word { $$ = ssl_expr_make(op_ListElement, $1, NULL); }
106 | words ',' word { $$ = ssl_expr_make(op_ListElement, $3, $1); }
109 word : T_DIGIT { $$ = ssl_expr_make(op_Digit, $1, NULL); }
110 | T_STRING { $$ = ssl_expr_make(op_String, $1, NULL); }
111 | '%' '{' T_ID '}' { $$ = ssl_expr_make(op_Var, $3, NULL); }
112 | funccall { $$ = $1; }
117 if ((regex = ap_pregcomp(ssl_expr_info.pool, $1,
118 REG_EXTENDED|REG_NOSUB)) == NULL) {
119 ssl_expr_error = "Failed to compile regular expression";
122 $$ = ssl_expr_make(op_Regex, regex, NULL);
126 if ((regex = ap_pregcomp(ssl_expr_info.pool, $1,
127 REG_EXTENDED|REG_NOSUB|REG_ICASE)) == NULL) {
128 ssl_expr_error = "Failed to compile regular expression";
131 $$ = ssl_expr_make(op_Regex, regex, NULL);
135 funccall : T_FUNC_FILE '(' T_STRING ')' {
136 ssl_expr *args = ssl_expr_make(op_ListElement, $3, NULL);
137 $$ = ssl_expr_make(op_Func, "file", args);