|
Proto : |
Subject: [proto] Using Phoenix inside eUML: mixing grammars
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2011-03-16 16:56:09
Hi,
I have my eUML grammar, defing, for example a transition as:
SourceState+ Event [some_guard] == TargetState
I want to write for some_guard an expression of a phoenix grammar. The
relevant part of the expression is:
Event [some_guard]
Where the corresponding part of my grammar is:
struct BuildEventPlusGuard
: proto::when<
proto::subscript<proto::terminal<event_tag>,BuildGuards >,
TempRow<none,proto::_left,none,none,BuildGuards(proto::_right)>()
>
{};
BuildGuards is, at the moment, a proto::switch_ grammar, which I want
to replace with something matching a phoenix grammar and returning me
a phoenix::actor<Expr>, which I will then save into TempRow.
I suppose I could typeof/decltype the phoenix expression but it
doesn't seem like the best solution, I'd prefer to delay this.
Is there something like a phoenix grammar which I can call to check if
the expression is valid, and if yes, which will return me the correct
phoenix::actor?
Second question. Now it's becoming more "interesting". And not easy to
explain :(
For eUML, a guard can be defined as "g1 && g2", where g1 and g2 are
functors, taking 4 arguments. For example (to make short):
struct g1_
{
template <class FSM,class EVT,class SourceState,class TargetState>
void operator()(EVT const& ,FSM&,SourceState& ,TargetState& )
{
...
}
};
g1_ g1;
The fact that there are 4 arguments is the condition to make this work
without placeholders.
I 'm pretty sure that, while this clearly should be a function for
phoenix, I would not like the syntax:
g1(arg1,arg2,arg3,arg4) && g2(arg1,arg2,arg3,arg4).
Is it possible to define g1 and g2 as custom terminals, but still get
them treated like functions?
(To solve the problem, my current implementation generates me a
functor of type And_<g1,g2> which has an operator () with 4
arguments).
Thanks,
Christophe
Proto list run by eric at boostpro.com