Now kdl compilation accumulates errors of maximum length

This commit is contained in:
Felipe g 2022-09-26 11:55:13 -03:00
parent 377af111e2
commit 7e3008d24d
2 changed files with 21 additions and 4 deletions

View File

@ -129,6 +129,7 @@ pub fn to_kdl_book(book: &Book, kdl_names: &HashMap<String, String>, comp_book:
// Returns a map of kind names to kindelia names
// Returns an err if any of the names can't be converted
pub fn get_kdl_names(book: &CompBook) -> Result<HashMap<String, String>, String> {
let mut errors = Vec::new();
// Fits a name to the max size allowed by kindelia.
// If the name is too large, truncates and replaces the last characters by random chars.
// Fails if the namespace is too large.
@ -193,8 +194,16 @@ pub fn get_kdl_names(book: &CompBook) -> Result<HashMap<String, String>, String>
let mut kdl_names = HashMap::new();
for name in &book.names {
let kdln = get_kdl_name(book.entrs.get(name).unwrap())?;
kdl_names.insert(name.clone(), kdln);
let kdln = get_kdl_name(book.entrs.get(name).unwrap());
match kdln {
Ok(kdln) => kdl_names.insert(name.clone(), kdln).map(|_| ()).unwrap_or(()),
Err(err) => errors.push(err)
}
}
if errors.is_empty() {
Ok(kdl_names)
} else {
Err(errors.join("\n"))
}
Ok(kdl_names)
}

View File

@ -1 +1,9 @@
Namespace for "Algebra.Group.concat" has more than 11 characters.
Namespace for "Algebra.Group.concat" has more than 11 characters.
Namespace for "Algebra.Group.new" has more than 11 characters.
Namespace for "Algebra.Monoid.concat" has more than 11 characters.
Namespace for "Algebra.Monoid.new" has more than 11 characters.
Namespace for "Algebra.Semigroup.concat" has more than 11 characters.
Namespace for "Algebra.Semigroup.new" has more than 11 characters.
Namespace for "Algebra.Magma.concat" has more than 11 characters.
Namespace for "Algebra.Magma.new" has more than 11 characters.
Namespace for "Algebra.Monoid.empty" has more than 11 characters.