3 %extra_argument
{ssi_ctx_t
*ctx
}
8 #include "mod_ssi_expr.h"
19 %type expr
{ ssi_val_t
* }
20 %type value
{ buffer
* }
21 %type exprline
{ ssi_val_t
* }
23 %token_destructor
{ buffer_free
($$
); }
27 %nonassoc EQ NE GT GE LT LE.
30 input
::= exprline
(B
).
{
31 ctx
->val.bo
= ssi_val_tobool
(B
);
32 ctx
->val.type
= SSI_TYPE_BOOL
;
37 exprline
(A
) ::= expr
(B
) cond
(C
) expr
(D
).
{
40 if
(B
->type
== SSI_TYPE_STRING
&&
41 D
->type
== SSI_TYPE_STRING
) {
42 cmp
= strcmp
(B
->str
->ptr
, D
->str
->ptr
);
44 cmp
= ssi_val_tobool
(B
) - ssi_val_tobool
(D
);
50 case SSI_COND_EQ
: A
->bo
= (cmp
== 0) ?
1 : 0; break
;
51 case SSI_COND_NE
: A
->bo
= (cmp
!= 0) ?
1 : 0; break
;
52 case SSI_COND_GE
: A
->bo
= (cmp
>= 0) ?
1 : 0; break
;
53 case SSI_COND_GT
: A
->bo
= (cmp
> 0) ?
1 : 0; break
;
54 case SSI_COND_LE
: A
->bo
= (cmp
<= 0) ?
1 : 0; break
;
55 case SSI_COND_LT
: A
->bo
= (cmp
< 0) ?
1 : 0; break
;
58 A
->type
= SSI_TYPE_BOOL
;
62 exprline
(A
) ::= expr
(B
).
{
65 expr
(A
) ::= expr
(B
) AND expr
(C
).
{
68 e
= ssi_val_tobool
(B
) && ssi_val_tobool
(C
);
72 A
->type
= SSI_TYPE_BOOL
;
76 expr
(A
) ::= expr
(B
) OR expr
(C
).
{
79 e
= ssi_val_tobool
(B
) || ssi_val_tobool
(C
);
83 A
->type
= SSI_TYPE_BOOL
;
87 expr
(A
) ::= NOT expr
(B
).
{
90 e
= !ssi_val_tobool
(B
);
94 A
->type
= SSI_TYPE_BOOL
;
96 expr
(A
) ::= LPARAN exprline
(B
) RPARAN.
{
100 expr
(A
) ::= value
(B
).
{
103 A
->type
= SSI_TYPE_STRING
;
106 value
(A
) ::= VALUE
(B
).
{
110 value
(A
) ::= value
(B
) VALUE
(C
).
{
112 buffer_append_string_buffer
(A
, C
);
116 cond
(A
) ::= EQ.
{ A
= SSI_COND_EQ
; }
117 cond
(A
) ::= NE.
{ A
= SSI_COND_NE
; }
118 cond
(A
) ::= LE.
{ A
= SSI_COND_LE
; }
119 cond
(A
) ::= GE.
{ A
= SSI_COND_GE
; }
120 cond
(A
) ::= LT.
{ A
= SSI_COND_LT
; }
121 cond
(A
) ::= GT.
{ A
= SSI_COND_GT
; }