c3c icon indicating copy to clipboard operation
c3c copied to clipboard

Some errors in "grammar.y" not caught by bison

Open mingodad opened this issue 1 year ago • 8 comments

While doing some tests with a script to convert grammar.y to a tree-sitter grammar I discovered what seems to be a copy and paste mistake that bison doesn't detect.

Here https://github.com/c3lang/c3c/blob/c673101bbb08e8de5d6e35d9aa83d42bcc73f642/resources/grammar/grammar.y#L758 we need to replace : by | (what seems to a copy and paste operation that forgot to replace : by |).

There was also some rules without the closing ; and mix of spaces and tabs, the lexer also was missing BANBANG definition and other minor problems (see my proposed fixes in the attached zip bellow).

gramlex.zip

mingodad avatar Feb 15 '24 10:02 mingodad

I'm unsure of some of those lexer changes, 1__000__000 is actually permitted currently. And I think there was something else there as well. I'll have a look. Keep in mind that the top level compile time if/switch is removed. Otherwise the grammar fixes were all good.

lerno avatar Feb 15 '24 13:02 lerno

What do you mean by top level compile time if/switch is removed ? My changes did it ?

mingodad avatar Feb 15 '24 13:02 mingodad

No I mean it's gone and I removed it from the dev branch already, but your grammar.y had it still.

lerno avatar Feb 15 '24 14:02 lerno

Why did you change to {HEX}+ wasn't that redundant?

lerno avatar Feb 15 '24 22:02 lerno

Do you mean "Why did I changed from {HEX}+ to {HEX} ? If so yes it was redundant.

mingodad avatar Feb 16 '24 08:02 mingodad

Sorry that was me reading things wrong. I think I updated with most of your changes now, but the 1__0 will not be invalid until 0.5.5

lerno avatar Feb 16 '24 11:02 lerno

Thank you ! The _?{D|H|B} it's OK to stay _*{D|H|B}.

mingodad avatar Feb 16 '24 11:02 mingodad

I've updated in the dev branch already. It's fine if your parser only accepts _? I don't think anyone uses this feature anyway.

lerno avatar Feb 16 '24 19:02 lerno

I think I can close this.

lerno avatar Jun 18 '24 20:06 lerno