Skip to main content

lex_core/lex/parsing/
common.rs

1//! Common parser module
2//!
3//! This module contains shared interfaces for parser implementations.
4
5use std::fmt;
6
7use crate::lex::lexing::Token;
8/// Input type for parsers
9pub type ParserInput = Vec<(Token, std::ops::Range<usize>)>;
10
11/// Errors that can occur during parsing
12#[derive(Debug, Clone)]
13pub enum ParseError {
14    /// Generic error message
15    Error(String),
16}
17
18impl fmt::Display for ParseError {
19    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20        match self {
21            ParseError::Error(msg) => write!(f, "Parse error: {msg}"),
22        }
23    }
24}
25
26impl std::error::Error for ParseError {}