add EExpr error for unexpected comma

This commit is contained in:
Luke Boswell 2024-04-02 20:48:13 +11:00
parent 62cc19c64b
commit ca01913ab3
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
3 changed files with 30 additions and 1 deletions

View file

@ -687,6 +687,23 @@ fn to_expr_report<'a>(
severity: Severity::RuntimeError,
}
}
EExpr::UnexpectedComma(pos) => {
let surroundings = Region::new(start, *pos);
let region = LineColumnRegion::from_pos(lines.convert_pos(*pos));
let doc = alloc.stack([
alloc.reflow(r"I am trying to parse an expression, but I got stuck here:"),
alloc.region_with_subregion(lines.convert_region(surroundings), region),
alloc.concat([alloc.reflow("This comma in an invalid position.")]),
]);
Report {
filename,
doc,
title: "UNEXPECTED COMMA".to_string(),
severity: Severity::RuntimeError,
}
}
_ => todo!("unhandled parse error: {:?}", parse_problem),
}
}