From f898f3c3a17a7c71236cafff34f507b10d71f835 Mon Sep 17 00:00:00 2001 From: Tolmachev Igor Date: Sat, 9 May 2026 14:35:06 +0300 Subject: Replace todo!() in parser with errors --- compiler/src/ast/error.rs | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'compiler/src/ast/error.rs') diff --git a/compiler/src/ast/error.rs b/compiler/src/ast/error.rs index 11f552d..ced2231 100644 --- a/compiler/src/ast/error.rs +++ b/compiler/src/ast/error.rs @@ -1,7 +1,37 @@ -use std::{error, fmt}; +use std::{ + error, fmt, + num::{ParseFloatError, ParseIntError}, + rc::Rc, +}; #[derive(Debug)] -pub enum Error {} +pub enum Error { + // Number + InvalidFloatLiteral(ParseFloatError), + InvalidIntegerLiteral(ParseIntError), + + // String + UnclosedString(Rc), + UnexpectedEscapeChar(char), + + // Par + UnexpectedRightPar, + UnclosedLeftPar, + + UnexpectedEof, +} + +impl From for Error { + fn from(value: ParseFloatError) -> Self { + Self::InvalidFloatLiteral(value) + } +} + +impl From for Error { + fn from(value: ParseIntError) -> Self { + Self::InvalidIntegerLiteral(value) + } +} impl fmt::Display for Error { fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { -- cgit v1.3