Split blocks and closures (#7075)

* Split closures and blocks

* Tests mostly working

* finish last fixes, passes all tests

* fmt
This commit is contained in:
JT
2022-11-10 21:21:49 +13:00
committed by GitHub
parent 921a66554e
commit 63433f1bc8
57 changed files with 576 additions and 220 deletions

View File

@ -46,8 +46,11 @@ pub enum SyntaxShape {
/// A binary literal
Binary,
/// A closure is allowed, eg `{|| start this thing}`
Closure(Option<Vec<SyntaxShape>>),
/// A block is allowed, eg `{start this thing}`
Block(Option<Vec<SyntaxShape>>),
Block,
/// A table is allowed, eg `[[first, second]; [1, 2]]`
Table,
@ -106,7 +109,8 @@ impl SyntaxShape {
pub fn to_type(&self) -> Type {
match self {
SyntaxShape::Any => Type::Any,
SyntaxShape::Block(_) => Type::Block,
SyntaxShape::Block => Type::Block,
SyntaxShape::Closure(_) => Type::Closure,
SyntaxShape::Binary => Type::Binary,
SyntaxShape::CellPath => Type::Any,
SyntaxShape::Custom(custom, _) => custom.to_type(),
@ -160,7 +164,8 @@ impl Display for SyntaxShape {
SyntaxShape::Directory => write!(f, "directory"),
SyntaxShape::GlobPattern => write!(f, "glob"),
SyntaxShape::ImportPattern => write!(f, "import"),
SyntaxShape::Block(_) => write!(f, "block"),
SyntaxShape::Block => write!(f, "block"),
SyntaxShape::Closure(_) => write!(f, "closure"),
SyntaxShape::Binary => write!(f, "binary"),
SyntaxShape::Table => write!(f, "table"),
SyntaxShape::List(x) => write!(f, "list<{}>", x),