Re: (a || b) is not the same as (a >> -b | b) !!!!

Joel de Guzman <[email protected]> Tue, 20 Oct 2020 08:43:10 +0800
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
On 10/20/20 1:34 am, Larry Evans wrote:
> On 10/19/20 12:09 PM, Juan Dent wrote:
>> Hi Joel and Larry,
>>
>> Indeed Larry is correct, I have no problem with the roman_numerals parser but with the stated equivalence of these 2 grammars:
>>
>> (a || b)
>>
>> (a >> -b | b)
>>
> [snip]
> 
> Hi Juan,
> 
> I think Joel, because he has had to dissect so many previous lines
> of spirit code, wants you to actually test the roman_numerals code
> to see if it fails.  If it does, then, since it, I assume,
> doesn't fail for Joel, the conclusion would be something else
> beside spirit is causing the difference.
> 
> Anyway, it would just reassure Joel that there really is
> a problem with spirit if you confirmed the roman_numerals code
> fails for you.
> 
> I know it's a hassle, but I think it would be a
> good "division of labor" ;)

I think I understand better now. There are actually two different definitions we're
looking at here. Syntactic equivalence and semantic equivalence. It is possible,
given the PEG nature of Spirit, for two syntactically equivalent grammars to have
different semantics.

So the question is, are they syntactically equivalent or not(?). Because typically,
when talking only about grammars in its purest form, that is what you care about.
Semantics of equal importance of course, but it is a separate thing.

I don't have time to look deeper, but that question should perhaps be the underlying
point in investigating both the roman_numerals code and your code.

1. Pure grammar alone, do they work as expected? If not, they are not
    syntactically equivalent.
2. With attributes, do they work as expected? If not, they are not
    semantically equivalent.

Either way, the documentation can probably make it clear, but I am 100%
convinced because, as I said, when talking only about grammars, the focus
is on syntax.

Regards,
-- 
Joel