mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-06 12:34:00 +08:00
Sort parser keywords
This commit is contained in:
parent
774b7c7b5b
commit
ab4606430e
18
src/ast.rs
18
src/ast.rs
|
@ -1255,7 +1255,7 @@ impl CheckParse for JobConjunction {
|
||||||
token.typ == ParseTokenType::string
|
token.typ == ParseTokenType::string
|
||||||
&& !matches!(
|
&& !matches!(
|
||||||
token.keyword,
|
token.keyword,
|
||||||
ParseKeyword::kw_end | ParseKeyword::kw_else | ParseKeyword::kw_case
|
ParseKeyword::kw_case | ParseKeyword::kw_end | ParseKeyword::kw_else
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3337,6 +3337,14 @@ impl<'s> Populator<'s> {
|
||||||
ParseTokenType::string => {
|
ParseTokenType::string => {
|
||||||
// There are three keywords which end a job list.
|
// There are three keywords which end a job list.
|
||||||
match tok.keyword {
|
match tok.keyword {
|
||||||
|
ParseKeyword::kw_case => {
|
||||||
|
parse_error!(
|
||||||
|
self,
|
||||||
|
tok,
|
||||||
|
ParseErrorCode::unbalancing_case,
|
||||||
|
"'case' builtin not inside of switch block"
|
||||||
|
);
|
||||||
|
}
|
||||||
ParseKeyword::kw_end => {
|
ParseKeyword::kw_end => {
|
||||||
parse_error!(
|
parse_error!(
|
||||||
self,
|
self,
|
||||||
|
@ -3353,14 +3361,6 @@ impl<'s> Populator<'s> {
|
||||||
"'else' builtin not inside of if block"
|
"'else' builtin not inside of if block"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ParseKeyword::kw_case => {
|
|
||||||
parse_error!(
|
|
||||||
self,
|
|
||||||
tok,
|
|
||||||
ParseErrorCode::unbalancing_case,
|
|
||||||
"'case' builtin not inside of switch block"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
internal_error!(
|
internal_error!(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -4,43 +4,43 @@ use crate::wchar::prelude::*;
|
||||||
|
|
||||||
const SKIP_KEYWORDS: &[&wstr] = &[L!("else"), L!("begin")];
|
const SKIP_KEYWORDS: &[&wstr] = &[L!("else"), L!("begin")];
|
||||||
const SUBCOMMAND_KEYWORDS: &[&wstr] = &[
|
const SUBCOMMAND_KEYWORDS: &[&wstr] = &[
|
||||||
L!("command"),
|
L!("and"),
|
||||||
|
L!("begin"),
|
||||||
L!("builtin"),
|
L!("builtin"),
|
||||||
L!("while"),
|
L!("command"),
|
||||||
L!("exec"),
|
L!("exec"),
|
||||||
L!("if"),
|
L!("if"),
|
||||||
L!("and"),
|
|
||||||
L!("or"),
|
|
||||||
L!("not"),
|
L!("not"),
|
||||||
|
L!("or"),
|
||||||
L!("time"),
|
L!("time"),
|
||||||
L!("begin"),
|
L!("while"),
|
||||||
];
|
];
|
||||||
const BLOCK_KEYWORDS: &[&wstr] = &[
|
const BLOCK_KEYWORDS: &[&wstr] = &[
|
||||||
L!("for"),
|
|
||||||
L!("while"),
|
|
||||||
L!("if"),
|
|
||||||
L!("function"),
|
|
||||||
L!("switch"),
|
|
||||||
L!("begin"),
|
L!("begin"),
|
||||||
|
L!("for"),
|
||||||
|
L!("function"),
|
||||||
|
L!("if"),
|
||||||
|
L!("switch"),
|
||||||
|
L!("while"),
|
||||||
];
|
];
|
||||||
|
|
||||||
// Don't forget to add any new reserved keywords to the documentation
|
// Don't forget to add any new reserved keywords to the documentation
|
||||||
const RESERVED_KEYWORDS: &[&wstr] = &[
|
const RESERVED_KEYWORDS: &[&wstr] = &[
|
||||||
L!("end"),
|
|
||||||
L!("case"),
|
|
||||||
L!("else"),
|
|
||||||
L!("return"),
|
|
||||||
L!("continue"),
|
|
||||||
L!("break"),
|
|
||||||
L!("argparse"),
|
|
||||||
L!("read"),
|
|
||||||
L!("string"),
|
|
||||||
L!("set"),
|
|
||||||
L!("status"),
|
|
||||||
L!("test"),
|
|
||||||
L!("["),
|
L!("["),
|
||||||
L!("_"),
|
L!("_"),
|
||||||
|
L!("argparse"),
|
||||||
|
L!("break"),
|
||||||
|
L!("case"),
|
||||||
|
L!("continue"),
|
||||||
|
L!("else"),
|
||||||
|
L!("end"),
|
||||||
L!("eval"),
|
L!("eval"),
|
||||||
|
L!("read"),
|
||||||
|
L!("return"),
|
||||||
|
L!("set"),
|
||||||
|
L!("status"),
|
||||||
|
L!("string"),
|
||||||
|
L!("test"),
|
||||||
];
|
];
|
||||||
|
|
||||||
// The lists above are purposely implemented separately from the logic below, so that future
|
// The lists above are purposely implemented separately from the logic below, so that future
|
||||||
|
|
Loading…
Reference in New Issue
Block a user