#include <stdio.h>
#include "Expr.h"
namespace
{
#define EXPR_ACCEPT_VISITOR_IMPL(TYPE)\
void TYPE::Accept(IExprVisitor* visitor)\
{\
visitor->Visit(this);\
}\
EXPR_TYPES(EXPR_ACCEPT_VISITOR_IMPL)
void
::
(
*
) {
->
(
this
); }
void
::
(
*
) {
->
(
this
); }
void
::
(
*
) {
->
(
this
); }
#undef EXPR_ACCEPT_VISITOR_IMPL
class
:
public
{
public
:
void
(
*
)
override
{
(
"%g"
,
->
);
}
void
(
*
)
override
{
switch
(
->
)
{
case
::
:
(
"-"
);
break
;
}
->
(
this
);
}
void
(
*
)
override
{
(
"("
);
->
(
this
);
switch
(
->
)
{
case
::
:
(
"+"
);
break
;
case
::
:
(
"-"
);
break
;
case
::
:
(
"*"
);
break
;
case
::
:
(
"/"
);
break
;
}
->
(
this
);
(
")"
);
}
};
void
(
const
::
&
)
{
;
(&
visitor
);
}
class
:
public
{
public
:
double
;
void
(
*
)
override
{
=
->
;
}
void
(
*
)
override
{
->
(
this
);
switch
(
->
)
{
case
::
:
= -
;
break
;
}
= -
;
}
void
(
*
)
override
{
double
= (
->
(
this
),
);
double
= (
->
(
this
),
);
switch
(
->
)
{
case
::
:
=
left
+
right
;
break
;
case
::
:
=
left
-
right
;
break
;
case
::
:
=
left
*
right
;
break
;
case
::
:
=
left
/
right
;
break
;
}
}
};
double
(
const
::
&
)
{
;
(&
visitor
);
return
visitor
.
;
}
}