From 03a93bd0892193ad31f05df1e7b854430a13e386 Mon Sep 17 00:00:00 2001 From: JT Date: Sat, 17 Jul 2021 10:00:41 +1200 Subject: [PATCH] Improve colon sep --- src/lex.rs | 10 +++++++++- src/parser.rs | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lex.rs b/src/lex.rs index ca58acf70e..7f4b661e5a 100644 --- a/src/lex.rs +++ b/src/lex.rs @@ -54,6 +54,13 @@ impl LexMode { _ => false, } } + + pub fn special_contains(&self, b: u8) -> bool { + match self { + LexMode::Custom { ref special, .. } => special.contains(&b), + _ => false, + } + } } // A baseline token is terminated if it's not nested inside of a paired @@ -67,7 +74,8 @@ fn is_item_terminator(block_level: &[BlockKind], c: u8, lex_mode: &LexMode) -> b || c == b'|' || c == b';' || c == b'#' - || lex_mode.whitespace_contains(c)) + || lex_mode.whitespace_contains(c) + || lex_mode.special_contains(c)) } // A special token is one that is a byte that stands alone as its own token. For example diff --git a/src/parser.rs b/src/parser.rs index 3201f5067a..38977c4719 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -999,7 +999,7 @@ impl ParserWorkingSet { desc: String::new(), long: String::from_utf8_lossy(contents).to_string(), short: None, - required: true, + required: false, })); } else { // Positional arg