BenHanson / parsertl14

C++14 version of parsertl
32 stars 4 forks source link

Check for duplicated precedence declarations not done #14

Closed mingodad closed 5 months ago

mingodad commented 8 months ago

While converting this grammar https://github.com/diku-dk/futhark/blob/master/src/Language/Futhark/Parser/Parser.y to be uded in https://mingodad.github.io/parsertl-playground/playground/ I found that parsertl doesn't check for duplicated precedence declarations (that was present on that grammar).

This https://github.com/mingodad/parsertl-playground/commit/c5a94a611eff38caddda6f7fc7da80f3ac862223 seems to fix it.

mingodad commented 6 months ago

Also parsertl doesn't check for duplicated token declaration and this https://github.com/mingodad/parsertl-playground/commit/c9958a7e1b3f401402f795425b36d8a0632c6200 seems to somehow fix it.

BenHanson commented 5 months ago

It seems bison allows tokens to be re-defined.

mingodad commented 5 months ago
%token A
%token A

%left A
%left A

%%

the_a : A ;

%%

Output bison 3.8.2:

bison-nb test-dup-token.y
test-dup-token.y:2.8: warning: symbol A redeclared [-Wother]
    2 | %token A
      |        ^
test-dup-token.y:1.8: note: previous declaration
    1 | %token A
      |        ^
test-dup-token.y:5.1-5: error: %left redeclaration for A
    5 | %left A
      | ^~~~~
test-dup-token.y:4.1-5: note: previous declaration
    4 | %left A
      | ^~~~~
BenHanson commented 5 months ago

Ah, I didn't know that. Done now.