Skip to content

Commit

Permalink
Use string interning when parsing AnonymousIndividual
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Feb 28, 2024
1 parent 61c27c8 commit df308ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::parser::Rule;
use pest::Span;

use super::parser::Rule;

/// The result type for this crate.
pub type Result<T> = std::result::Result<T, Error>;

Expand Down Expand Up @@ -73,7 +74,7 @@ pub enum Error {
}

impl Error {
// Create a custom `pest` error spanning the given pair.
/// Create a custom `pest` error located at the given span.
pub fn custom<S: Into<String>>(message: S, span: Span) -> Self {
Self::from(pest::error::Error::new_from_span(
pest::error::ErrorVariant::CustomError {
Expand Down
6 changes: 4 additions & 2 deletions src/from_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,9 @@ impl<A: ForIRI> FromPair<A> for Individual<A> {

impl<A: ForIRI> FromPair<A> for AnonymousIndividual<A> {
const RULE: Rule = Rule::NodeID;
fn from_pair_unchecked(pair: Pair<Rule>, _ctx: &Context<'_, A>) -> Result<Self> {
Ok(AnonymousIndividual(pair.as_str().to_string().into()))
fn from_pair_unchecked(pair: Pair<Rule>, ctx: &Context<'_, A>) -> Result<Self> {
let iri = ctx.iri(pair.as_str());
Ok(AnonymousIndividual(iri.underlying()))
}
}

Expand Down Expand Up @@ -1532,6 +1533,7 @@ impl<A: ForIRI> FromPair<A> for MiscClause<A> {
}
Rule::MiscRuleClause => {
if ctx.strict {
// FIXME: SWRL rules are not supported for now
Err(Error::custom(
"SWRL rules are not supported by horned-owl",
inner.as_span(),
Expand Down

0 comments on commit df308ee

Please sign in to comment.