Merge nucleic/clever-quartz-marten-uqnx into dev
This commit is contained in:
@@ -49,3 +49,24 @@ pub struct InteractivePrompt {
|
||||
/// Prompt to display on a continuation line of input.
|
||||
pub continuation_prompt: String,
|
||||
}
|
||||
|
||||
/// Returns whether a parser result represents a complete command that can be
|
||||
/// executed, as opposed to a command that needs more physical input lines.
|
||||
pub(crate) fn parse_result_is_complete(
|
||||
result: &Result<brush_parser::ast::Program, brush_parser::ParseError>,
|
||||
) -> bool {
|
||||
match result {
|
||||
// Unclosed quotes and similar tokenizer states need another line.
|
||||
Err(brush_parser::ParseError::Tokenizing { inner, position: _ })
|
||||
if inner.is_incomplete() =>
|
||||
{
|
||||
false
|
||||
}
|
||||
// An otherwise-valid compound command may simply be missing its
|
||||
// closing token (`fi`, `done`, `}`, ...).
|
||||
Err(brush_parser::ParseError::ParsingAtEndOfInput) => false,
|
||||
// A located syntax error is complete input and should be surfaced.
|
||||
// A successful parse is ready to execute.
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user