[ragel-users] Re: Bug or feature?
Carlos Antunes
cmantu... at gmail.com
Fri Jul 20 15:00:29 UTC 2007
On 7/20/07, Adrian Thurston <thurs... at cs.queensu.ca> wrote:
> Carlos Antunes wrote:
> > machine_a = machine_b %action_b machine_c
> >
> > Now, this is semantically equivalent to (assuming that ">" is really
> > associated with the start state:
> >
> > machine_a = machine_b machine_c >action_b
>
> They are not quite equivalent. Consider the case of machine_c accepting
> the zero-length word (start state is final). Then action_b will be a
> pending out action of machine_a.
>
Adrian, my point is that when the start and final states are one and
the same, there is no difference between "pending in" and "pending
out". In the example above, and using the old semantics, ">action_b"
may indeed represent a "pending out". But this is consistent with what
I've said: there is no semantic difference between "pending_in" and
"pending_out" when start and final states are one and the same. And
the empty machine just so happens to have a start state
indistinguishable from a final one, no?
>
> One thing I don't like about the syntax you propose is that it creates
> an ambiguity in the ragel language itself. When you parse % is it
> associated with the tree on the left or the tree on the right?
>
At the end of the day, I don't think it matters. The end result, from
a semantic point of view, is the same. After all, from a semantic
point of view "(expr1 %action) expr2" is the same as "expr1 (%action
expr2)".
>
>Right now all embedding operators are currently of this form:
>
> <expr> <op> <action>
>
> and this syntax changes that.
>
Yes, you are right.
>
> Also note that you can achieve the same thing using the existing
> language by putting "" in front of %. Like this:
>
> machine_a = machine_b ( ""%action_b machine_c );
>
> So that brings up an interesting point. The line directly above is
> another way to emulate the old semantics of >.
>
Indeed and that is, right now, the best practical way to recover the
old semantics.
However, allow me to be mathematical one more time:
machine_a = machine_b ( ""%action_b machine_c )
<=> machine_a = ( machine_b ""%action_b ) machine_c
<=> machine_a = ( machine_b "" ) %action_b machine_c
<=> machine_a = ( machine_b ) %action_b machine_c
<=> machine_a = machine_b ( %action_b machine_c)
Obviously, "<=>" refers to semantic rather than syntactic equivalence.
But the end result is always the same: no difference in the way the
FSM "sees" the "%" operator. In reality, I guess one could call it
simply the "transition between machines" operator because that's the
way a FSM sees it. The ">" in the old semantics would simply be a
redundant beast.
However, I understand the syntactic simplicity of "<expr> <op>
<action>" and, as much as I think it would be cool, it is not that
important from a practical point of view. Maybe, as a suggestion, you
could mention the ( "" %action ) trick in the documentation?
Thanks!
Carlos
--
"We hold [...] that all men are created equal; that they are
endowed [...] with certain inalienable rights; that among
these are life, liberty, and the pursuit of happiness"
-- Thomas Jefferson
More information about the ragel-users
mailing list