mirror of
https://github.com/PaddiM8/kalker.git
synced 2024-12-12 17:40:52 +01:00
cli: Continue on new line when missing closing group symbol
This commit is contained in:
parent
e0bc36482c
commit
dfc05bc11d
@ -192,8 +192,23 @@ impl Hinter for RLHelper {
|
|||||||
|
|
||||||
impl Validator for RLHelper {
|
impl Validator for RLHelper {
|
||||||
fn validate(&self, ctx: &mut ValidationContext) -> Result<ValidationResult, ReadlineError> {
|
fn validate(&self, ctx: &mut ValidationContext) -> Result<ValidationResult, ReadlineError> {
|
||||||
|
let mut group_symbol_count = vec![0i32, 0i32, 0i32];
|
||||||
|
|
||||||
|
for c in ctx.input().chars() {
|
||||||
|
match c {
|
||||||
|
'⌈' | '⌉' => group_symbol_count[0] += 1,
|
||||||
|
'⌊' | '⌋' => group_symbol_count[1] += 1,
|
||||||
|
'|' => group_symbol_count[2] += 1,
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !group_symbol_count.into_iter().all(|x| x % 2 == 0) {
|
||||||
|
Ok(ValidationResult::Incomplete)
|
||||||
|
} else {
|
||||||
self.validator.validate(ctx)
|
self.validator.validate(ctx)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn validate_while_typing(&self) -> bool {
|
fn validate_while_typing(&self) -> bool {
|
||||||
self.validator.validate_while_typing()
|
self.validator.validate_while_typing()
|
||||||
|
@ -569,7 +569,6 @@ fn parse_group_fn(context: &mut Context) -> Result<Expr, CalcError> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let expr = parse_expr(context)?;
|
let expr = parse_expr(context)?;
|
||||||
advance(context);
|
|
||||||
|
|
||||||
if peek(context).kind == TokenKind::EOF {
|
if peek(context).kind == TokenKind::EOF {
|
||||||
return Err(CalcError::Expected(String::from(
|
return Err(CalcError::Expected(String::from(
|
||||||
@ -577,6 +576,8 @@ fn parse_group_fn(context: &mut Context) -> Result<Expr, CalcError> {
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
advance(context);
|
||||||
|
|
||||||
Ok(Expr::FnCall(Identifier::from_full_name(name), vec![expr]))
|
Ok(Expr::FnCall(Identifier::from_full_name(name), vec![expr]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user