diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82eba1d7..c50d143a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,6 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Clippy check uses: actions-rs/cargo@v1 - continue-on-error: true with: command: clippy args: --all-targets --all-features --workspace -- -D warnings diff --git a/Cargo.toml b/Cargo.toml index bdaa2fca..6d0a052d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,9 +3,9 @@ name = "shapes-rs" version = "0.0.11" description = "RDF Data shapes implementation in Rust" license = "GPL-3.0-or-later" -authors = [ - "Jose Emilio Labra Gayo", - "Ángel Iglesias Préstamo ", +authors = [ + "Jose Emilio Labra Gayo ", + "Ángel Iglesias Préstamo ", ] repository = "https://github.com/weso/shapes-rs" homepage = "https://www.weso.es/shapes-rs/" @@ -13,7 +13,7 @@ homepage = "https://www.weso.es/shapes-rs/" [[bin]] path = "sx_cli/src/main.rs" -name = "sx" +name = "sx" [workspace] members = [ @@ -47,15 +47,16 @@ exclude = [ # version = "0.0.6" edition = "2021" license = "MIT OR Apache-2.0" -authors = ["Jose Emilio Labra Gayo ", - "Ángel Iglesias Préstamo ", +authors = [ + "Jose Emilio Labra Gayo ", + "Ángel Iglesias Préstamo ", ] description = "RDF data shapes implementation in Rust" -repository = "https://github.com/weso/shapes_rs" +repository = "https://github.com/weso/shapes-rs" homepage = "https://www.weso.es/shapes-rs/" readme = "./README.md" -keywords = ["rdf", "linked-data", "semantic-web", "shex"] +keywords = ["rdf", "linked-data", "semantic-web", "shex"] categories = ["rdf"] [workspace.dependencies] @@ -89,4 +90,4 @@ oxrdf = "0.2.0-alpha.2" serde_json = "1.0" regex = "1.10.4" tracing = "0.1" -tracing-subscriber = { version = "0.3", features = [ "env-filter" ] } \ No newline at end of file +tracing-subscriber = { version = "0.3", features = [ "env-filter" ] } diff --git a/dctap/src/dctap.rs b/dctap/src/dctap.rs index d77a0cd4..dc2acb79 100644 --- a/dctap/src/dctap.rs +++ b/dctap/src/dctap.rs @@ -1,6 +1,6 @@ use crate::{tap_config::TapConfig, tap_error::TapError}; use serde_derive::{Deserialize, Serialize}; -use std::path::PathBuf; +use std::path::Path; use tracing::debug; #[derive(Debug, Serialize, Deserialize)] @@ -11,6 +11,12 @@ pub struct DCTap { version: String, } +impl Default for DCTap { + fn default() -> Self { + Self::new() + } +} + impl DCTap { pub fn new() -> DCTap { DCTap { @@ -18,7 +24,7 @@ impl DCTap { } } - pub fn read_buf(path_buf: &PathBuf, config: TapConfig) -> Result { + pub fn read_buf(_path: &Path, _config: TapConfig) -> Result { let dctap = DCTap::new(); debug!("DCTap parsed: {:?}", dctap); Ok(dctap) diff --git a/dctap/src/lib.rs b/dctap/src/lib.rs index 8c5a910c..94f614b5 100644 --- a/dctap/src/lib.rs +++ b/dctap/src/lib.rs @@ -13,8 +13,6 @@ pub mod tap_statement; pub use crate::tap_config::*; pub use crate::tap_error::*; -pub use crate::tap_error::*; pub use crate::tap_shape::*; pub use crate::tap_statement::*; pub use dctap::*; -pub use dctap::*; diff --git a/dctap/src/tap_config.rs b/dctap/src/tap_config.rs index 1132a6a9..466553c7 100644 --- a/dctap/src/tap_config.rs +++ b/dctap/src/tap_config.rs @@ -1,10 +1,4 @@ use serde_derive::{Deserialize, Serialize}; -#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)] +#[derive(Deserialize, Serialize, Debug, PartialEq, Clone, Default)] pub struct TapConfig {} - -impl Default for TapConfig { - fn default() -> Self { - Self {} - } -} diff --git a/rbe_testsuite/Cargo.toml b/rbe_testsuite/Cargo.toml index 09abb824..47733a3e 100755 --- a/rbe_testsuite/Cargo.toml +++ b/rbe_testsuite/Cargo.toml @@ -18,4 +18,3 @@ tracing = "0.1" [dev-dependencies] indoc = "2" - diff --git a/shex_ast/src/ast/iri.rs b/shex_ast/src/ast/iri.rs index d8d8a48c..4b0f105d 100644 --- a/shex_ast/src/ast/iri.rs +++ b/shex_ast/src/ast/iri.rs @@ -46,9 +46,9 @@ impl Display for Iri { } // This is required by serde serialization -impl Into for Iri { - fn into(self) -> String { - match self { +impl From for String { + fn from(val: Iri) -> Self { + match val { Iri::String(s) => s, Iri::IriS(iri_s) => iri_s.as_str().to_string(), } diff --git a/shex_ast/src/ast/mod.rs b/shex_ast/src/ast/mod.rs index 46b002b6..8982df59 100644 --- a/shex_ast/src/ast/mod.rs +++ b/shex_ast/src/ast/mod.rs @@ -165,7 +165,7 @@ mod tests { let shape_expr = serde_json::from_str::(str); if let Ok(v) = &shape_expr { - let serialized = serde_json::to_string(v).unwrap(); + let _serialized = serde_json::to_string(v).unwrap(); } assert!(shape_expr.is_ok()) } diff --git a/shex_ast/src/ast/shape_expr.rs b/shex_ast/src/ast/shape_expr.rs index 4667f878..ceb1ccdc 100644 --- a/shex_ast/src/ast/shape_expr.rs +++ b/shex_ast/src/ast/shape_expr.rs @@ -93,7 +93,7 @@ impl ShapeExpr { ShapeExpr::External } - pub fn not(se: ShapeExpr) -> ShapeExpr { + pub fn shape_not(se: ShapeExpr) -> ShapeExpr { ShapeExpr::ShapeNot { shape_expr: Box::new(ShapeExprWrapper { se }), } diff --git a/shex_ast/src/ast/shape_expr_label.rs b/shex_ast/src/ast/shape_expr_label.rs index 3ea07d39..37b47a09 100644 --- a/shex_ast/src/ast/shape_expr_label.rs +++ b/shex_ast/src/ast/shape_expr_label.rs @@ -108,9 +108,9 @@ impl Display for ShapeExprLabel { } } -impl Into for ShapeExprLabel { - fn into(self) -> String { - self.to_string() +impl From for String { + fn from(val: ShapeExprLabel) -> Self { + val.to_string() } } diff --git a/shex_ast/src/ast/triple_expr_label.rs b/shex_ast/src/ast/triple_expr_label.rs index 6e8455ee..d414b370 100644 --- a/shex_ast/src/ast/triple_expr_label.rs +++ b/shex_ast/src/ast/triple_expr_label.rs @@ -53,8 +53,8 @@ impl Display for TripleExprLabel { } } -impl Into for TripleExprLabel { - fn into(self) -> String { - self.to_string() +impl From for String { + fn from(val: TripleExprLabel) -> Self { + val.to_string() } } diff --git a/shex_compact/benches/regex.rs b/shex_compact/benches/regex.rs index 4737b0de..58b349e7 100644 --- a/shex_compact/benches/regex.rs +++ b/shex_compact/benches/regex.rs @@ -1,12 +1,10 @@ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use nom_locate::LocatedSpan; -use pprof::criterion::{Output, PProfProfiler}; -use shex_compact::ShExParser; use shex_compact::{hex, hex_refactor}; fn regex_compare(c: &mut Criterion) { let mut group = c.benchmark_group("Regex compare"); - for i in 1..1 { + for i in 1..2 { let txt = LocatedSpan::new("A"); group.bench_with_input(BenchmarkId::new("No_regex", i), &txt, |b, txt| { b.iter(|| hex(*txt)) diff --git a/shex_compact/benches/shex_parse.rs b/shex_compact/benches/shex_parse.rs index 29b2e5a1..7011224a 100644 --- a/shex_compact/benches/shex_parse.rs +++ b/shex_compact/benches/shex_parse.rs @@ -16,7 +16,7 @@ fn shex_parse_benchmark(c: &mut Criterion) { // test once to make sure it parses correctly the first time parse(); // real benchmark - c.bench_function("shex_parse", |b| b.iter(|| parse())); + c.bench_function("shex_parse", |b| b.iter(parse)); } criterion_group! { diff --git a/shex_compact/src/compact_printer.rs b/shex_compact/src/compact_printer.rs index 9e622b67..62eec449 100644 --- a/shex_compact/src/compact_printer.rs +++ b/shex_compact/src/compact_printer.rs @@ -1,16 +1,11 @@ use colored::*; use iri_s::IriS; use prefixmap::{IriRef, PrefixMap}; -use pretty::{Arena, DocAllocator, DocBuilder, RefDoc}; -use rust_decimal::Decimal; +use pretty::{Arena, DocAllocator, DocBuilder}; use shex_ast::{object_value::ObjectValue, BNode, ShapeExprLabel}; use srdf::literal::Literal; use std::borrow::Cow; -pub(crate) fn space<'a, A>(doc: &'a Arena<'a, A>) -> DocBuilder<'a, Arena<'a, A>, A> { - doc.space() -} - pub(crate) fn pp_object_value<'a, A>( v: &ObjectValue, doc: &'a Arena<'a, A>, @@ -47,22 +42,6 @@ pub(crate) fn pp_bnode<'a, A>( doc.text(format!("{value}")) } -fn pp_isize<'a, A>(value: &isize, doc: &'a Arena<'a, A>) -> DocBuilder<'a, Arena<'a, A>, A> { - doc.text(value.to_string()) -} - -fn pp_decimal<'a, A>(value: &Decimal, doc: &'a Arena<'a, A>) -> DocBuilder<'a, Arena<'a, A>, A> { - doc.text(value.to_string()) -} - -fn pp_double<'a, A>(value: &f64, doc: &'a Arena<'a, A>) -> DocBuilder<'a, Arena<'a, A>, A> { - doc.text(value.to_string()) -} - -fn pp_usize<'a, A>(value: &usize, doc: &'a Arena<'a, A>) -> DocBuilder<'a, Arena<'a, A>, A> { - doc.text(value.to_string()) -} - fn pp_iri_ref<'a, A>( value: &IriRef, doc: &'a Arena<'a, A>, @@ -98,11 +77,6 @@ where } } -fn pp_iri_unqualified<'a, A>(iri: &IriS, doc: &'a Arena<'a, A>) -> DocBuilder<'a, Arena<'a, A>, A> { - let str = format!("<{iri}>"); - doc.text(str) -} - fn pp_iri<'a, A>( iri: &IriS, doc: &'a Arena<'a, A>, @@ -110,72 +84,3 @@ fn pp_iri<'a, A>( ) -> DocBuilder<'a, Arena<'a, A>, A> { doc.text(prefixmap.qualify(iri)) } - -fn is_empty<'a, A>(d: &DocBuilder<'a, Arena<'a, A>, A>) -> bool { - use pretty::Doc::*; - match &**d { - Nil => true, - FlatAlt(t1, t2) => is_empty_ref(t1) && is_empty_ref(t2), - Group(t) => is_empty_ref(t), - Nest(_, t) => is_empty_ref(t), - Union(t1, t2) => is_empty_ref(t1) && is_empty_ref(t2), - Annotated(_, t) => is_empty_ref(t), - _ => false, - } -} - -fn is_empty_ref(rd: &RefDoc<'_, A>) -> bool { - use pretty::Doc::*; - - match &**rd { - Nil => true, - FlatAlt(t1, t2) => is_empty_ref(t1) && is_empty_ref(t2), - Group(t) => is_empty_ref(t), - Nest(_, t) => is_empty_ref(t), - Union(t1, t2) => is_empty_ref(t1) && is_empty_ref(t2), - Annotated(_, t) => is_empty_ref(t), - _ => false, - } -} - -pub(crate) fn enclose<'a, A>( - left: &'a str, - doc: DocBuilder<'a, Arena<'a, A>, A>, - right: &'a str, - arena: &'a Arena<'a, A>, - indent: isize, -) -> DocBuilder<'a, Arena<'a, A>, A> { - if is_empty(&doc) { - arena.text(left).append(right) - } else { - arena - .text(left) - .append(arena.line_()) - .append(doc) - .nest(indent) - .append(arena.line_()) - .append(right) - .group() - } -} - -pub(crate) fn enclose_space<'a, A>( - left: &'a str, - middle: DocBuilder<'a, Arena<'a, A>, A>, - right: &'a str, - arena: &'a Arena<'a, A>, - indent: isize, -) -> DocBuilder<'a, Arena<'a, A>, A> { - if is_empty(&middle) { - arena.text(left).append(right) - } else { - arena - .text(left) - .append(arena.line()) - .append(middle) - .nest(indent) - .append(arena.line()) - .append(right) - .group() - } -} diff --git a/shex_compact/src/grammar.rs b/shex_compact/src/grammar.rs index d555086d..36b43b91 100644 --- a/shex_compact/src/grammar.rs +++ b/shex_compact/src/grammar.rs @@ -5,7 +5,7 @@ use nom::{ bytes::complete::{is_not, tag, tag_no_case}, character::complete::multispace1, combinator::value, - multi::{many0, many1}, + multi::many0, sequence::{delimited, pair}, Err, }; @@ -89,11 +89,13 @@ pub(crate) fn tws0(input: Span) -> IRes<()> { value((), many0(alt((value((), multispace1), comment))))(input) } +/* /// A combinator that recognises any non-empty amount of whitespace /// and comments. pub(crate) fn tws1(input: Span) -> IRes<()> { value((), many1(alt((value((), multispace1), comment))))(input) } +*/ /// A combinator that creates a parser for a specific token. pub(crate) fn token<'a>(token: &'a str) -> impl FnMut(Span<'a>) -> IRes> { @@ -117,58 +119,3 @@ pub(crate) fn tag_no_case_tws<'a>(token: &'a str) -> impl FnMut(Span<'a>) -> IRe ShExParseError::ExpectedToken(token.to_string()) }) } - -fn many1_sep<'a, O, O2, F, G, H>( - mut parser_many: F, - mut sep: G, - maker: H, - mut i: Span<'a>, -) -> IRes<'a, O2> -where - F: FnMut(Span<'a>) -> IRes<'a, O>, - G: FnMut(Span<'a>) -> IRes<'a, ()>, - H: Fn(Vec) -> O2, -{ - let mut vs = Vec::new(); - - // skip tws - if let Ok((left, _)) = tws0(i) { - i = left; - } - match parser_many(i) { - Ok((left, v)) => { - vs.push(v); - i = left; - } - Err(e) => return Err(e), - } - loop { - if let Ok((left, _)) = tws0(i) { - i = left; - } - - match sep(i) { - Ok((left, _)) => { - i = left; - } - _ => return Ok((i, maker(vs))), - } - - if let Ok((left, _)) = tws0(i) { - i = left; - } - - match parser_many(i) { - Ok((left, v)) => { - vs.push(v); - i = left; - } - _ => return Ok((i, maker(vs))), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; -} diff --git a/shex_compact/src/grammar_structs.rs b/shex_compact/src/grammar_structs.rs index ded729b7..1473489a 100644 --- a/shex_compact/src/grammar_structs.rs +++ b/shex_compact/src/grammar_structs.rs @@ -25,13 +25,6 @@ pub(crate) enum ShExStatement<'a> { shape_label: ShapeExprLabel, shape_expr: ShapeExpr, }, - Empty, -} - -impl<'a> ShExStatement<'a> { - pub fn is_empty(&self) -> bool { - matches!(self, ShExStatement::Empty) - } } #[derive(PartialEq, Debug)] @@ -69,12 +62,14 @@ impl Cardinality { } } + /* pub fn range(min: i32, max: i32) -> Cardinality { Cardinality { min: Some(min), max: Some(max), } } + */ pub fn exact(n: i32) -> Cardinality { Cardinality { @@ -83,12 +78,14 @@ impl Cardinality { } } + /* pub fn only_min(n: i32) -> Cardinality { Cardinality { min: Some(n), max: None, } } + */ pub fn min_max(min: i32, max: i32) -> Cardinality { Cardinality { diff --git a/shex_compact/src/lib.rs b/shex_compact/src/lib.rs index 3a20276b..d9cd0762 100644 --- a/shex_compact/src/lib.rs +++ b/shex_compact/src/lib.rs @@ -38,11 +38,10 @@ pub mod shex_parser_error; use nom::IResult; use nom_locate::LocatedSpan; -pub use crate::compact_printer::*; -pub use crate::grammar::*; +pub(crate) use crate::compact_printer::*; +pub(crate) use crate::grammar::*; pub use crate::located_parse_error::*; pub use crate::shapemap_compact_printer::*; -pub use crate::shapemap_grammar::*; pub use crate::shapemap_parser::*; pub use crate::shex_compact_printer::*; pub use crate::shex_grammar::*; diff --git a/shex_compact/src/shapemap_compact_printer.rs b/shex_compact/src/shapemap_compact_printer.rs index 2df52795..ce6dae22 100644 --- a/shex_compact/src/shapemap_compact_printer.rs +++ b/shex_compact/src/shapemap_compact_printer.rs @@ -69,7 +69,6 @@ where A: Clone, { width: usize, - indent: isize, keyword_color: Option, shapemap: &'a QueryShapeMap, doc: &'a Arena<'a, A>, @@ -79,7 +78,6 @@ where } const DEFAULT_WIDTH: usize = 100; -const DEFAULT_INDENT: isize = 4; const DEFAULT_QUALIFY_ALIAS_COLOR: Option = Some(Color::Blue); const DEFAULT_QUALIFY_SEMICOLON_COLOR: Option = Some(Color::BrightGreen); const DEFAULT_QUALIFY_LOCALNAME_COLOR: Option = Some(Color::Black); @@ -95,7 +93,6 @@ where ) -> ShapemapCompactPrinter<'a, A> { ShapemapCompactPrinter { width: DEFAULT_WIDTH, - indent: DEFAULT_INDENT, keyword_color: DEFAULT_KEYWORD_COLOR, shapemap, doc, @@ -113,11 +110,6 @@ where } } - pub fn with_width(mut self, width: usize) -> Self { - self.width = width; - self - } - pub fn with_keyword_color(mut self, color: Option) -> Self { self.keyword_color = color; self diff --git a/shex_compact/src/shapemap_parser.rs b/shex_compact/src/shapemap_parser.rs index 7a89c30a..2c67fce0 100644 --- a/shex_compact/src/shapemap_parser.rs +++ b/shex_compact/src/shapemap_parser.rs @@ -12,7 +12,7 @@ use shapemap::query_shape_map::QueryShapeMap; use shapemap::NodeSelector; use shapemap::ShapeSelector; use std::fs; -use std::path::{Path, PathBuf}; +use std::path::Path; type Result = std::result::Result; diff --git a/shex_compact/src/shex_compact_printer.rs b/shex_compact/src/shex_compact_printer.rs index e2a79338..36a1aa97 100644 --- a/shex_compact/src/shex_compact_printer.rs +++ b/shex_compact/src/shex_compact_printer.rs @@ -128,11 +128,6 @@ where } } - pub fn with_width(mut self, width: usize) -> Self { - self.width = width; - self - } - pub fn with_keyword_color(mut self, color: Option) -> Self { self.keyword_color = color; self @@ -568,7 +563,6 @@ where U: Into>, { if let Some(color) = self.keyword_color { - use std::borrow::Borrow; let data: Cow = s.into(); let s: String = match data { Cow::Owned(t) => t, @@ -692,26 +686,6 @@ where } } - pub fn enclose( - &self, - left: &'a str, - doc: DocBuilder<'a, Arena<'a, A>, A>, - right: &'a str, - ) -> DocBuilder<'a, Arena<'a, A>, A> { - if self.is_empty(&doc) { - self.doc.text(left).append(right) - } else { - self.doc - .text(left) - .append(self.doc.line_()) - .append(doc) - .nest(self.indent) - .append(self.doc.line_()) - .append(right) - .group() - } - } - pub fn enclose_space( &self, left: &'a str, diff --git a/shex_compact/src/shex_grammar.rs b/shex_compact/src/shex_grammar.rs index 36280ed5..94878f47 100644 --- a/shex_compact/src/shex_grammar.rs +++ b/shex_compact/src/shex_grammar.rs @@ -3,14 +3,14 @@ use crate::grammar_structs::{ }; use crate::{ map_error, shex_parser_error::ParseError as ShExParseError, tag_no_case_tws, token, token_tws, - traced, tws0, tws1, IRes, Span, + traced, tws0, IRes, Span, }; use iri_s::IriS; use nom::{ branch::alt, bytes::complete::{tag, tag_no_case, take_while, take_while1}, character::complete::{alpha1, alphanumeric1, char, digit0, digit1, none_of, one_of, satisfy}, - combinator::{cut, fail, map, map_res, opt, recognize}, + combinator::{cut, map, map_res, opt, recognize}, error::ErrorKind, error_position, multi::{count, fold_many0, many0, many1}, @@ -29,12 +29,12 @@ use shex_ast::{ use std::{collections::VecDeque, fmt::Debug, num::ParseIntError}; use thiserror::Error; -use lazy_regex::{lazy_regex, regex, Lazy}; +use lazy_regex::{regex, Lazy}; use nom_locate::LocatedSpan; use prefixmap::IriRef; -use srdf::{lang::Lang, literal::Literal, numeric_literal::NumericLiteral, RDF_TYPE, RDF_TYPE_STR}; +use srdf::{lang::Lang, literal::Literal, numeric_literal::NumericLiteral, RDF_TYPE_STR}; -/// `[1] shexDoc ::= directive* ((notStartAction | startActions) statement*)?` +/// `[1] shexDoc ::= directive* ((notStartAction | startActions) statement*)?` pub(crate) fn shex_statement<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShExStatement> { traced( "shex_statement", @@ -100,12 +100,12 @@ fn statements(i: Span) -> IRes> { many0(statement)(i) } */ -/// `[2] directive ::= baseDecl | prefixDecl | importDecl` +/// `[2] directive ::= baseDecl | prefixDecl | importDecl` fn directive(i: Span) -> IRes { alt((base_decl(), prefix_decl(), import_decl()))(i) } -/// `[3] baseDecl ::= "BASE" IRIREF` +/// `[3] baseDecl ::= "BASE" IRIREF` fn base_decl<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShExStatement> { traced( "base_decl", @@ -119,7 +119,7 @@ fn base_decl<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShExStatement> { ) } -/// [4] `prefixDecl ::= "PREFIX" PNAME_NS IRIREF` +/// [4] `prefixDecl ::= "PREFIX" PNAME_NS IRIREF` fn prefix_decl<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShExStatement> { traced( "prefix_decl", @@ -145,7 +145,7 @@ fn prefix_decl<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShExStatement> { ) } -/// `[4½] importDecl ::= "IMPORT" IRIREF` +/// `[4½] importDecl ::= "IMPORT" IRIREF` fn import_decl<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShExStatement> { traced( "import_decl", @@ -159,13 +159,13 @@ fn import_decl<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShExStatement> { ), ) } - +/* /// `[5] notStartAction ::= start | shapeExprDecl` fn not_start_action(i: Span) -> IRes { alt((start(), shape_expr_decl()))(i) } - -/// `[6] start ::= "start" '=' inlineShapeExpression` +*/ +/// `[6] start ::= "start" '=' inlineShapeExpression` fn start<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShExStatement> { map_error( move |i| { @@ -182,18 +182,18 @@ fn start<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShExStatement> { ) } -/// `[7] startActions ::= codeDecl+` +/// `[7] startActions ::= codeDecl+` fn start_actions(i: Span) -> IRes { let (i, cs) = many1(code_decl())(i)?; Ok((i, ShExStatement::StartActions { actions: cs })) } - +/* /// `[8] statement ::= directive | notStartAction` fn statement(i: Span) -> IRes { alt((directive, not_start_action))(i) } - -/// `[9] shapeExprDecl ::= shapeExprLabel (shapeExpression | "EXTERNAL")` +*/ +/// `[9] shapeExprDecl ::= shapeExprLabel (shapeExpression | "EXTERNAL")` fn shape_expr_decl<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShExStatement> { traced( "shape_expr_decl", @@ -205,10 +205,7 @@ fn shape_expr_decl<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShExStatement> { tws0, cut(shape_expr_or_external()), ))(i)?; - let is_abstract = match maybe_abstract { - Some(_) => true, - None => false, - }; + let is_abstract = maybe_abstract.is_some(); Ok(( i, ShExStatement::ShapeDecl { @@ -243,7 +240,7 @@ fn shape_expression<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShapeExpr> { ) } -/// `[11] inlineShapeExpression ::= inlineShapeOr` +/// `[11] inlineShapeExpression ::= inlineShapeOr` fn inline_shape_expression<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShapeExpr> { traced( "inline_shape_expr", @@ -254,8 +251,8 @@ fn inline_shape_expression<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShapeExpr> ) } -/// `[12] shapeOr ::= shapeAnd ("OR" shapeAnd)*` -fn shape_or<'a>(i: Span<'a>) -> IRes<'a, ShapeExpr> { +/// `[12] shapeOr ::= shapeAnd ("OR" shapeAnd)*` +fn shape_or(i: Span<'_>) -> IRes<'_, ShapeExpr> { many1_sep(shape_and, symbol("OR"), make_shape_or, i) } @@ -267,12 +264,12 @@ fn make_shape_or(ses: Vec) -> ShapeExpr { } } -/// `[13] inlineShapeOr ::= inlineShapeAnd ("OR" inlineShapeAnd)*` +/// `[13] inlineShapeOr ::= inlineShapeAnd ("OR" inlineShapeAnd)*` fn inline_shape_or(i: Span) -> IRes { many1_sep(inline_shape_and, symbol("OR"), make_shape_or, i) } -/// `[14] shapeAnd ::= shapeNot ("AND" shapeNot)*`` +/// `[14] shapeAnd ::= shapeNot ("AND" shapeNot)*` fn shape_and(i: Span) -> IRes { many1_sep(shape_not, symbol("AND"), make_shape_and, i) } @@ -285,32 +282,32 @@ fn make_shape_and(ses: Vec) -> ShapeExpr { } } -/// `[15] inlineShapeAnd ::= inlineShapeNot ("AND" inlineShapeNot)*` +/// `[15] inlineShapeAnd ::= inlineShapeNot ("AND" inlineShapeNot)*` fn inline_shape_and(i: Span) -> IRes { many1_sep(inline_shape_not, symbol("AND"), make_shape_and, i) } -/// `[16] shapeNot ::= "NOT"? shapeAtom` +/// `[16] shapeNot ::= "NOT"? shapeAtom` fn shape_not(i: Span) -> IRes { let (i, maybe) = opt(symbol("NOT"))(i)?; let (i, se) = shape_atom()(i)?; match maybe { None => Ok((i, se)), - Some(_) => Ok((i, ShapeExpr::not(se))), + Some(_) => Ok((i, ShapeExpr::shape_not(se))), } } -/// `[17] inlineShapeNot ::= "NOT"? inlineShapeAtom` +/// `[17] inlineShapeNot ::= "NOT"? inlineShapeAtom` fn inline_shape_not(i: Span) -> IRes { let (i, maybe) = opt(symbol("NOT"))(i)?; let (i, se) = inline_shape_atom()(i)?; match maybe { None => Ok((i, se)), - Some(_) => Ok((i, ShapeExpr::not(se))), + Some(_) => Ok((i, ShapeExpr::shape_not(se))), } } -/// `[18] shapeAtom ::= nonLitNodeConstraint shapeOrRef? +/// `[18] shapeAtom ::= nonLitNodeConstraint shapeOrRef?` /// `| litNodeConstraint` /// `| shapeOrRef nonLitNodeConstraint?` /// `| '(' shapeExpression ')'` @@ -447,31 +444,23 @@ fn dot(i: Span) -> IRes { Ok((i, ShapeExpr::any())) } -/// `[21] shapeOrRef ::= shapeDefinition | shapeRef` +/// `[21] shapeOrRef ::= shapeDefinition | shapeRef` fn shape_or_ref<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShapeExpr> { traced( "shape_or_ref", map_error( - move |i| { - alt(( - shape_definition(), - map(shape_ref, |label| ShapeExpr::Ref(label)), - ))(i) - }, + move |i| alt((shape_definition(), map(shape_ref, ShapeExpr::Ref)))(i), || ShExParseError::ExpectedShapeOrRef, ), ) } -/// `[22] inlineShapeOrRef ::= inlineShapeDefinition | shapeRef` +/// `[22] inlineShapeOrRef ::= inlineShapeDefinition | shapeRef` fn inline_shape_or_ref(i: Span) -> IRes { - alt(( - inline_shape_definition, - map(shape_ref, |label| ShapeExpr::Ref(label)), - ))(i) + alt((inline_shape_definition, map(shape_ref, ShapeExpr::Ref)))(i) } -/// `[23] shapeRef ::= ATPNAME_LN | ATPNAME_NS | '@' shapeExprLabel` +/// `[23] shapeRef ::= ATPNAME_LN | ATPNAME_NS | '@' shapeExprLabel` fn shape_ref(i: Span) -> IRes { alt((at_pname_ln, at_pname_ns, at_shape_expr_label))(i) } @@ -481,7 +470,7 @@ fn at_shape_expr_label(i: Span) -> IRes { Ok((i, label)) } -/// `[24] litNodeConstraint ::= "LITERAL" xsFacet* +/// `[24] litNodeConstraint ::= "LITERAL" xsFacet* /// | datatype xsFacet* /// | valueSet xsFacet* /// | numericFacet+` @@ -551,8 +540,7 @@ fn facets<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Vec> { traced("facets", move |i| many0(xs_facet())(i)) } -/// `[25] nonLitNodeConstraint ::= nonLiteralKind stringFacet*` -/// ` | stringFacet+` +/// `[25] nonLitNodeConstraint ::= nonLiteralKind stringFacet* | stringFacet+` fn non_lit_node_constraint(i: Span) -> IRes { alt((non_literal_kind_string_facets, string_facets))(i) } @@ -573,7 +561,7 @@ fn string_facets(i: Span) -> IRes { Ok((i, NodeConstraint::new().with_xsfacets(facets))) } -/// `[26] nonLiteralKind ::= "IRI" | "BNODE" | "NONLITERAL"` +/// `[26] nonLiteralKind ::= "IRI" | "BNODE" | "NONLITERAL"` fn non_literal_kind(i: Span) -> IRes { alt(( map(token_tws("IRI"), |_| NodeKind::Iri), @@ -582,13 +570,12 @@ fn non_literal_kind(i: Span) -> IRes { ))(i) } -/// `[27] xsFacet ::= stringFacet | numericFacet` +/// `[27] xsFacet ::= stringFacet | numericFacet` fn xs_facet<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, XsFacet> { traced("xs_facet", move |i| alt((string_facet, numeric_facet()))(i)) } -/// `[28] stringFacet ::= stringLength INTEGER` -/// `| REGEXP` +/// `[28] stringFacet ::= stringLength INTEGER | REGEXP` fn string_facet(i: Span) -> IRes { alt(( string_length, @@ -627,8 +614,7 @@ fn pos_integer(i: Span) -> IRes { } } -/// `[30] numericFacet ::= numericRange numericLiteral -/// `| numericLength INTEGER` +/// `[30] numericFacet ::= numericRange numericLiteral | numericLength INTEGER` fn numeric_facet<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, XsFacet> { traced("numeric_facet", move |i| { alt((numeric_range_lit(), numeric_length_int()))(i) @@ -674,7 +660,7 @@ fn numeric_length(i: Span) -> IRes { ))(i) } -/// `[31] numericRange ::= "MININCLUSIVE" | "MINEXCLUSIVE" | "MAXINCLUSIVE" | "MAXEXCLUSIVE"` +/// `[31] numericRange ::= "MININCLUSIVE" | "MINEXCLUSIVE" | "MAXINCLUSIVE" | "MAXEXCLUSIVE"` fn numeric_range(i: Span) -> IRes { alt(( map(token_tws("MININCLUSIVE"), |_| NumericRange::MinInclusive), @@ -684,7 +670,7 @@ fn numeric_range(i: Span) -> IRes { ))(i) } -/// `[33] shapeDefinition ::= qualifiers '{' tripleExpression? '}' annotation* semanticActions` +/// `[33] shapeDefinition ::= qualifiers '{' tripleExpression? '}' annotation* semanticActions` /// qualifiers = (extraPropertySet | "CLOSED" | extends) * fn shape_definition<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShapeExpr> { traced( @@ -745,7 +731,7 @@ fn shape_definition<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ShapeExpr> { ) } -/// `[34] inlineShapeDefinition ::= qualifiers '{' tripleExpression? '}'` +/// `[34] inlineShapeDefinition ::= qualifiers '{' tripleExpression? '}'` fn inline_shape_definition(i: Span) -> IRes { let (i, (qualifiers, _, maybe_triple_expr, _)) = tuple(( qualifiers(), @@ -781,7 +767,7 @@ fn inline_shape_definition(i: Span) -> IRes { fn maybe_triple_expr<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Option> { traced("maybe_triple_expr", move |i| { - alt((map(triple_expression(), |te| Some(te)), map(tws0, |_| None)))(i) + alt((map(triple_expression(), Some), map(tws0, |_| None)))(i) }) } @@ -839,7 +825,7 @@ fn closed<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Qualifier> { ) } -/// `[35] extraPropertySet ::= "EXTRA" predicate+` +/// `[35] extraPropertySet ::= "EXTRA" predicate+` fn extra_property_set<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Qualifier> { traced( "extra_property_set", @@ -855,7 +841,7 @@ fn extra_property_set<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Qualifier> { ) } -/// `[36] tripleExpression ::= oneOfTripleExpr` +/// `[36] tripleExpression ::= oneOfTripleExpr` fn triple_expression<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { traced( "triple_expression", @@ -866,7 +852,7 @@ fn triple_expression<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { ) } -/// `[37] oneOfTripleExpr ::= groupTripleExpr | multiElementOneOf` +/// `[37] oneOfTripleExpr ::= groupTripleExpr | multiElementOneOf` fn one_of_triple_expr<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { traced( "one_of_triple_expr", @@ -877,7 +863,7 @@ fn one_of_triple_expr<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { ) } -/// `[38] multiElementOneOf ::= groupTripleExpr ('|' groupTripleExpr)+` +/// `[38] multiElementOneOf ::= groupTripleExpr ('|' groupTripleExpr)+` fn multi_element_one_of<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { traced("multi_element_one_of", move |i| { let (i, (te1, _, tes)) = tuple((group_triple_expr(), tws0, rest_group_triple_expr))(i)?; @@ -901,20 +887,20 @@ fn rest_group_triple_expr(i: Span) -> IRes> { Ok((i, tes)) } -/// `[40] groupTripleExpr ::= singleElementGroup | multiElementGroup` +/// `[40] groupTripleExpr ::= singleElementGroup | multiElementGroup` fn group_triple_expr<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { traced("group_triple_expr", move |i| { alt((multi_element_group, single_element_group))(i) }) } -/// `[41] singleElementGroup ::= unaryTripleExpr ';'?` +/// `[41] singleElementGroup ::= unaryTripleExpr ';'?` fn single_element_group(i: Span) -> IRes { let (i, (te, _, _)) = tuple((unary_triple_expr(), tws0, opt(char(';'))))(i)?; Ok((i, te)) } -/// `[42] multiElementGroup ::= unaryTripleExpr (';' unaryTripleExpr)+ ';'?` +/// `[42] multiElementGroup ::= unaryTripleExpr (';' unaryTripleExpr)+ ';'?` fn multi_element_group(i: Span) -> IRes { let (i, (te1, _, tes, _, _)) = tuple(( unary_triple_expr(), @@ -967,14 +953,11 @@ fn unary_triple_expr_opt1(i: Span) -> IRes { // From unary_triple_expr_opt1 fn triple_expr_label_opt(i: Span) -> IRes> { let (i, maybe_ts) = opt(tuple((char('$'), tws0, triple_expr_label)))(i)?; - let maybe_label = match maybe_ts { - Some((_, _, r)) => Some(r), - None => None, - }; + let maybe_label = maybe_ts.map(|(_, _, r)| r); Ok((i, maybe_label)) } -/// `[44] bracketedTripleExpr ::= '(' tripleExpression ')' cardinality? annotation* semanticActions` +/// `[44] bracketedTripleExpr ::= '(' tripleExpression ')' cardinality? annotation* semanticActions` fn bracketed_triple_expr<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { traced( "bracketed_triple_expr", @@ -992,12 +975,9 @@ fn bracketed_triple_expr<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { semantic_actions, ))(i)?; let mut te = te; - match maybe_card { - Some(card) => { - te = te.with_min(card.min()); - te = te.with_max(card.max()); - } - None => {} + if let Some(card) = maybe_card { + te = te.with_min(card.min()); + te = te.with_max(card.max()); }; if !annotations.is_empty() { te = te.with_annotations(Some(annotations)); @@ -1010,7 +990,7 @@ fn bracketed_triple_expr<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { ) } -/// `[45] tripleConstraint ::= senseFlags? predicate inlineShapeExpression cardinality? annotation* semanticActions` +/// `[45] tripleConstraint ::= senseFlags? predicate inlineShapeExpression cardinality? annotation* semanticActions` fn triple_constraint<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { traced( "triple_constraint", @@ -1071,7 +1051,6 @@ fn triple_constraint<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { ) } -/// fn sense_flags(i: Span) -> IRes { alt((sense_flags_negated, sense_flags_inverse))(i) } @@ -1086,10 +1065,7 @@ fn inverse(i: Span) -> IRes { fn sense_flags_negated(i: Span) -> IRes { let (i, (_, maybe_inverse)) = tuple((negated, opt(inverse)))(i)?; - let inverse = match maybe_inverse { - Some(_) => Some(true), - None => None, - }; + let inverse = maybe_inverse.map(|_| true); Ok(( i, SenseFlags { @@ -1101,10 +1077,7 @@ fn sense_flags_negated(i: Span) -> IRes { fn sense_flags_inverse(i: Span) -> IRes { let (i, (_, maybe_negated)) = tuple((inverse, opt(negated)))(i)?; - let negated = match maybe_negated { - Some(_) => Some(true), - None => None, - }; + let negated = maybe_negated.map(|_| true); Ok(( i, SenseFlags { @@ -1114,7 +1087,7 @@ fn sense_flags_inverse(i: Span) -> IRes { )) } -/// `[46] cardinality ::= '*' | '+' | '?' | REPEAT_RANGE` +/// `[46] cardinality ::= '*' | '+' | '?' | REPEAT_RANGE` fn cardinality<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Cardinality> { traced( "cardinality", @@ -1140,7 +1113,7 @@ fn optional(i: Span) -> IRes { Ok((i, Cardinality::optional())) } -/// `[48] valueSet ::= '[' valueSetValue* ']'` +/// `[48] valueSet ::= '[' valueSetValue* ']'` fn value_set<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, NodeConstraint> { traced( "value set", @@ -1155,8 +1128,8 @@ fn value_set<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, NodeConstraint> { ) } -/// `[49] valueSetValue ::= iriRange | literalRange | languageRange` -/// ` | exclusion+` +/// `[49] valueSetValue ::= iriRange | literalRange | languageRange` +/// ` | exclusion+` fn value_set_value<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ValueSetValue> { traced( "value_set_value", @@ -1208,7 +1181,7 @@ fn exclusion_plus<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ValueSetValue> { ) } -/// `[51] iriRange ::= iri ('~' exclusion*)?` +/// `[51] iriRange ::= iri ('~' exclusion*)?` fn iri_range(i: Span) -> IRes { let (i, (iri, _, maybe_stem)) = tuple((iri, tws0, opt(tilde_iri_exclusion)))(i)?; let value = match maybe_stem { @@ -1237,7 +1210,7 @@ fn tilde_literal_exclusion(i: Span) -> IRes> { Ok((i, es)) } -/// `[52] exclusion ::= '-' (iri | literal | LANGTAG) '~'?` +/// `[52] exclusion ::= '-' (iri | literal | LANGTAG) '~'?` fn iri_exclusion(i: Span) -> IRes { let (i, (_, iri, _, maybe_tilde)) = tuple((token_tws("-"), iri, tws0, opt(token_tws("~"))))(i)?; let iri_exc = match maybe_tilde { @@ -1247,7 +1220,7 @@ fn iri_exclusion(i: Span) -> IRes { Ok((i, iri_exc)) } -/// `[53] literalRange ::= literal ('~' literalExclusion*)?` +/// `[53] literalRange ::= literal ('~' literalExclusion*)?` fn literal_range<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ValueSetValue> { traced( "literal_range", @@ -1287,7 +1260,7 @@ fn dash<'a>() -> impl FnMut(Span<'a>) -> IRes> { move |i| token_tws("-")(i) } -/// `[54] literalExclusion ::= '-' literal '~'?` +/// `[54] literalExclusion ::= '-' literal '~'?` fn literal_exclusion(i: Span) -> IRes { let (i, (_, literal, maybe_tilde)) = tuple((dash(), literal(), opt(tilde())))(i)?; let le = match maybe_tilde { @@ -1370,7 +1343,7 @@ fn language_exclusions(i: Span) -> IRes> { many0(language_exclusion)(i) } -/// `[56] languageExclusion ::= '-' LANGTAG '~'?` +/// `[56] languageExclusion ::= '-' LANGTAG '~'?` fn language_exclusion(i: Span) -> IRes { let (i, (_, lang, _, maybe_tilde)) = tuple((token_tws("-"), lang_tag, tws0, opt(token_tws("~"))))(i)?; @@ -1381,7 +1354,7 @@ fn language_exclusion(i: Span) -> IRes { Ok((i, lang_exc)) } -/// `[57] include ::= '&' tripleExprLabel` +/// `[57] include ::= '&' tripleExprLabel` fn include_<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { traced( "include", @@ -1395,7 +1368,7 @@ fn include_<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, TripleExpr> { ) } -/// `[58] annotation ::= "//" predicate (iri | literal)` +/// `[58] annotation ::= "//" predicate (iri | literal)` fn annotation<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Annotation> { traced( "annotation", @@ -1403,7 +1376,7 @@ fn annotation<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Annotation> { move |i| { let (i, (_, p, _, o)) = tuple((token_tws("//"), cut(predicate), tws0, cut(iri_or_literal())))(i)?; - Ok((i, Annotation::new(p.into(), o))) + Ok((i, Annotation::new(p, o))) }, || ShExParseError::ExpectedAnnotation, ), @@ -1417,8 +1390,8 @@ fn iri_or_literal<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ObjectValue> { map_error( move |i| { alt(( - map(iri, |i| ObjectValue::iri_ref(i)), - map(literal(), |lit| ObjectValue::Literal(lit)), + map(iri, ObjectValue::iri_ref), + map(literal(), ObjectValue::Literal), ))(i) }, || ShExParseError::ExpectedIriOrLiteral, @@ -1426,7 +1399,7 @@ fn iri_or_literal<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, ObjectValue> { ) } -/// `[59] semanticActions ::= codeDecl*` +/// `[59] semanticActions ::= codeDecl*` fn semantic_actions(i: Span) -> IRes>> { let (i, sas) = many0(code_decl())(i)?; if sas.is_empty() { @@ -1436,7 +1409,7 @@ fn semantic_actions(i: Span) -> IRes>> { } } -/// `[60] codeDecl ::= '%' iri (CODE | '%')` +/// `[60] codeDecl ::= '%' iri (CODE | '%')` fn code_decl<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, SemAct> { traced( "code_decl", @@ -1444,7 +1417,7 @@ fn code_decl<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, SemAct> { move |i| { let (i, (_, _, iri, _, code, _)) = tuple((char('%'), tws0, cut(iri), tws0, cut(code_or_percent), tws0))(i)?; - Ok((i, SemAct::new(IriRef::from(iri), code))) + Ok((i, SemAct::new(iri, code))) }, || ShExParseError::CodeDeclaration, ), @@ -1461,7 +1434,7 @@ fn percent_code(i: Span) -> IRes> { Ok((i, None)) } -/// `[13t] literal ::= rdfLiteral | numericLiteral | booleanLiteral` +/// `[13t] literal ::= rdfLiteral | numericLiteral | booleanLiteral` fn literal<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Literal> { traced( "literal", @@ -1469,7 +1442,7 @@ fn literal<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Literal> { move |i| { alt(( rdf_literal(), - map(numeric_literal, |n| Literal::NumericLiteral(n)), + map(numeric_literal, Literal::NumericLiteral), boolean_literal, ))(i) }, @@ -1478,23 +1451,23 @@ fn literal<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Literal> { ) } -/// `[16t] numericLiteral ::= INTEGER | DECIMAL | DOUBLE` +/// `[16t] numericLiteral ::= INTEGER | DECIMAL | DOUBLE` fn numeric_literal(i: Span) -> IRes { alt(( - map(double, |n| NumericLiteral::double(n)), + map(double, NumericLiteral::double), decimal, integer_literal(), ))(i) } /// raw_numeric_literal obtains a numeric literal as a JSON -/// `[16t] rawnumericLiteral ::= INTEGER | DECIMAL | DOUBLE +/// `[16t] rawnumericLiteral ::= INTEGER | DECIMAL | DOUBLE /// ` fn raw_numeric_literal<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, NumericLiteral> { map_error( move |i| { alt(( - map(double, |n| NumericLiteral::decimal_from_f64(n)), + map(double, NumericLiteral::decimal_from_f64), decimal, raw_integer_literal(), ))(i) @@ -1505,20 +1478,20 @@ fn raw_numeric_literal<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, NumericLiteral> fn raw_integer_literal<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, NumericLiteral> { map_error( - move |i| map(integer(), |n| NumericLiteral::decimal_from_i128(n))(i), + move |i| map(integer(), NumericLiteral::decimal_from_i128)(i), || ShExParseError::IntegerLiteral, ) } fn integer_literal<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, NumericLiteral> { map_error( - move |i| map(integer(), |n| NumericLiteral::integer_from_i128(n))(i), + move |i| map(integer(), NumericLiteral::integer_from_i128)(i), || ShExParseError::IntegerLiteral, ) } fn boolean_literal(i: Span) -> IRes { - map(boolean_value, |b| Literal::boolean(b))(i) + map(boolean_value, Literal::boolean)(i) } fn boolean_value(i: Span) -> IRes { @@ -1613,7 +1586,7 @@ fn single_quote_char<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, char> { }) } -/// `[158s] ::= "'''" ( ("'" | "''")? ([^\\'\\] | ECHAR | UCHAR) )* "'''"` +/// `[158s] ::= "'''" ( ("'" | "''")? ([^\\'\\] | ECHAR | UCHAR) )* "'''"` fn string_literal_long1(i: Span) -> IRes { let (i, chars) = delimited( token("'''"), @@ -1624,7 +1597,7 @@ fn string_literal_long1(i: Span) -> IRes { Ok((i, str)) } -/// `[159s] ::= '"""' ( ('"' | '""')? ([^\"\\] | ECHAR | UCHAR) )* '"""'` +/// `[159s] ::= '"""' ( ('"' | '""')? ([^\"\\] | ECHAR | UCHAR) )* '"""'` fn string_literal_long2(i: Span) -> IRes { let (i, chars) = delimited( token(r#"""""#), @@ -1672,8 +1645,8 @@ const REQUIRES_ESCAPE: &str = "\u{22}\u{5C}\u{0A}\u{0D}"; /// 22 = ", 5C = \, 0A = \n, 0D = \r const REQUIRES_ESCAPE_SINGLE_QUOTE: &str = "\u{27}\u{5C}\u{0A}\u{0D}"; -/// `[26t] ::= "\\u" HEX HEX HEX HEX` -/// ` | "\\U" HEX HEX HEX HEX HEX HEX HEX HEX` +/// `[26t] ::= "\\u" HEX HEX HEX HEX` +/// ` | "\\U" HEX HEX HEX HEX HEX HEX HEX HEX` fn uchar(i: Span) -> IRes { let (i, str) = recognize(alt(( preceded(token(r"\u"), count(hex, 4)), @@ -1683,7 +1656,7 @@ fn uchar(i: Span) -> IRes { Ok((i, c)) } -/// `[160s] ::= "\\" [tbnrf\\\"\\']` +/// `[160s] ::= "\\" [tbnrf\\\"\\']` /// Escaped chars. The unicode chars come from Turtle https://www.w3.org/TR/turtle/#string fn echar(i: Span) -> IRes { let (i, c) = preceded(token(r"\"), one_of(r#"tbnrf"'\"#))(i)?; @@ -1701,7 +1674,7 @@ fn echar(i: Span) -> IRes { Ok((i, c)) } -/// `[145s] ::= "@" ([a-zA-Z])+ ("-" ([a-zA-Z0-9])+)*` +/// `[145s] ::= "@" ([a-zA-Z])+ ("-" ([a-zA-Z0-9])+)*` fn lang_tag(i: Span) -> IRes { let (i, lang_str) = preceded( token("@"), @@ -1710,18 +1683,18 @@ fn lang_tag(i: Span) -> IRes { Ok((i, Lang::new(lang_str.fragment()))) } -/// `[61] predicate ::= iri | RDF_TYPE` +/// `[61] predicate ::= iri | RDF_TYPE` fn predicate(i: Span) -> IRes { alt((iri, rdf_type))(i) } -/// `[62] datatype ::= iri` +/// `[62] datatype ::= iri` fn datatype(i: Span) -> IRes { let (i, iri_ref) = iri(i)?; Ok((i, NodeConstraint::new().with_datatype(iri_ref))) } -/// `[63] shapeExprLabel ::= iri | blankNode` +/// `[63] shapeExprLabel ::= iri | blankNode` pub(crate) fn shape_expr_label(i: Span) -> IRes { let (i, ref_) = alt((iri_as_ref, blank_node_ref))(i)?; Ok((i, ref_)) @@ -1736,7 +1709,7 @@ fn blank_node_ref(i: Span) -> IRes { Ok((i, ShapeExprLabel::bnode(bn))) } -/// `[64] tripleExprLabel ::= iri | blankNode` +/// `[64] tripleExprLabel ::= iri | blankNode` fn triple_expr_label(i: Span) -> IRes { alt(( map(iri, |value| TripleExprLabel::IriRef { value }), @@ -1744,8 +1717,8 @@ fn triple_expr_label(i: Span) -> IRes { ))(i) } -/// `[67] ::= "{" ([^%\\] | "\\" [%\\] | UCHAR)* "%" "}"` -/// ` code_str = ([^%\\] | "\\" [%\\] | UCHAR)*` +/// `[67] ::= "{" ([^%\\] | "\\" [%\\] | UCHAR)* "%" "}"` +/// ` code_str = ([^%\\] | "\\" [%\\] | UCHAR)*` fn code<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Option> { traced( "code", @@ -1832,7 +1805,7 @@ fn escaped_code(i: Span) -> IRes { Ok((i, c)) } -/// `[68] ::= "{" INTEGER ( "," (INTEGER | "*")? )? "}"` +/// `[68] ::= "{" INTEGER ( "," (INTEGER | "*")? )? "}"` fn repeat_range<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Cardinality> { traced( "repeat_range", @@ -1844,7 +1817,7 @@ fn repeat_range<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, Cardinality> { None => Cardinality::exact(min as i32), Some(maybe_max) => match maybe_max { None => Cardinality::min_max(min as i32, -1), - Some(max) => Cardinality::min_max(min as i32, max as i32), + Some(max) => Cardinality::min_max(min as i32, max), }, }; Ok((i, cardinality)) @@ -1877,27 +1850,27 @@ fn integer_or_star(i: Span) -> IRes { ))(i) } -/// `[69] ::= "a"` +/// `[69] ::= "a"` fn rdf_type(i: Span) -> IRes { let (i, _) = tag_no_case("a")(i)?; let rdf_type: IriRef = IriRef::iri(IriS::new_unchecked(RDF_TYPE_STR)); Ok((i, rdf_type)) } -/// `[70] ::= "@" PNAME_NS` +/// `[70] ::= "@" PNAME_NS` fn at_pname_ns(i: Span) -> IRes { let (i, (_, _, pname)) = tuple((char('@'), tws0, pname_ns_iri_ref))(i)?; let label = ShapeExprLabel::iri_ref(pname); Ok((i, label)) } -/// `[71] ::= "@" PNAME_LN` +/// `[71] ::= "@" PNAME_LN` fn at_pname_ln(i: Span) -> IRes { let (i, (_, _, pname_ln)) = tuple((char('@'), tws0, pname_ln))(i)?; Ok((i, ShapeExprLabel::iri_ref(pname_ln))) } -/// `[72] ::= '/' ([^/\\\n\r] +/// `[72] ::= '/' ([^/\\\n\r] /// | '\\' [nrt\\|.?*+(){}$-\[\]^/] /// | UCHAR /// )+ '/' [smix]*` @@ -1991,7 +1964,7 @@ fn flags(i: Span) -> IRes { recognize(many0(alt((char('s'), char('m'), char('i'), char('x')))))(i) } -/// `[136s] iri ::= IRIREF | prefixedName` +/// `[136s] iri ::= IRIREF | prefixedName` pub(crate) fn iri(i: Span) -> IRes { alt((iri_ref_s, prefixed_name()))(i) } @@ -2001,7 +1974,7 @@ fn iri_ref_s(i: Span) -> IRes { Ok((i, iri.into())) } -/// `[137s] prefixedName ::= PNAME_LN | PNAME_NS` +/// `[137s] prefixedName ::= PNAME_LN | PNAME_NS` fn prefixed_name<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, IriRef> { traced( "prefixed_name", @@ -2015,6 +1988,7 @@ fn prefixed_name<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, IriRef> { ) } +/* /// `[137s] prefixedName ::= PNAME_LN | PNAME_NS` fn prefixed_name_refactor<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, IriRef> { traced( @@ -2028,20 +2002,21 @@ fn prefixed_name_refactor<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, IriRef> { ), ) } +*/ fn pname_ns_iri_ref(i: Span) -> IRes { let (i, pname_ns) = pname_ns(i)?; Ok((i, IriRef::prefixed(pname_ns.fragment(), ""))) } -/// `[138s] blankNode ::= BLANK_NODE_LABEL` +/// `[138s] blankNode ::= BLANK_NODE_LABEL` fn blank_node(i: Span) -> IRes { - map(blank_node_label, |str| BNode::new(str))(i) + map(blank_node_label, BNode::new)(i) } //---- Terminals -/// `[142s] ::= "_:" (PN_CHARS_U | [0-9]) ((PN_CHARS | ".")* PN_CHARS)?` +/// `[142s] ::= "_:" (PN_CHARS_U | [0-9]) ((PN_CHARS | ".")* PN_CHARS)?` fn blank_node_label(i: Span) -> IRes<&str> { let (i, _) = tag("_:")(i)?; let (i, label) = recognize(tuple((one_if(is_pn_chars_u_digit), blank_node_label2)))(i)?; @@ -2078,7 +2053,7 @@ fn blank_node_label3(i: Span) -> IRes { take_while(is_pn_chars_or_dot)(i) } -/// `[19t] ::= [+-]? [0-9]+` +/// `[19t] ::= [+-]? [0-9]+` fn integer<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, i128> { map_error( move |i| { @@ -2095,7 +2070,7 @@ fn integer<'a>() -> impl FnMut(Span<'a>) -> IRes<'a, i128> { ) } -/// `[20t] ::= [+-]? [0-9]* "." [0-9]+` +/// `[20t] ::= [+-]? [0-9]* "." [0-9]+` fn decimal(i: Span) -> IRes { map_res( pair( @@ -2111,7 +2086,7 @@ fn decimal(i: Span) -> IRes { )(i) } -/// `[21t] ::= [+-]? ([0-9]+ "." [0-9]* EXPONENT | "."? [0-9]+ EXPONENT)` +/// `[21t] ::= [+-]? ([0-9]+ "." [0-9]* EXPONENT | "."? [0-9]+ EXPONENT)` fn double(i: Span) -> IRes { map_res( recognize(preceded( @@ -2138,14 +2113,14 @@ fn digits(i: Span) -> IRes { map_res(digit1, |number: Span| number.parse::())(i) } -/// `[141s] ::= PNAME_NS PN_LOCAL` +/// `[141s] ::= PNAME_NS PN_LOCAL` fn pname_ln(i: Span) -> IRes { // This code is different here: https://github.com/vandenoever/rome/blob/047cf54def2aaac75ac4b9adbef08a9d010689bd/src/io/turtle/grammar.rs#L293 let (i, (prefix, local)) = tuple((pname_ns, pn_local))(i)?; Ok((i, IriRef::prefixed(prefix.fragment(), local))) } -/// `[77] ::= (PN_CHARS_U | ":" | [0-9] | PLX) (PN_CHARS | "." | ":" | PLX)` +/// `[77] ::= (PN_CHARS_U | ":" | [0-9] | PLX) (PN_CHARS | "." | ":" | PLX)` fn pn_local(i: Span) -> IRes<&str> { let (i, cs) = recognize(tuple((alt((one_if(is_pn_local_start), plx)), pn_local2)))(i)?; Ok((i, cs.fragment())) @@ -2190,8 +2165,8 @@ fn plx(i: Span) -> IRes { } /// ShEx rule -/// `[173s] ::= "\\" ( "_" | "~" | "." | "-" | "!" | "$" | "&" | "'" | -/// "(" | ")" | "*" | "+" | "," | ";" | "=" | "/" | "?" | "#" | "@" | "%" )`` +/// `[173s] ::= "\\" ( "_" | "~" | "." | "-" | "!" | "$" | "&" | "'" | +/// "(" | ")" | "*" | "+" | "," | ";" | "=" | "/" | "?" | "#" | "@" | "%" )`` fn pn_local_esc(i: Span) -> IRes { recognize(tuple(( char('\\'), @@ -2204,10 +2179,10 @@ fn percent(i: Span) -> IRes { } fn is_hex(c: char) -> bool { - is_digit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') + is_digit(c) || ('a'..='f').contains(&c) || ('A'..='F').contains(&c) } -/// `[18t] ::= "<" ([^#0000- <>\"{}|^`\\] | UCHAR)* ">"` +/// `[18t] ::= "<" ([^#0000- <>\"{}|^`\\] | UCHAR)* ">"` /// iri_chars = ([^#0000- <>\"{}|^`\\] | UCHAR)* fn iri_ref(i: Span) -> IRes { let (i, str) = delimited( @@ -2298,16 +2273,16 @@ fn iri_chr(i: Span) -> IRes { #[inline] fn is_iri_ref(chr: char) -> bool { - chr > ' ' && "<>\"{}|^`\\".find(chr) == None + chr > ' ' && "<>\"{}|^`\\".find(chr).is_none() } -/// [140s] ` ::= PN_PREFIX? ":"` +/// [140s] ` ::= PN_PREFIX? ":"` fn pname_ns(i: Span) -> IRes { let (i, (maybe_pn_prefix, _)) = tuple((opt(pn_prefix), char(':')))(i)?; Ok((i, maybe_pn_prefix.unwrap_or(Span::from("")))) } -/// [168s] ` ::= PN_CHARS_BASE ( (PN_CHARS | ".")* PN_CHARS )?` +/// [168s] ` ::= PN_CHARS_BASE ( (PN_CHARS | ".")* PN_CHARS )?` fn pn_prefix(i: Span) -> IRes { /*let (i, (pn_chars_base, maybe_rest)) = tuple((pn_chars_base, opt(rest_pn_prefix)))(i)?; let mut s: String = pn_chars_base.to_string(); @@ -2351,12 +2326,12 @@ fn char_dot(i: Span) -> IRes { one_if(is_pn_chars)(i) }*/ -/// [164s] ` ::= [A-Z] | [a-z]` -/// ` | [#00C0-#00D6] | [#00D8-#00F6] | [#00F8-#02FF]` -/// ` | [#0370-#037D] | [#037F-#1FFF]` -/// ` | [#200C-#200D] | [#2070-#218F] | [#2C00-#2FEF]` -/// ` | [#3001-#D7FF] | [#F900-#FDCF] | [#FDF0-#FFFD]` -/// ` | [#10000-#EFFFF]` +/// [164s] ` ::= [A-Z] | [a-z]` +/// ` | [#00C0-#00D6] | [#00D8-#00F6] | [#00F8-#02FF]` +/// ` | [#0370-#037D] | [#037F-#1FFF]` +/// ` | [#200C-#200D] | [#2070-#218F] | [#2C00-#2FEF]` +/// ` | [#3001-#D7FF] | [#F900-#FDCF] | [#FDF0-#FFFD]` +/// ` | [#10000-#EFFFF]` fn is_pn_chars_base(c: char) -> bool { is_alpha(c) || in_range(c, 0xC0, 0x00D6) @@ -2373,12 +2348,12 @@ fn is_pn_chars_base(c: char) -> bool { || in_range(c, 0x10000, 0xEFFFF) } -/// `[165s] ::= PN_CHARS_BASE | "_"` +/// `[165s] ::= PN_CHARS_BASE | "_"` fn is_pn_chars_u(c: char) -> bool { c == '_' || is_pn_chars_base(c) } -/// `[167s] ::= PN_CHARS_U | "-" | [0-9]` +/// `[167s] ::= PN_CHARS_U | "-" | [0-9]` /// ` | [#00B7] | [#0300-#036F] | [#203F-#2040]` fn is_pn_chars(c: char) -> bool { is_pn_chars_u(c) @@ -2390,11 +2365,11 @@ fn is_pn_chars(c: char) -> bool { } fn is_alpha(c: char) -> bool { - (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') + c.is_ascii_lowercase() || c.is_ascii_uppercase() } fn is_digit(c: char) -> bool { - c >= '0' && c <= '9' + c.is_ascii_digit() } fn in_range(c: char, lower: u32, upper: u32) -> bool { diff --git a/shex_compact/src/shex_parser.rs b/shex_compact/src/shex_parser.rs index 100edef1..51870586 100644 --- a/shex_compact/src/shex_parser.rs +++ b/shex_compact/src/shex_parser.rs @@ -4,7 +4,7 @@ use prefixmap::Deref; use shex_ast::Iri; use shex_ast::Schema; use std::fs; -use std::path::{Path, PathBuf}; +use std::path::Path; use crate::grammar_structs::ShExStatement; use crate::shex_statement; @@ -35,7 +35,6 @@ impl<'a> ShExParser<'a> { let mut shapes_counter = 0; for s in parser.shex_statement_iterator.by_ref() { match s? { - ShExStatement::Empty => {} ShExStatement::BaseDecl { iri } => { schema = schema.with_base(Some(iri)); } diff --git a/shex_compact/src/shex_parser_error.rs b/shex_compact/src/shex_parser_error.rs index 7f8ab870..2ed32412 100644 --- a/shex_compact/src/shex_parser_error.rs +++ b/shex_compact/src/shex_parser_error.rs @@ -1,6 +1,5 @@ use iri_s::IriSError; use prefixmap::DerefError; -use regex::Regex; use std::{ io, num::{ParseFloatError, ParseIntError}, diff --git a/shex_testsuite/Cargo.toml b/shex_testsuite/Cargo.toml index 770f3bf7..075bb705 100644 --- a/shex_testsuite/Cargo.toml +++ b/shex_testsuite/Cargo.toml @@ -17,7 +17,6 @@ shex_ast = { path = "../shex_ast", version = "0.0.11" } shex_compact = { path = "../shex_compact", version = "0.0.11" } shex_validation = { path = "../shex_validation", version = "0.0.11" } serde = { version = "1.0", features = ["derive"] } -# serde_derive = "1.0" serde_json = "1.0" serde_yaml = "0.9.21" anyhow = "1.0" @@ -28,9 +27,5 @@ clap = { version = "4.2.1", features = ["derive"] } # rio_turtle = "0.8.2" oxrdf = "0.2.0-alpha.2" oxiri = "0.2.3-alpha.1" -clippy = "0.0.302" url = "2.4" tracing = "0.1" - - -[dev-dependencies] diff --git a/shex_testsuite/src/manifest.rs b/shex_testsuite/src/manifest.rs index 126a5fd3..47c66102 100644 --- a/shex_testsuite/src/manifest.rs +++ b/shex_testsuite/src/manifest.rs @@ -7,6 +7,8 @@ use std::path::Path; pub trait Manifest { fn len(&self) -> usize; + fn is_empty(&self) -> bool; + fn entry_names(&self) -> Vec; fn run_entry(&self, name: &str, base: &Path) -> Result<(), ManifestError>; @@ -28,38 +30,32 @@ pub trait Manifest { mode: ManifestRunMode, excluded_entries: Vec, single_entries: Option>, - single_traits: Option>, + _single_traits: Option>, ) -> ManifestRunResult { let mut result: ManifestRunResult = ManifestRunResult::new(); for entry_name in &self.entry_names() { if excluded_entries.contains(entry_name) { result.add_skipped(entry_name.to_string()); - () - } else if Self::should_run_entry_name(&self, &single_entries, entry_name) { + } else if Self::should_run_entry_name(self, &single_entries, entry_name) { let safe_result = catch_unwind(AssertUnwindSafe(move || self.run_entry(entry_name, base))); match safe_result { Ok(Ok(())) => { result.add_passed(entry_name.to_string()); - () } Ok(Err(e)) => { result.add_failed(entry_name.to_string(), e); - match mode { - ManifestRunMode::FailFirstError => return result, - _ => (), + if mode == ManifestRunMode::FailFirstError { + return result; } } Err(err) => { result.add_panicked(entry_name.to_string(), err); - match mode { - ManifestRunMode::FailFirstError => return result, - _ => (), + if mode == ManifestRunMode::FailFirstError { + return result; } } } - } else { - () } } result diff --git a/shex_testsuite/src/manifest_error.rs b/shex_testsuite/src/manifest_error.rs index 16b4d6f3..0e4725ae 100644 --- a/shex_testsuite/src/manifest_error.rs +++ b/shex_testsuite/src/manifest_error.rs @@ -3,7 +3,7 @@ use shex_ast::{ast::SchemaJsonError, CompiledSchemaError, Schema}; use shex_compact::ParseError; use shex_validation::{ResultValue, ValidatorError}; use srdf::srdf_graph::SRDFGraphError; -use std::{ffi::OsString, io, path::Path}; +use std::{ffi::OsString, io}; use thiserror::Error; #[derive(Error, Debug)] @@ -45,7 +45,7 @@ pub enum ManifestError { ParseError(#[from] ParseError), #[error(transparent)] - CompiledSchemaError(#[from] CompiledSchemaError), + CompiledSchemaError(#[from] Box), #[error(transparent)] IriError(#[from] IriSError), diff --git a/shex_testsuite/src/manifest_negative_structure.rs b/shex_testsuite/src/manifest_negative_structure.rs index 2cc689f9..e10d2494 100644 --- a/shex_testsuite/src/manifest_negative_structure.rs +++ b/shex_testsuite/src/manifest_negative_structure.rs @@ -22,7 +22,7 @@ pub struct ManifestNegativeStructureJson { graph: Vec, } -impl<'a> From for ManifestNegativeStructure { +impl From for ManifestNegativeStructure { fn from(m: ManifestNegativeStructureJson) -> Self { let entries = &m.graph[0].entries; let names = entries.iter().map(|e| e.name.clone()).collect(); @@ -32,7 +32,7 @@ impl<'a> From for ManifestNegativeStructure { } ManifestNegativeStructure { entry_names: names, - map: map, + map, } } } @@ -70,8 +70,8 @@ struct NegativeStructureEntry { } impl NegativeStructureEntry { - pub fn run(&self, base: &Path) -> Result<(), ManifestError> { - debug!("Runnnig entry: {}...not implemented", self.id); + pub fn run(&self, _base: &Path) -> Result<(), ManifestError> { + debug!("Running entry: {}...not implemented", self.id); Ok(()) } } @@ -81,6 +81,10 @@ impl Manifest for ManifestNegativeStructure { self.entry_names.len() } + fn is_empty(&self) -> bool { + self.entry_names.is_empty() + } + fn entry_names(&self) -> Vec { self.entry_names.clone() // iter().map(|n| n.clone()).collect() } @@ -105,7 +109,7 @@ mod tests { fn count_negative_structure_entries() { let manifest_path = Path::new("shexTest/negativeStructure/manifest.jsonld"); let manifest = { - let manifest_str = fs::read_to_string(&manifest_path).unwrap(); + let manifest_str = fs::read_to_string(manifest_path).unwrap(); serde_json::from_str::(&manifest_str).unwrap() }; assert_eq!(manifest.entry_names.len(), 14); diff --git a/shex_testsuite/src/manifest_negative_syntax.rs b/shex_testsuite/src/manifest_negative_syntax.rs index 82f80533..ec7b795f 100644 --- a/shex_testsuite/src/manifest_negative_syntax.rs +++ b/shex_testsuite/src/manifest_negative_syntax.rs @@ -22,7 +22,7 @@ pub struct ManifestNegativeSyntaxJson { graph: Vec, } -impl<'a> From for ManifestNegativeSyntax { +impl From for ManifestNegativeSyntax { fn from(m: ManifestNegativeSyntaxJson) -> Self { let entries = &m.graph[0].entries; let names = entries.iter().map(|e| e.name.clone()).collect(); @@ -32,7 +32,7 @@ impl<'a> From for ManifestNegativeSyntax { } ManifestNegativeSyntax { entry_names: names, - map: map, + map, } } } @@ -55,6 +55,9 @@ impl Manifest for ManifestNegativeSyntax { fn len(&self) -> usize { self.entry_names.len() } + fn is_empty(&self) -> bool { + self.entry_names.is_empty() + } fn entry_names(&self) -> Vec { self.entry_names.clone() // iter().map(|n| n.clone()).collect() @@ -90,8 +93,8 @@ struct NegativeSyntaxEntry { } impl NegativeSyntaxEntry { - pub fn run(&self, base: &Path) -> Result<(), ManifestError> { - debug!("Runnnig entry: {}...not implemented", self.id); + pub fn run(&self, _base: &Path) -> Result<(), ManifestError> { + debug!("Running entry: {}...not implemented", self.id); Ok(()) } } @@ -106,7 +109,7 @@ mod tests { fn count_negative_syntax_entries() { let manifest_path = Path::new("shexTest/negativeSyntax/manifest.jsonld"); let manifest = { - let manifest_str = fs::read_to_string(&manifest_path).unwrap(); + let manifest_str = fs::read_to_string(manifest_path).unwrap(); serde_json::from_str::(&manifest_str).unwrap() }; assert_eq!(manifest.entry_names.len(), 100); diff --git a/shex_testsuite/src/manifest_run_result.rs b/shex_testsuite/src/manifest_run_result.rs index daf0a480..81940e42 100644 --- a/shex_testsuite/src/manifest_run_result.rs +++ b/shex_testsuite/src/manifest_run_result.rs @@ -10,6 +10,12 @@ pub struct ManifestRunResult { pub panicked: Vec<(String, Box)>, } +impl Default for ManifestRunResult { + fn default() -> Self { + Self::new() + } +} + impl ManifestRunResult { pub fn new() -> ManifestRunResult { ManifestRunResult { diff --git a/shex_testsuite/src/manifest_schemas.rs b/shex_testsuite/src/manifest_schemas.rs index d370774a..291cadda 100644 --- a/shex_testsuite/src/manifest_schemas.rs +++ b/shex_testsuite/src/manifest_schemas.rs @@ -20,7 +20,7 @@ pub struct ManifestSchemas { map: HashMap, } -impl<'a> From for ManifestSchemas { +impl From for ManifestSchemas { fn from(m: ManifestSchemasJson) -> Self { let entries = &m.graph[0].entries; let names = entries.iter().map(|e| e.name.clone()).collect(); @@ -30,7 +30,7 @@ impl<'a> From for ManifestSchemas { } ManifestSchemas { entry_names: names, - map: map, + map, } } } @@ -134,7 +134,7 @@ impl<'de> Deserialize<'de> for Focus { } impl ManifestSchemas { - pub fn run(&self, base: &Path, debug: u8) -> Result<(), ManifestError> { + pub fn run(&self, base: &Path, _debug: u8) -> Result<(), ManifestError> { for entry in self.map.values() { entry.run(base)? } @@ -145,7 +145,7 @@ impl ManifestSchemas { impl SchemasEntry { pub fn run(&self, base: &Path) -> Result<(), ManifestError> { tracing::debug!( - "Runnnig entry: {} with json: {}, shex: {}, base: {:?}", + "Running entry: {} with json: {}, shex: {}, base: {:?}", self.id, self.json, self.shex, @@ -228,6 +228,10 @@ impl Manifest for ManifestSchemas { self.entry_names.len() } + fn is_empty(&self) -> bool { + self.entry_names.is_empty() + } + fn entry_names(&self) -> Vec { self.entry_names.clone() // iter().map(|n| n.clone()).collect() } @@ -252,7 +256,7 @@ mod tests { fn count_local_manifest_entries() { let manifest_path = Path::new("localTest/schemas/manifest.jsonld"); let manifest = { - let manifest_str = fs::read_to_string(&manifest_path).unwrap(); + let manifest_str = fs::read_to_string(manifest_path).unwrap(); serde_json::from_str::(&manifest_str).unwrap() }; assert_eq!(manifest.len(), 2); @@ -262,7 +266,7 @@ mod tests { fn count_schema_entries() { let manifest_path = Path::new("shexTest/schemas/manifest.jsonld"); let manifest = { - let manifest_str = fs::read_to_string(&manifest_path).unwrap(); + let manifest_str = fs::read_to_string(manifest_path).unwrap(); serde_json::from_str::(&manifest_str).unwrap() }; assert_eq!(manifest.len(), 433); diff --git a/shex_testsuite/src/manifest_validation.rs b/shex_testsuite/src/manifest_validation.rs index 48d334e2..6212e7a4 100644 --- a/shex_testsuite/src/manifest_validation.rs +++ b/shex_testsuite/src/manifest_validation.rs @@ -39,7 +39,7 @@ struct ManifestValidationJson { graph: Vec, } -impl<'a> From for ManifestValidation { +impl From for ManifestValidation { fn from(m: ManifestValidationJson) -> Self { let entries = &m.graph[0].entries; let names = entries.iter().map(|e| e.name.clone()).collect(); @@ -49,7 +49,7 @@ impl<'a> From for ManifestValidation { } ManifestValidation { entry_names: names, - map: map, + map, } } } @@ -189,7 +189,9 @@ impl ValidationEntry { let mut compiler = SchemaJsonCompiler::new(); let mut compiled_schema = CompiledSchema::new(); - compiler.compile(&schema, &mut compiled_schema)?; + compiler + .compile(&schema, &mut compiled_schema) + .map_err(Box::new)?; let mut validator = Validator::new(compiled_schema); validator.validate_node_shape(&node, &shape, &graph)?; let type_ = parse_type(&self.type_)?; @@ -219,7 +221,7 @@ fn parse_maybe_shape(shape: &Option) -> Result Ok(ShapeLabel::Start), Some(str) => { - let shape = parse_shape(&str)?; + let shape = parse_shape(str)?; Ok(shape) } } @@ -275,6 +277,10 @@ impl Manifest for ManifestValidation { self.entry_names.len() } + fn is_empty(&self) -> bool { + self.entry_names.is_empty() + } + fn entry_names(&self) -> Vec { self.entry_names.clone() // iter().map(|n| n.clone()).collect() } @@ -299,7 +305,7 @@ mod tests { fn count_validation_entries() { let manifest_path = Path::new("shexTest/validation/manifest.jsonld"); let manifest = { - let manifest_str = fs::read_to_string(&manifest_path).unwrap(); + let manifest_str = fs::read_to_string(manifest_path).unwrap(); serde_json::from_str::(&manifest_str).unwrap() }; assert_eq!(manifest.entry_names.len(), 1166); diff --git a/shex_validation/Cargo.toml b/shex_validation/Cargo.toml index 07d574cb..001611a4 100755 --- a/shex_validation/Cargo.toml +++ b/shex_validation/Cargo.toml @@ -23,7 +23,7 @@ serde_derive = "1.0" serde_json = "1.0" tokio = { version = "^1.35", features = ["full"] } tracing = "0.1" -indexmap = { version = "2", feature = "serde" } +indexmap = { version = "2" } colored = "2" either = "1" diff --git a/shex_validation/src/lib.rs b/shex_validation/src/lib.rs index e52fa3c1..3d28885d 100755 --- a/shex_validation/src/lib.rs +++ b/shex_validation/src/lib.rs @@ -17,21 +17,10 @@ pub use crate::reason::*; pub use crate::result_map::*; pub use crate::result_value::*; pub use crate::rule::*; -pub use crate::solver::*; pub use crate::validator::*; pub use crate::validator_error::*; pub use crate::validator_runner::*; -// pub mod validation_error; -// pub mod cardinality_error; -// pub mod cardinality; - -// pub use crate::cardinality_error::*; -// pub use crate::cardinality::*; -// pub use crate::validation_error::*; - /// Default MAX STEPS /// This value can be overriden in the Validator configuration const MAX_STEPS: usize = 20; - -type Result = std::result::Result; diff --git a/shex_validation/src/reason.rs b/shex_validation/src/reason.rs index 4b2de42c..8cd10537 100644 --- a/shex_validation/src/reason.rs +++ b/shex_validation/src/reason.rs @@ -1,6 +1,5 @@ use std::fmt::Display; -use prefixmap::PrefixMap; use shex_ast::{ compiled::{node_constraint::NodeConstraint, shape::Shape, shape_expr::ShapeExpr}, Node, diff --git a/shex_validation/src/result_map.rs b/shex_validation/src/result_map.rs index f52f5e11..b69e8dd9 100644 --- a/shex_validation/src/result_map.rs +++ b/shex_validation/src/result_map.rs @@ -1,11 +1,9 @@ use colored::*; use prefixmap::PrefixMap; -use rbe::Pending; use shex_ast::compiled::shape_label::ShapeLabel; use shex_ast::Node; use srdf::Object; use std::collections::hash_map::Entry; -use std::hash::Hash; use std::{ collections::{HashMap, HashSet}, fmt::{Debug, Display, Formatter}, diff --git a/shex_validation/src/rule.rs b/shex_validation/src/rule.rs index ccf20792..88099437 100644 --- a/shex_validation/src/rule.rs +++ b/shex_validation/src/rule.rs @@ -19,6 +19,7 @@ where Rule { head, body } } + /* /// A fact is a rule with an empty body fn fact(a: Atom) -> Rule { Rule { @@ -33,5 +34,5 @@ where self.body.swap_remove(index); } self - } + }*/ } diff --git a/shex_validation/src/validator.rs b/shex_validation/src/validator.rs index 33cebca1..eeb6be57 100644 --- a/shex_validation/src/validator.rs +++ b/shex_validation/src/validator.rs @@ -50,9 +50,9 @@ impl Validator { fn get_shape_expr_label(&mut self, label: &ShapeExprLabel) -> Result { self.schema .find_ref(label) - .map_err(|e| ValidatorError::ShapeLabelNotFoundError { + .map_err(|error| ValidatorError::ShapeLabelNotFoundError { shape_label: label.clone(), - err: e, + err: Box::new(error), }) } @@ -87,7 +87,7 @@ impl Validator { let iri = rdf.resolve_prefix_local(prefix, local)?; Ok(Node::iri(iri.clone())) } - ObjectValue::Literal(lit) => todo!(), + ObjectValue::Literal(_lit) => todo!(), } } @@ -135,7 +135,7 @@ impl Validator { pub fn get_result(&self, node: &Node, shape: &ShapeLabel) -> Result { if let Some(idx) = self.schema.find_shape_label_idx(shape) { - let pos_atom = PosAtom::new((node.clone(), idx.clone())); + let pos_atom = PosAtom::new((node.clone(), *idx)); let atom = Atom::pos(&pos_atom); Ok(self.runner.get_result(&atom)) } else { @@ -152,7 +152,7 @@ impl Validator { fn get_idx(&self, shape: &ShapeLabel) -> Result { match self.schema.find_label(shape) { - Some((idx, _se)) => Ok(idx.clone()), + Some((idx, _se)) => Ok(*idx), None => Err(ValidatorError::NotFoundShapeLabel { shape: (*shape).clone(), }), diff --git a/shex_validation/src/validator_error.rs b/shex_validation/src/validator_error.rs index faf888af..35cddcbe 100644 --- a/shex_validation/src/validator_error.rs +++ b/shex_validation/src/validator_error.rs @@ -23,7 +23,7 @@ pub enum ValidatorError { ConversionObjectIri { object: Object }, #[error(transparent)] - CompiledSchemaError(#[from] CompiledSchemaError), + CompiledSchemaError(#[from] Box), #[error("Failed regular expression")] RbeFailed(), @@ -40,7 +40,7 @@ pub enum ValidatorError { #[error("ShapeLabel not found {shape_label:?}: {err}")] ShapeLabelNotFoundError { shape_label: ShapeExprLabel, - err: CompiledSchemaError, + err: Box, }, #[error("And error: shape expression {shape_expr} failed for node {node}: {errors}")] diff --git a/shex_validation/src/validator_runner.rs b/shex_validation/src/validator_runner.rs index 1543b89c..5f07fa46 100644 --- a/shex_validation/src/validator_runner.rs +++ b/shex_validation/src/validator_runner.rs @@ -1,5 +1,4 @@ use crate::atom; -use crate::rule; use crate::validator_error::*; use crate::Reason; use crate::ResultValue; @@ -16,17 +15,14 @@ use shex_ast::Pred; use shex_ast::ShapeLabelIdx; use srdf::{Object, SRDF}; use std::collections::hash_map::Entry; -use std::{ - collections::HashMap, - fmt::{Display, Formatter}, -}; +use std::collections::HashMap; use tracing::debug; type Result = std::result::Result; type Atom = atom::Atom<(Node, ShapeLabelIdx)>; type NegAtom = atom::NegAtom<(Node, ShapeLabelIdx)>; type PosAtom = atom::PosAtom<(Node, ShapeLabelIdx)>; -type Rule = rule::Rule<(Node, ShapeLabelIdx)>; +// type Rule = rule::Rule<(Node, ShapeLabelIdx)>; type Neighs = (Vec<(Pred, Node)>, Vec); #[derive(Debug)] @@ -34,7 +30,7 @@ pub struct ValidatorRunner { checked: IndexSet, processing: IndexSet, pending: IndexSet, - rules: Vec, + //rules: Vec, alternative_match_iterators: Vec>, // alternatives: Vec>, max_steps: usize, @@ -43,13 +39,19 @@ pub struct ValidatorRunner { errors: HashMap>, } +impl Default for ValidatorRunner { + fn default() -> Self { + Self::new() + } +} + impl ValidatorRunner { pub fn new() -> ValidatorRunner { ValidatorRunner { checked: IndexSet::new(), processing: IndexSet::new(), pending: IndexSet::new(), - rules: Vec::new(), + //rules: Vec::new(), alternative_match_iterators: Vec::new(), max_steps: MAX_STEPS, step_counter: 0, @@ -63,7 +65,7 @@ impl ValidatorRunner { } pub(crate) fn remove_processing(&mut self, atom: &Atom) { - self.processing.remove(atom); + self.processing.swap_remove(atom); } pub(crate) fn add_checked_pos(&mut self, atom: Atom, reasons: Vec) { @@ -73,7 +75,7 @@ impl ValidatorRunner { self.checked.insert(new_atom); self.add_reasons(pa, reasons) } - Atom::Neg(na) => { + Atom::Neg(_na) => { todo!() } } @@ -86,7 +88,7 @@ impl ValidatorRunner { self.checked.insert(new_atom); self.add_errors(na, errors) } - Atom::Pos(na) => { + Atom::Pos(_na) => { todo!() } } @@ -226,7 +228,7 @@ impl ValidatorRunner { } Err(err) => Ok(Either::Left(vec![ValidatorError::RbeError(err)])), }, - ShapeExpr::Ref { idx } => { + ShapeExpr::Ref { .. } => { todo!() } ShapeExpr::ShapeAnd { exprs, .. } => { @@ -248,15 +250,15 @@ impl ValidatorRunner { ShapeExpr::ShapeNot { expr, .. } => { let result = self.check_node_shape_expr(node, expr, rdf)?; match result { - Either::Left(errors) => { + Either::Left(_errors) => { todo!() } - Either::Right(errors) => { + Either::Right(_errors) => { todo!() } } } - ShapeExpr::ShapeOr { exprs, .. } => { + ShapeExpr::ShapeOr { .. } => { todo!() /*for e in exprs { let result = self.check_node_shape_expr(node, e, rdf)?; @@ -399,14 +401,14 @@ impl ValidatorRunner { } } - fn cnv_err(&self, err: S::Err) -> ValidatorError + fn cnv_err(&self, _err: S::Err) -> ValidatorError where S: SRDF, { todo!() } - fn get_rdf_node(&self, node: &Node, rdf: &S) -> S::Term + fn get_rdf_node(&self, node: &Node, _rdf: &S) -> S::Term where S: SRDF, { @@ -415,10 +417,10 @@ impl ValidatorRunner { let i = S::iri_s2iri(iri); S::iri_as_term(i) } - Object::BlankNode(id) => { + Object::BlankNode(_id) => { todo!() } - Object::Literal(lit) => { + Object::Literal(_lit) => { todo!() } } diff --git a/srdf/src/srdf_graph/srdfgraph.rs b/srdf/src/srdf_graph/srdfgraph.rs index bfb277ce..0b87c984 100644 --- a/srdf/src/srdf_graph/srdfgraph.rs +++ b/srdf/src/srdf_graph/srdfgraph.rs @@ -102,7 +102,7 @@ impl SRDFGraph { } pub fn from_path( - path: &PathBuf, + path: &Path, format: &RDFFormat, base: Option>, ) -> Result { diff --git a/sx_cli/src/cli.rs b/sx_cli/src/cli.rs index f2076fe7..f90c7cca 100644 --- a/sx_cli/src/cli.rs +++ b/sx_cli/src/cli.rs @@ -329,9 +329,9 @@ pub enum DataFormat { NQuads, } -impl Into for DataFormat { - fn into(self) -> RDFFormat { - match self { +impl From for RDFFormat { + fn from(val: DataFormat) -> Self { + match val { DataFormat::Turtle => RDFFormat::Turtle, DataFormat::NTriples => RDFFormat::NTriples, DataFormat::RDFXML => RDFFormat::RDFXML, diff --git a/sx_cli/src/main.rs b/sx_cli/src/main.rs index 42ed6971..fa06a8f3 100755 --- a/sx_cli/src/main.rs +++ b/sx_cli/src/main.rs @@ -29,11 +29,10 @@ use srdf::srdf_sparql::SRDFSparql; use srdf::SRDF; use std::fs::File; use std::io::{self, BufWriter, Write}; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::str::FromStr; use std::time::Instant; use tracing::debug; -use tracing_subscriber::fmt::time::Uptime; pub mod cli; pub mod data; @@ -157,7 +156,7 @@ fn main() -> Result<()> { } fn run_schema( - schema_buf: &PathBuf, + schema_path: &Path, schema_format: &ShExFormat, result_schema_format: &ShExFormat, output: &Option, @@ -166,7 +165,7 @@ fn run_schema( ) -> Result<()> { let begin = Instant::now(); let mut writer = get_writer(output)?; - let schema_json = parse_schema(schema_buf, schema_format)?; + let schema_json = parse_schema(schema_path, schema_format)?; match result_schema_format { ShExFormat::Internal => { writeln!(writer, "{schema_json:?}")?; @@ -198,15 +197,16 @@ fn run_schema( Ok(()) } +#[allow(clippy::too_many_arguments)] fn run_validate( - schema_path: &PathBuf, + schema_path: &Path, schema_format: &ShExFormat, data: &Option, data_format: &DataFormat, endpoint: &Option, maybe_node: &Option, maybe_shape: &Option, - shapemap: &Option, + shapemap_path: &Option, shapemap_format: &ShapeMapFormat, max_steps: &usize, debug: u8, @@ -217,7 +217,7 @@ fn run_validate( let mut schema: CompiledSchema = CompiledSchema::new(); schema.from_schema_json(&schema_json)?; let data = get_data(data, data_format, endpoint, debug)?; - let mut shapemap = match shapemap { + let mut shapemap = match shapemap_path { None => QueryShapeMap::new(), Some(shapemap_buf) => parse_shapemap(shapemap_buf, shapemap_format)?, }; @@ -264,13 +264,13 @@ fn run_validate( } fn run_shacl( - shapes_buf: &PathBuf, + shapes_path: &Path, shapes_format: &ShaclFormat, result_shapes_format: &ShaclFormat, output: &Option, ) -> Result<()> { let mut writer = get_writer(output)?; - let shacl_schema = parse_shacl(shapes_buf, shapes_format)?; + let shacl_schema = parse_shacl(shapes_path, shapes_format)?; match result_shapes_format { ShaclFormat::Internal => { writeln!(writer, "{shacl_schema}")?; @@ -287,13 +287,13 @@ fn run_shacl( } fn run_dctap( - input_buf: &PathBuf, + input_path: &Path, format: &DCTapFormat, result_format: &DCTapResultFormat, output: &Option, ) -> Result<()> { let mut writer = get_writer(output)?; - let dctap = parse_dctap(input_buf, format)?; + let dctap = parse_dctap(input_path, format)?; match result_format { DCTapResultFormat::JSON => { let str = serde_json::to_string_pretty(&dctap)?; @@ -360,11 +360,12 @@ fn start() -> ShapeSelector { ShapeSelector::start() } +#[allow(clippy::too_many_arguments)] fn run_node( data: &Option, data_format: &DataFormat, endpoint: &Option, - node_str: &String, + node_str: &str, predicates: &Vec, show_node_mode: &ShowNodeMode, show_hyperlinks: &bool, @@ -379,7 +380,7 @@ fn run_node( node_selector, predicates, &endpoint, - &show_node_mode, + show_node_mode, show_hyperlinks, &mut writer, ), @@ -387,7 +388,7 @@ fn run_node( node_selector, predicates, &data, - &show_node_mode, + show_node_mode, show_hyperlinks, &mut writer, ), @@ -427,10 +428,10 @@ where }; writeln!(writer, "{}", rdf.qualify_subject(&subject))?; for pred in map.keys() { - writeln!(writer, " -{}-> ", rdf.qualify_iri(&pred))?; + writeln!(writer, " -{}-> ", rdf.qualify_iri(pred))?; if let Some(objs) = map.get(pred) { for o in objs { - writeln!(writer, " {}", rdf.qualify_term(&o))?; + writeln!(writer, " {}", rdf.qualify_term(o))?; } } else { bail!("Not found values for {pred} in map") @@ -453,10 +454,10 @@ where }; writeln!(writer, "{}", rdf.qualify_term(&object))?; for pred in map.keys() { - writeln!(writer, " <-{}-", rdf.qualify_iri(&pred))?; + writeln!(writer, " <-{}-", rdf.qualify_iri(pred))?; if let Some(subjs) = map.get(pred) { for s in subjs { - writeln!(writer, " {}", rdf.qualify_subject(&s))?; + writeln!(writer, " {}", rdf.qualify_subject(s))?; } } else { bail!("Not found values for {pred} in map") @@ -491,13 +492,13 @@ where } fn run_shapemap( - shapemap: &PathBuf, + shapemap_path: &Path, shapemap_format: &ShapeMapFormat, result_format: &ShapeMapFormat, output: &Option, ) -> Result<()> { let mut writer = get_writer(output)?; - let shapemap = parse_shapemap(shapemap, shapemap_format)?; + let shapemap = parse_shapemap(shapemap_path, shapemap_format)?; match result_format { ShapeMapFormat::Compact => { let str = ShapemapFormatter::default().format_shapemap(&shapemap); @@ -518,14 +519,11 @@ where match node { ObjectValue::IriRef(iri_ref) => { let iri = match iri_ref { - IriRef::Iri(iri_s) => { - let v = S::iri_s2iri(iri_s); - v - } + IriRef::Iri(iri_s) => S::iri_s2iri(iri_s), IriRef::Prefixed { prefix, local } => { let iri_s = rdf.resolve_prefix_local(prefix, local)?; - let v = S::iri_s2iri(&iri_s); - v + + S::iri_s2iri(&iri_s) } }; let term = S::iri_as_term(iri); @@ -539,7 +537,7 @@ where } fn run_data( - data: &PathBuf, + data: &Path, data_format: &DataFormat, _debug: u8, output: &Option, @@ -550,10 +548,7 @@ fn run_data( Ok(()) } -fn parse_shapemap( - shapemap_path: &PathBuf, - shapemap_format: &ShapeMapFormat, -) -> Result { +fn parse_shapemap(shapemap_path: &Path, shapemap_format: &ShapeMapFormat) -> Result { match shapemap_format { ShapeMapFormat::Internal => Err(anyhow!("Cannot read internal ShapeMap format yet")), ShapeMapFormat::Compact => { @@ -563,7 +558,7 @@ fn parse_shapemap( } } -fn parse_schema(schema_path: &PathBuf, schema_format: &ShExFormat) -> Result { +fn parse_schema(schema_path: &Path, schema_format: &ShExFormat) -> Result { match schema_format { ShExFormat::Internal => Err(anyhow!("Cannot read internal ShEx format yet")), ShExFormat::ShExC => { @@ -585,7 +580,7 @@ fn parse_schema(schema_path: &PathBuf, schema_format: &ShExFormat) -> Result Result { +fn parse_shacl(shapes_path: &Path, shapes_format: &ShaclFormat) -> Result { match shapes_format { ShaclFormat::Internal => Err(anyhow!("Cannot read internal ShEx format yet")), _ => { @@ -597,10 +592,10 @@ fn parse_shacl(shapes_path: &PathBuf, shapes_format: &ShaclFormat) -> Result Result { +fn parse_dctap(input_path: &Path, format: &DCTapFormat) -> Result { match format { DCTapFormat::CSV => { - let dctap = DCTap::read_buf(input_buf, TapConfig::default())?; + let dctap = DCTap::read_buf(input_path, TapConfig::default())?; Ok(dctap) } } @@ -618,7 +613,7 @@ fn shacl_format_to_data_format(shacl_format: &ShaclFormat) -> Result } } -fn parse_data(data: &PathBuf, data_format: &DataFormat) -> Result { +fn parse_data(data: &Path, data_format: &DataFormat) -> Result { match data_format { DataFormat::Turtle => { let rdf_format = (*data_format).into();