From 83ab8c67beecfc05684c9400e29f7d77225d3af9 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 7 Jun 2026 16:37:28 -0700 Subject: Cleaned up a lot of parsing code. --- src/lexer.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/lexer.rs') diff --git a/src/lexer.rs b/src/lexer.rs index 04be350..902bb64 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -1,15 +1,16 @@ use std::iter::Iterator; //use core::error::Error; use std::str::CharIndices; +use std::fmt; use crate::Position; -#[derive(Debug,Copy,Clone)] +#[derive(Debug,Copy,Clone,PartialEq)] pub enum ErrorType { UnexpectedChar(char), } -#[derive(Debug,Copy,Clone)] +#[derive(Debug,Copy,Clone,PartialEq)] pub enum SymbolType<'a> { StartFlat, StartPoint, @@ -26,13 +27,19 @@ pub enum SymbolType<'a> { EOS, } -#[derive(Debug,Copy,Clone)] +#[derive(Copy,Clone)] pub struct Symbol<'a> { symbol: SymbolType<'a>, start: Position, end: Position, } +impl<'a> fmt::Debug for Symbol<'a> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?} @ {}:{}", self.symbol, self.start.line, self.start.column ) + } +} + impl<'a> Symbol<'a> { pub fn new( symbol: SymbolType<'a>, start: Position, end: Position ) -> Self { Self { -- cgit v1.2.3