ebnf_parser/error.rs
1use std::borrow::Cow;
2
3use thiserror::Error;
4
5use crate::span::Span;
6
7#[derive(Debug, Clone, Error)]
8#[error("invalid syntax at {span}: {message}")]
9pub struct SyntaxError {
10 pub span: Span,
11 pub message: String,
12}
13
14impl SyntaxError {
15 pub(crate) fn new(span: Span, message: Cow<str>) -> Self {
16 Self {
17 span,
18 message: message.into_owned(),
19 }
20 }
21}