paul-j-lucas / cdecl

Composing and deciphering C (or C++) declarations or casts, aka ‘‘gibberish.’’
GNU General Public License v3.0
90 stars 11 forks source link

Add support for using type alias. #1

Closed IOBYTE closed 6 years ago

IOBYTE commented 6 years ago

Are there any plans to add C++ using type aliases?

c++decl> explain typedef int v3[3];
declare v3 as type array 3 of int
c++decl> explain using v3 = int[3];
                 ^
9: syntax error: "using": unexpected token
c++decl>
paul-j-lucas commented 6 years ago

For some reason, I don't get notified of new issues when they're created, so I didn't see this until just now just after I published cdecl 4.5 that contains support for C++11's using declarations. However, I forgot to add support for explaining using declarations. I'll get around to it.

I also discovered that there are some broken using cases like the one you gave. :(

paul-j-lucas commented 6 years ago

OK, I just added support for explain using name = gibberish.

I also realized that the breakage isn't limited to using. It fails to parse array declarations without a name, e.g., explain void f(char[]). If you insert a name like explain void f(char s[]) then it works.

Unfortunately, it's not an easy fix and will likely require some serious reworking of parts of the grammar so as not to trigger a gazillion more shift/reduce conflicts (as well as new reduce/reduce conflicts).

With 671 unit tests, you'd think I would have caught this earlier; but no. :(

paul-j-lucas commented 6 years ago

Unfortunately, it's not an easy fix and will likely require some serious reworking of parts of the grammar so as not to trigger a gazillion more shift/reduce conflicts (as well as new reduce/reduce conflicts).

It turns out that the fix was simpler than I thought. It's fixed in 4.6.1.