glyph_parser/
lib.rs

1//! Glyph Parser
2//!
3//! A Python-like parser optimized for LLM generation with excellent error recovery.
4
5use thiserror::Error;
6
7pub mod ast;
8pub mod indent_tracker;
9pub mod lexer;
10pub mod parser;
11
12pub use ast::*;
13pub use parser::{parse_glyph, Parser};
14
15#[derive(Debug, Error)]
16pub enum ParseError {
17    #[error("Unexpected token: {0}")]
18    UnexpectedToken(String),
19
20    #[error("Invalid indentation at line {line}: expected {expected} spaces, found {found}")]
21    IndentationError {
22        line: usize,
23        expected: usize,
24        found: usize,
25    },
26
27    #[error("Missing required field '{field}' in @program decorator")]
28    MissingProgramField { field: String },
29
30    #[error("Syntax error at line {line}: {message}")]
31    SyntaxError { line: usize, message: String },
32
33    #[error("Type annotation error: {0}")]
34    TypeError(String),
35}
36
37pub type ParseResult<T> = Result<T, ParseError>;