mirror of
https://github.com/nushell/nushell.git
synced 2024-12-27 01:19:25 +01:00
Fixed trailing issues
This commit is contained in:
parent
af82f44e13
commit
bed5ba52d3
@ -163,7 +163,6 @@ pub fn baseline_parse_semantic_token(
|
||||
TokenNode::Whitespace(_span) => unreachable!(),
|
||||
TokenNode::Error(error) => Err(*error.item.clone()),
|
||||
TokenNode::Path(_path) => unimplemented!(),
|
||||
TokenNode::EOF(_span) => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -429,17 +429,6 @@ pub fn node(input: NomSpan) -> IResult<NomSpan, TokenNode> {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn eof(input: NomSpan) -> IResult<NomSpan, TokenNode> {
|
||||
if input.input_len() == 0 {
|
||||
Ok((input, TokenNode::EOF(Span::from(input))))
|
||||
} else {
|
||||
Err(Err::Error(error_position!(
|
||||
input,
|
||||
nom::error::ErrorKind::Eof
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pipeline(input: NomSpan) -> IResult<NomSpan, TokenNode> {
|
||||
trace_step(input, "pipeline", |input| {
|
||||
let start = input.offset;
|
||||
@ -450,13 +439,22 @@ pub fn pipeline(input: NomSpan) -> IResult<NomSpan, TokenNode> {
|
||||
many0(tuple((opt(space1), raw_call, opt(space1), opt(tag("|"))))),
|
||||
)?;
|
||||
|
||||
let (input, tail) = tuple((opt(space1), eof))(input)?;
|
||||
let (input, tail) = opt(space1)(input)?;
|
||||
let (input, newline) = opt(multispace1)(input)?;
|
||||
|
||||
if input.input_len() != 0 {
|
||||
return Err(Err::Error(error_position!(
|
||||
input,
|
||||
nom::error::ErrorKind::Eof
|
||||
)));
|
||||
}
|
||||
|
||||
let end = input.offset;
|
||||
|
||||
Ok((
|
||||
input,
|
||||
TokenTreeBuilder::spanned_pipeline(
|
||||
(make_call_list(head, items), tail.0.map(Span::from)),
|
||||
(make_call_list(head, items), tail.map(Span::from)),
|
||||
(start, end),
|
||||
),
|
||||
))
|
||||
|
@ -18,7 +18,6 @@ pub enum TokenNode {
|
||||
#[allow(unused)]
|
||||
Error(Spanned<Box<ShellError>>),
|
||||
Path(Spanned<PathNode>),
|
||||
EOF(Span),
|
||||
}
|
||||
|
||||
impl TokenNode {
|
||||
@ -34,7 +33,6 @@ impl TokenNode {
|
||||
TokenNode::Whitespace(s) => *s,
|
||||
TokenNode::Error(s) => s.span,
|
||||
TokenNode::Path(s) => s.span,
|
||||
TokenNode::EOF(s) => *s,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,6 @@ fn paint_token_node(token_node: &TokenNode, line: &str) -> String {
|
||||
item: RawToken::Bare,
|
||||
..
|
||||
}) => Color::Green.normal().paint(token_node.span().slice(line)),
|
||||
TokenNode::EOF(_) => return format!(""),
|
||||
};
|
||||
|
||||
styled.to_string()
|
||||
|
Loading…
Reference in New Issue
Block a user