fix(parser): make ; be part of the statement
Signed-off-by: Charlotte Meyer <dev@buffet.sh>
This commit is contained in:
parent
a990418704
commit
cfd15122ab
4 changed files with 54 additions and 6 deletions
|
@ -179,7 +179,8 @@ impl Iterator for Parser<'_> {
|
||||||
Comment => leaf!(Comment),
|
Comment => leaf!(Comment),
|
||||||
Pipe => chain!(leaf!(Pipe), call!(PipelineCont)),
|
Pipe => chain!(leaf!(Pipe), call!(PipelineCont)),
|
||||||
PlainText | DoubleQuote | OpeningParenthesis | EscapedChar => call!(Command),
|
PlainText | DoubleQuote | OpeningParenthesis | EscapedChar => call!(Command),
|
||||||
Newlines | Semicolon | ClosingParenthesis | Eof => ret!(),
|
Semicolon => chain_buf!(leaf!(Semicolon), ret!()),
|
||||||
|
Newlines | ClosingParenthesis | Eof => ret!(),
|
||||||
},
|
},
|
||||||
NodeKind::PipelineCont => match self.lookahead.kind {
|
NodeKind::PipelineCont => match self.lookahead.kind {
|
||||||
Whitespace => leaf!(Whitespace),
|
Whitespace => leaf!(Whitespace),
|
||||||
|
|
|
@ -685,3 +685,17 @@ fn quoted_command_substitution() {
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_pipeline() {
|
||||||
|
check(
|
||||||
|
";",
|
||||||
|
expect![[r#"
|
||||||
|
Ok(
|
||||||
|
Code(
|
||||||
|
[],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -197,12 +197,12 @@ fn semicolon() {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
Leaf {
|
||||||
|
kind: Semicolon,
|
||||||
|
len: 1,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
Leaf {
|
|
||||||
kind: Semicolon,
|
|
||||||
len: 1,
|
|
||||||
},
|
|
||||||
Leaf {
|
Leaf {
|
||||||
kind: Whitespace,
|
kind: Whitespace,
|
||||||
len: 1,
|
len: 1,
|
||||||
|
@ -1085,3 +1085,21 @@ fn quoted_command_substitution() {
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_pipeline() {
|
||||||
|
check(
|
||||||
|
";",
|
||||||
|
expect![[r#"
|
||||||
|
Tree {
|
||||||
|
kind: Program,
|
||||||
|
children: [
|
||||||
|
Leaf {
|
||||||
|
kind: Semicolon,
|
||||||
|
len: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -165,11 +165,11 @@ fn semicolon() {
|
||||||
),
|
),
|
||||||
EndNode,
|
EndNode,
|
||||||
EndNode,
|
EndNode,
|
||||||
EndNode,
|
|
||||||
NewLeaf(
|
NewLeaf(
|
||||||
Semicolon,
|
Semicolon,
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
|
EndNode,
|
||||||
NewLeaf(
|
NewLeaf(
|
||||||
Whitespace,
|
Whitespace,
|
||||||
1,
|
1,
|
||||||
|
@ -935,3 +935,18 @@ fn quoted_command_substitution() {
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_pipeline() {
|
||||||
|
check(
|
||||||
|
";",
|
||||||
|
expect![[r#"
|
||||||
|
[
|
||||||
|
NewLeaf(
|
||||||
|
Semicolon,
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue