Fixed trailing issues

This commit is contained in:
Yehuda Katz 2019-06-23 15:32:26 -04:00
parent af82f44e13
commit bed5ba52d3
4 changed files with 11 additions and 17 deletions

View File

@ -163,7 +163,6 @@ pub fn baseline_parse_semantic_token(
TokenNode::Whitespace(_span) => unreachable!(), TokenNode::Whitespace(_span) => unreachable!(),
TokenNode::Error(error) => Err(*error.item.clone()), TokenNode::Error(error) => Err(*error.item.clone()),
TokenNode::Path(_path) => unimplemented!(), TokenNode::Path(_path) => unimplemented!(),
TokenNode::EOF(_span) => unimplemented!(),
} }
} }

View File

@ -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> { pub fn pipeline(input: NomSpan) -> IResult<NomSpan, TokenNode> {
trace_step(input, "pipeline", |input| { trace_step(input, "pipeline", |input| {
let start = input.offset; 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("|"))))), 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; let end = input.offset;
Ok(( Ok((
input, input,
TokenTreeBuilder::spanned_pipeline( TokenTreeBuilder::spanned_pipeline(
(make_call_list(head, items), tail.0.map(Span::from)), (make_call_list(head, items), tail.map(Span::from)),
(start, end), (start, end),
), ),
)) ))

View File

@ -18,7 +18,6 @@ pub enum TokenNode {
#[allow(unused)] #[allow(unused)]
Error(Spanned<Box<ShellError>>), Error(Spanned<Box<ShellError>>),
Path(Spanned<PathNode>), Path(Spanned<PathNode>),
EOF(Span),
} }
impl TokenNode { impl TokenNode {
@ -34,7 +33,6 @@ impl TokenNode {
TokenNode::Whitespace(s) => *s, TokenNode::Whitespace(s) => *s,
TokenNode::Error(s) => s.span, TokenNode::Error(s) => s.span,
TokenNode::Path(s) => s.span, TokenNode::Path(s) => s.span,
TokenNode::EOF(s) => *s,
} }
} }

View File

@ -130,7 +130,6 @@ fn paint_token_node(token_node: &TokenNode, line: &str) -> String {
item: RawToken::Bare, item: RawToken::Bare,
.. ..
}) => Color::Green.normal().paint(token_node.span().slice(line)), }) => Color::Green.normal().paint(token_node.span().slice(line)),
TokenNode::EOF(_) => return format!(""),
}; };
styled.to_string() styled.to_string()