2016-05-03 08:22:44 +08:00
|
|
|
// Functions having to do with parser keywords, like testing if a function is a block command.
|
2007-04-22 17:50:26 +08:00
|
|
|
#include "parser_keywords.h"
|
2016-05-03 08:22:44 +08:00
|
|
|
#include "common.h"
|
|
|
|
#include "fallback.h" // IWYU pragma: keep
|
2007-04-22 17:50:26 +08:00
|
|
|
|
2016-05-03 08:22:44 +08:00
|
|
|
bool parser_keywords_skip_arguments(const wcstring &cmd) {
|
|
|
|
return contains(cmd, L"else", L"begin");
|
2007-04-22 17:50:26 +08:00
|
|
|
}
|
|
|
|
|
2016-05-03 08:22:44 +08:00
|
|
|
bool parser_keywords_is_subcommand(const wcstring &cmd) {
|
2012-11-19 08:30:30 +08:00
|
|
|
return parser_keywords_skip_arguments(cmd) ||
|
2016-05-03 08:22:44 +08:00
|
|
|
contains(cmd, L"command", L"builtin", L"while", L"exec", L"if", L"and", L"or", L"not");
|
2007-04-22 17:50:26 +08:00
|
|
|
}
|
|
|
|
|
2016-05-03 08:22:44 +08:00
|
|
|
bool parser_keywords_is_block(const wcstring &word) {
|
|
|
|
return contains(word, L"for", L"while", L"if", L"function", L"switch", L"begin");
|
2007-04-22 17:50:26 +08:00
|
|
|
}
|
|
|
|
|
2016-05-03 08:22:44 +08:00
|
|
|
bool parser_keywords_is_reserved(const wcstring &word) {
|
|
|
|
return parser_keywords_is_block(word) || parser_keywords_is_subcommand(word) ||
|
|
|
|
contains(word, L"end", L"case", L"else", L"return", L"continue", L"break");
|
2007-04-22 17:50:26 +08:00
|
|
|
}
|