| Crates.io | sipha-error |
| lib.rs | sipha-error |
| version | 0.3.1 |
| created_at | 2025-11-19 17:47:44.388872+00 |
| updated_at | 2025-11-22 10:29:32.802821+00 |
| description | Error handling and diagnostics for sipha parsers |
| homepage | |
| repository | https://github.com/NyalephTheCat/sipha |
| max_upload_size | |
| id | 1940488 |
| size | 57,264 |
Error handling and diagnostics for sipha parsers.
sipha-error provides comprehensive error handling and diagnostic capabilities for sipha parsers:
default: Includes diagnostics featurediagnostics: Enables rich error diagnostics with miette integrationcolor: Adds color support for error output (requires diagnostics)Add sipha-error to your Cargo.toml:
[dependencies]
sipha-error = "0.1.1"
With diagnostics:
[dependencies]
sipha-error = { version = "0.1.1", features = ["diagnostics", "color"] }
use sipha_error::{ParseError, Expected};
use sipha_core::{span::Span, traits::TokenKind};
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
enum Token { Ident, Plus }
impl TokenKind for Token { fn is_trivia(&self) -> bool { false } }
let error = ParseError::Expected {
expected: Expected::Single(Token::Ident),
found: Some(Token::Plus),
span: Span::new(0, 1),
rule_context: None,
context_stack: vec![],
};
#[cfg(feature = "diagnostics")]
{
use sipha_error::Diagnostic;
let diagnostic = Diagnostic::from_parse_error(&error);
println!("{}", diagnostic.format_with_source("+ 5"));
}
This project is licensed under the MIT License - see the LICENSE file for details.