Basic 'use' syntax for importing custom predicates (#286)

* Basic 'use' syntax for importing custom predicates

* Add extra test for unknown batches

* Fix unused import

* Enforce that imports must match number of predicates in a batch
This commit is contained in:
Rob Knight 2025-06-13 19:09:08 +02:00 committed by GitHub
parent f7bb6af219
commit 21ab3c2d0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 499 additions and 136 deletions

View file

@ -17,7 +17,7 @@ pub enum LangError {
Frontend(Box<frontend::Error>),
}
/// Errors that can occur during the processing of Podlog Pest tree into middleware structures.
/// Errors that can occur during the processing of Podlang Pest tree into middleware structures.
#[derive(thiserror::Error, Debug)]
pub enum ProcessorError {
#[error("Undefined identifier: '{name}' at {span:?}")]
@ -71,6 +71,22 @@ pub enum ProcessorError {
value: String,
span: Option<(usize, usize)>,
},
#[error("Batch with ID '{id}' not found at {span:?}")]
BatchNotFound {
id: String,
span: Option<(usize, usize)>,
},
#[error("Number of predicates in 'use' statement ({found}) exceeds the number of predicates in the batch ({expected}) at {span:?}")]
ImportArityMismatch {
expected: usize,
found: usize,
span: Option<(usize, usize)>,
},
#[error("Duplicate import name '{name}' at {span:?}")]
DuplicateImportName {
name: String,
span: Option<(usize, usize)>,
},
#[error("Frontend error: {0}")]
Frontend(#[from] frontend::Error),
}