Kaz Kylheku
12/11/2015 3:47:00 PM
On 2015-12-11, Jim Newton <jimka.issy@gmail.com> wrote:
>
>> That diagnostic looks buggy to me. Your <concatenation> does not derive
>> <simple-re> -- certainly not directly; it derives <simple-re>
>> <basic-re>. (Of course it reduces to <simple-re> in the other
>> direction, but that's not derivation).
>>
>> <concatenation> could derive <simple-re> indirectly if <basic-re> derived
>> the empty string, but I don't see that anywhere.
>
> I FOUND A BUG IN MY GRAMMAR!!! yippieeeee
Aha, so the diagnostic isn't lying after all.
You see, it pays to read them diagnostics.
> The <concatenation> rule from the published grammar is
> <concatenation> ::= <simple-RE> <basic-RE>
>
> I had encoded it as
> (<concatenation>
> <simple-RE>
> <basic-RE>)
If simply listing symbols together mmeans alternation, I would call that
a pretty bad S-exp notation for writing grammars.
CL-YACC should consider just one s-exp for one production. That is to
say, alternative productions should be written as separate rules:
(<concatenation> <simple-re>)
(<concatenation> <basic-re>)
Then,
(foo a b c)
means "foo := a b c".
> I should have that <concatenation> is a concatenation of <simple-RE> and <basic-RE>.
> I should encode this as
>
> (<concatenation>
> (<simple-RE> <basic-RE>))
See? Just because you added a nesting level, with no operator, the
juxtaposition of symbols changes meaning from "alternative" to "consecutive".
Ouch!