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

Missing reserved words #133

Closed
jaopaulolc opened this issue Oct 25, 2022 · 3 comments
Closed

Missing reserved words #133

jaopaulolc opened this issue Oct 25, 2022 · 3 comments

Comments

@jaopaulolc
Copy link
Contributor

Hi,

I notice that the grammar does not include some reserved words that are part of the language according to the Bash Reference Manual.

This is a list of some with some reserved words that are missing:

("time" "coproc" "type" "trap" "exit" "exec" "continue" "break" "return" "logout" "bye" "true" "false" "test")

My suspicion is that including those would complicate significantly the parser and that my be the reason to leave those out.

However, for fontification and other text editing tasks, it is desirable to identify those.

Is the recommend approach to use a generic query and a regex to find the above reserved words? Something like this:

(command_name ((word) @captured_keyword (#match? @captured_keyword <regex to reserved words>)))

@Ordoviz
Copy link

Ordoviz commented Apr 16, 2023

type, test, true, false, and logout are just builtins, while exec, exit, return, break, and continue are "special shell builtins", which cannot be used as function names in --posix mode.

I support adding the select and until keywords and the listed special builtins to the @keyword array since they change control flow so making them stand out would aid reading.

A complete list of keywords and builtins can be generated with compgen -k and compgen -b, respectively.

@verhovsky
Copy link
Collaborator

verhovsky commented Apr 16, 2023

I added select and until as keywords since they make sense as keywords and they're returned by compgen -k. I don't have an opinion on including exec, exit, return, break, and continue so I won't close the issue.

Also, "bye" is not a reserved word, at least on my Bash 5.2.15.

@amaanq
Copy link
Member

amaanq commented Aug 21, 2023

bye is a zsh builtin in my case

The others are not exposed literals, so no point adding them as keywords unless they're separate statement rules

@amaanq amaanq closed this as completed Aug 21, 2023
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

4 participants