Building rules through mixed-assignment operators?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Building rules through mixed-assignment operators?

Daryle Walker
Can the mixed assignment operators be used to build up a rule in piecemeal?
For example, turn this:

    expr = term >> *( '+' >> term );
    term = factor >> *( '*' >> factor );
    factor = int_p | '(' >> expr >> ')';

into:

    expr = term;
    expr >>= *( '+' >> term );  // or "expr %= '+'"
    term = factor;
    term >>= *( '*' >> factor );  // or "term %= '*'"
    factor = int_p;
    factor |= '(' >> expr >> ')';

(I haven't considered the full semantic consequences of such operators.)  We
could have: |= &= -= ^= >>= %=

--
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Building rules through mixed-assignment operators?

Carl Barron

On Sep 23, 2005, at 8:16 AM, Daryle Walker wrote:

> Can the mixed assignment operators be used to build up a rule in
> piecemeal?
> For example, turn this:
>
>     expr = term >> *( '+' >> term );
>     term = factor >> *( '*' >> factor );
>     factor = int_p | '(' >> expr >> ')';
>
> into:
>
>     expr = term;
>     expr >>= *( '+' >> term );  // or "expr %= '+'"
>     term = factor;
>     term >>= *( '*' >> factor );  // or "term %= '*'"
>     factor = int_p;
>     factor |= '(' >> expr >> ')';
>
> (I haven't considered the full semantic consequences of such
> operators.)  We
> could have: |= &= -= ^= >>= %=
>
    the usual meaning of x |= y is   x = x + y , in terms of spirt rule
thats left recursion
and an infinite loop.  Further rule<...> has is not 'copyable and
assignable', meaning
that operator = does not have the 'usual' semantics, but semantics
needed to emulate
ebnf.   That said I don't see any non confusing or really useful
overload,  perhaps
it is reasonable for stored_rule, but not rule.




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Building rules through mixed-assignment operators?

Carl Barron

On Sep 23, 2005, at 3:54 PM, Carl Barron wrote:

>
> On Sep 23, 2005, at 8:16 AM, Daryle Walker wrote:
>
>> Can the mixed assignment operators be used to build up a rule in
>> piecemeal?
>> For example, turn this:
>>
>>     expr = term >> *( '+' >> term );
>>     term = factor >> *( '*' >> factor );
>>     factor = int_p | '(' >> expr >> ')';
>>
>> into:
>>
>>     expr = term;
>>     expr >>= *( '+' >> term );  // or "expr %= '+'"
>>     term = factor;
>>     term >>= *( '*' >> factor );  // or "term %= '*'"
>>     factor = int_p;
>>     factor |= '(' >> expr >> ')';
>>
>> (I haven't considered the full semantic consequences of such
>> operators.)  We
>> could have: |= &= -= ^= >>= %=
>>
>    the usual meaning of x |= y is   x = x + y , in terms of spirt rule
> thats left recursion
> and an infinite loop.  Further rule<...> has is not 'copyable and
> assignable', meaning
> that operator = does not have the 'usual' semantics, but semantics
> needed to emulate
> ebnf.   That said I don't see any non confusing or really useful
> overload,  perhaps
> it is reasonable for stored_rule, but not rule.
>
>
>
   oops the usial meaning of x |=y is x = x | y , sorry for the typo of
the mind....




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general