Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to declare an explanation with "ptr" #18

Closed
jengelh opened this issue Dec 3, 2021 · 3 comments
Closed

Unable to declare an explanation with "ptr" #18

jengelh opened this issue Dec 3, 2021 · 3 comments

Comments

@jengelh
Copy link
Contributor

jengelh commented Dec 3, 2021

The explain command's output is normally usable a command in its own right (and vice-versa), but this falls on its feet when the variable name is called ptr:

c++decl> explain void *ptr
declare ptr as pointer to void
c++decl> declare ptr as pointer to void
                 ^
18: syntax error: "ptr": name or operator expected
@paul-j-lucas
Copy link
Owner

paul-j-lucas commented Dec 3, 2021

That's because ptr is a cdecl keyword that's a shorthand for pointer. Note that cdecl recognizes such words only when parsing English and not gibberish (which is why your explain line works).

@paul-j-lucas
Copy link
Owner

paul-j-lucas commented Dec 3, 2021

I could perhaps add code to check to see if a token is a cdecl keyword and include that in the error message. Cdecl already does that for C/C++ keywords, e.g.:

cdecl> declare switch as pointer to void
               ^
18: syntax error: "switch": name or operator expected ("switch" is a keyword)

but not currently for cdecl keywords.

@paul-j-lucas
Copy link
Owner

As of 306ff626412a, cdecl token checks are done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants