aimx/literals/
mod.rs

1//! Literal parsing modules for the AIM expression grammar.
2//!
3//! This module provides parsers for all literal value types in the AIM expression language,
4//! including numbers, dates, and text. Each sub-module handles a specific type of literal
5//! with its own parsing rules and format requirements.
6//!
7//! Literal values are the fundamental building blocks of AIM expressions. They represent
8//! concrete values that don't require evaluation and serve as the basis for type promotion
9//! and conversion operations throughout the expression evaluation system.
10//!
11//! # Literal Types
12//!
13//! - **Numbers** - Integers, floating-point numbers, and scientific notation via [`number`]
14//! - **Dates** - ISO 8601 date and datetime formats via [`date`]
15//! - **Text** - Quoted strings and tagged content via [`text`]
16//!
17//! # Usage
18//!
19//! The primary entry points are the individual parse functions exported from each submodule:
20//!
21//! ```rust
22//! use aimx::literals::{parse_number, parse_date, parse_text};
23//!
24//! // Parse a number
25//! let (_, num) = parse_number("42.5").unwrap();
26//! assert_eq!(num, 42.5);
27//!
28//! // Parse a date
29//! let (_, date) = parse_date("2023-01-15").unwrap();
30//! // Date handling uses jiff::civil::DateTime
31//!
32//! // Parse text
33//! let (_, text) = parse_text("\"hello world\"").unwrap();
34//! assert_eq!(text, "hello world");
35//! ```
36//!
37//! These parsers are used internally by the main literal parser [`crate::literal::parse_literal`]
38//! but can also be used directly when specific literal types need to be parsed.
39//!
40//! # Integration with AIMX
41//!
42//! Literal parsing is part of the broader expression parsing system. Most users will interact
43//! with the main parser [`crate::aimx_parse`] which automatically handles literal parsing:
44//!
45//! ```rust
46//! use aimx::{aimx_parse, ExpressionLike, Context};
47//!
48//! let expression = aimx_parse("42 + 10.5");
49//! let mut context = Context::new();
50//! let result = expression.evaluate(&mut context).unwrap();
51//! assert_eq!(result.to_string(), "52.5");
52//! ```
53//!
54//! # Related Modules
55//!
56//! - [`crate::literal`] - Main literal representation and parsing interface
57//! - [`crate::expression`] - Top-level expression parsing and evaluation
58
59pub mod date;
60pub mod number;
61pub mod text;
62
63pub use date::parse_date;
64pub use number::{parse_number, parse_unsigned};
65pub use text::{parse_block, parse_tag, parse_text};