shex_compact/
lib.rs

1//! ShEx compact syntax parser
2//!
3//! Example
4//!
5//! ```
6//! # use iri_s::IriS;
7//!
8//! use shex_ast::{Schema, Shape, ShapeExpr, ShapeExprLabel};
9//! use shex_compact::ShExParser;
10//!
11//! let str = r#"prefix : <http://example.org/>
12//!              :S {}
13//!             "#;
14//!
15//! let schema = ShExParser::parse(str, None).unwrap();
16//! let mut expected = Schema::new();
17//! expected.add_prefix("", &IriS::new_unchecked("http://example.org/"));
18//! expected.add_shape(
19//!   ShapeExprLabel::iri_unchecked("http://example.org/S"),
20//!   ShapeExpr::empty_shape(),
21//!   false
22//! );
23//! assert_eq!(schema,expected)
24//!
25//! ```
26mod compact_printer;
27mod grammar;
28mod grammar_structs;
29mod located_parse_error;
30pub mod shapemap_compact_printer;
31mod shapemap_grammar;
32pub mod shapemap_parser;
33pub mod shex_compact_printer;
34mod shex_grammar;
35pub mod shex_parser;
36pub mod shex_parser_error;
37
38use nom::IResult;
39use nom_locate::LocatedSpan;
40
41pub(crate) use crate::compact_printer::*;
42pub(crate) use crate::grammar::*;
43pub use crate::located_parse_error::*;
44pub use crate::shapemap_compact_printer::*;
45pub use crate::shapemap_parser::*;
46pub use crate::shex_compact_printer::*;
47pub use crate::shex_grammar::*;
48pub use crate::shex_parser::*;
49pub use crate::shex_parser_error::*;
50
51// type Result<A> = std::result::Result<A, ParseError>;
52
53// Some definitions were inspired from [Nemo](https://github.com/knowsys/nemo/blob/main/nemo/src/io/parser/types.rs)
54
55pub(crate) type IRes<'a, T> = IResult<Span<'a>, T, LocatedParseError>;
56
57/// A [`LocatedSpan`] over the input.
58pub(crate) type Span<'a> = LocatedSpan<&'a str>;