use crate::symbol_table::LocalSymbolTable;
#[derive(Debug, Clone)]
pub struct LexerConfig {
pub parse_interpolation: bool,
pub track_positions: bool,
pub max_lookahead: usize,
pub symbol_table: Option<LocalSymbolTable>,
}
impl Default for LexerConfig {
fn default() -> Self {
Self {
parse_interpolation: true,
track_positions: true,
max_lookahead: 1024,
symbol_table: None,
}
}
}
#[cfg(test)]
mod tests {
use super::LexerConfig;
#[test]
fn default_enables_interpolation_and_position_tracking() {
let config = LexerConfig::default();
assert!(config.parse_interpolation);
assert!(config.track_positions);
}
#[test]
fn default_uses_expected_lookahead_limit() {
let config = LexerConfig::default();
assert_eq!(config.max_lookahead, 1024);
}
#[test]
fn default_symbol_table_is_none() {
let config = LexerConfig::default();
assert!(config.symbol_table.is_none());
}
#[test]
fn clone_preserves_field_values() {
let config = LexerConfig {
parse_interpolation: false,
track_positions: false,
max_lookahead: 256,
symbol_table: None,
};
let cloned = config.clone();
assert!(!cloned.parse_interpolation);
assert!(!cloned.track_positions);
assert_eq!(cloned.max_lookahead, 256);
assert!(cloned.symbol_table.is_none());
}
}