[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: quirks in parse-gram.y

From: Akim Demaille
Subject: Re: quirks in parse-gram.y
Date: Thu, 22 Apr 2021 07:06:20 +0200


> Le 20 avr. 2021 à 04:18, 叶雨飞 <sunyucong@gmail.com> a écrit :
> Hello!
> I spent weekend hack together an IDEA plugin to support bison grammar files
> (
> https://github.com/thefallentree/idea-bison
> ) , and discovered some quirks , not sure if worth discussing here:

Nice job!

> 1. In “rules” , the bison grammar file shows that it accept ID_COLON
> namedref_opt ‘:’ ,  ID_COLON is of course “Id” immediately follows by an
> “:”,  my understanding is that this make namedref_opt useless because
> otherwise means you can write “id:[name]:....” which doesn’t looks right to
> me.

You're referring to this rule:

  id_colon named_ref.opt ":" rhses.1

Actually id_colon is more complex than "ID:": it actually means "an
identifier followed by COLON" but does not include the colon, as you
can see in the rule above.  And in fact it means "an identifier
followed by COLON possibly preceded by whitespace, comments, and
name reference".

> 2. The rules grammar indicate an ending “;” is actually optional. In fact,
> the parse-gram.y missed two “;” in separate places.  However the doc is
> pretty clear an “;” is expected.  Not sure which is intended .

Good catch.  The grammar would be definitely much simpler if the semicolon
were mandatory, but YACC compliance forbids this.  So it's the documentation
which is wrong.  I'll fix that, thanks!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]