Module error

Module error 

Source
Expand description

Error types for mathlex parsing operations.

This module defines comprehensive error types for reporting parsing failures, including precise location information and helpful error messages.

§Error Architecture

  • Position: A point in source text (line, column, offset)
  • Span: A range in source text (start and end positions)
  • ParseErrorKind: The specific type of parsing error
  • ParseError: Complete error with kind, location, and context
  • ParseResult<T>: Standard Result type for parsing operations

§Example

use mathlex::error::{Position, Span, ParseError, ParseErrorKind};

let pos = Position::new(1, 5, 5);
let error = ParseError::new(
    ParseErrorKind::UnexpectedEof {
        expected: vec!["number".to_string()],
    },
    Some(Span::new(pos, pos)),
);

assert_eq!(error.to_string(), "unexpected end of input, expected number at 1:5");

Structs§

ErrorBuilder
Builder for constructing parse errors ergonomically.
ParseError
A parsing error with location and context information.
Position
A position in the source text.
Span
A span representing a range in the source text.

Enums§

ParseErrorKind
The kind of parsing error that occurred.

Type Aliases§

ParseResult
Result type for parsing operations.