diff --git a/src/parser/ast_node/ast_node.rs b/src/parser/ast_node/ast_node.rs index 4a585ce..4e2a2e4 100644 --- a/src/parser/ast_node/ast_node.rs +++ b/src/parser/ast_node/ast_node.rs @@ -1,47 +1,47 @@ // #[derive(Debug)] -use super::ast_node_concat::ASTNodeConcat; -use super::ast_node_group::ASTNodeGroup; -use super::ast_node_literal::ASTNodeLiteral; -use super::ast_node_optional::ASTNodeOptional; -use super::ast_node_plus::ASTNodePlus; -use super::ast_node_star::ASTNodeStar; -use super::ast_node_union::ASTNodeUnion; +use super::ast_node_concat::AstNodeConcat; +use super::ast_node_group::AstNodeGroup; +use super::ast_node_literal::AstNodeLiteral; +use super::ast_node_optional::AstNodeOptional; +use super::ast_node_plus::AstNodePlus; +use super::ast_node_star::AstNodeStar; +use super::ast_node_union::AstNodeUnion; -pub(crate) enum ASTNode { - Literal(ASTNodeLiteral), // Single character literal - Concat(ASTNodeConcat), // Concatenation of two expressions - Union(ASTNodeUnion), // Union of two expressions - Star(ASTNodeStar), // Kleene Star (zero or more) - Plus(ASTNodePlus), // One or more - Optional(ASTNodeOptional), // Zero or one (optional) - Group(ASTNodeGroup), // Capturing group +pub(crate) enum AstNode { + Literal(AstNodeLiteral), // Single character literal + Concat(AstNodeConcat), // Concatenation of two expressions + Union(AstNodeUnion), // Union of two expressions + Star(AstNodeStar), // Kleene Star (zero or more) + Plus(AstNodePlus), // One or more + Optional(AstNodeOptional), // Zero or one (optional) + Group(AstNodeGroup), // Capturing group } -impl PartialEq for ASTNode { +impl PartialEq for AstNode { fn eq(&self, other: &Self) -> bool { match (self, other) { - (ASTNode::Literal(l1), ASTNode::Literal(l2)) => l1 == l2, - (ASTNode::Concat(c1), ASTNode::Concat(c2)) => c1 == c2, - (ASTNode::Union(u1), ASTNode::Union(u2)) => u1 == u2, - (ASTNode::Star(s1), ASTNode::Star(s2)) => s1 == s2, - (ASTNode::Plus(p1), ASTNode::Plus(p2)) => p1 == p2, - (ASTNode::Optional(o1), ASTNode::Optional(o2)) => o1 == o2, - (ASTNode::Group(g1), ASTNode::Group(g2)) => g1 == g2, + (AstNode::Literal(l1), AstNode::Literal(l2)) => l1 == l2, + (AstNode::Concat(c1), AstNode::Concat(c2)) => c1 == c2, + (AstNode::Union(u1), AstNode::Union(u2)) => u1 == u2, + (AstNode::Star(s1), AstNode::Star(s2)) => s1 == s2, + (AstNode::Plus(p1), AstNode::Plus(p2)) => p1 == p2, + (AstNode::Optional(o1), AstNode::Optional(o2)) => o1 == o2, + (AstNode::Group(g1), AstNode::Group(g2)) => g1 == g2, _ => false, } } } -impl std::fmt::Debug for ASTNode { +impl std::fmt::Debug for AstNode { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - ASTNode::Literal(l) => write!(f, "Literal({:?})", l), - ASTNode::Concat(c) => write!(f, "Concat({:?})", c), - ASTNode::Union(u) => write!(f, "Union({:?})", u), - ASTNode::Star(s) => write!(f, "Star({:?})", s), - ASTNode::Plus(p) => write!(f, "Plus({:?})", p), - ASTNode::Optional(o) => write!(f, "Optional({:?})", o), - ASTNode::Group(g) => write!(f, "Group({:?})", g), + AstNode::Literal(l) => write!(f, "Literal({:?})", l), + AstNode::Concat(c) => write!(f, "Concat({:?})", c), + AstNode::Union(u) => write!(f, "Union({:?})", u), + AstNode::Star(s) => write!(f, "Star({:?})", s), + AstNode::Plus(p) => write!(f, "Plus({:?})", p), + AstNode::Optional(o) => write!(f, "Optional({:?})", o), + AstNode::Group(g) => write!(f, "Group({:?})", g), } } } diff --git a/src/parser/ast_node/ast_node_concat.rs b/src/parser/ast_node/ast_node_concat.rs index 034d160..b247755 100644 --- a/src/parser/ast_node/ast_node_concat.rs +++ b/src/parser/ast_node/ast_node_concat.rs @@ -1,12 +1,12 @@ -use crate::parser::ast_node::ast_node::ASTNode; +use crate::parser::ast_node::ast_node::AstNode; #[derive(Debug)] -pub(crate) struct ASTNodeConcat { - m_op1: Box, - m_op2: Box, +pub(crate) struct AstNodeConcat { + m_op1: Box, + m_op2: Box, } -impl PartialEq for ASTNodeConcat { +impl PartialEq for AstNodeConcat { fn eq(&self, other: &Self) -> bool { self.m_op1 == other.m_op1 && self.m_op2 == other.m_op2 } diff --git a/src/parser/ast_node/ast_node_group.rs b/src/parser/ast_node/ast_node_group.rs index 7da6798..8c2ee95 100644 --- a/src/parser/ast_node/ast_node_group.rs +++ b/src/parser/ast_node/ast_node_group.rs @@ -1,11 +1,11 @@ -use crate::parser::ast_node::ast_node::ASTNode; +use crate::parser::ast_node::ast_node::AstNode; #[derive(Debug)] -pub(crate) struct ASTNodeGroup { - m_op1: Box, +pub(crate) struct AstNodeGroup { + m_op1: Box, } -impl PartialEq for ASTNodeGroup { +impl PartialEq for AstNodeGroup { fn eq(&self, other: &Self) -> bool { self.m_op1 == other.m_op1 } diff --git a/src/parser/ast_node/ast_node_literal.rs b/src/parser/ast_node/ast_node_literal.rs index cc05a6f..ffbdbc2 100644 --- a/src/parser/ast_node/ast_node_literal.rs +++ b/src/parser/ast_node/ast_node_literal.rs @@ -1,9 +1,9 @@ #[derive(Debug)] -pub(crate) struct ASTNodeLiteral { +pub(crate) struct AstNodeLiteral { m_value: char, } -impl PartialEq for ASTNodeLiteral { +impl PartialEq for AstNodeLiteral { fn eq(&self, other: &Self) -> bool { self.m_value == other.m_value } diff --git a/src/parser/ast_node/ast_node_optional.rs b/src/parser/ast_node/ast_node_optional.rs index a283423..f73a7d7 100644 --- a/src/parser/ast_node/ast_node_optional.rs +++ b/src/parser/ast_node/ast_node_optional.rs @@ -1,11 +1,11 @@ -use crate::parser::ast_node::ast_node::ASTNode; +use crate::parser::ast_node::ast_node::AstNode; #[derive(Debug)] -pub(crate) struct ASTNodeOptional { - m_op1: Box, +pub(crate) struct AstNodeOptional { + m_op1: Box, } -impl PartialEq for ASTNodeOptional { +impl PartialEq for AstNodeOptional { fn eq(&self, other: &Self) -> bool { self.m_op1 == other.m_op1 } diff --git a/src/parser/ast_node/ast_node_plus.rs b/src/parser/ast_node/ast_node_plus.rs index d7b62ab..fcc97cb 100644 --- a/src/parser/ast_node/ast_node_plus.rs +++ b/src/parser/ast_node/ast_node_plus.rs @@ -1,11 +1,11 @@ -use crate::parser::ast_node::ast_node::ASTNode; +use crate::parser::ast_node::ast_node::AstNode; #[derive(Debug)] -pub(crate) struct ASTNodePlus { - m_op1: Box, +pub(crate) struct AstNodePlus { + m_op1: Box, } -impl PartialEq for ASTNodePlus { +impl PartialEq for AstNodePlus { fn eq(&self, other: &Self) -> bool { self.m_op1 == other.m_op1 } diff --git a/src/parser/ast_node/ast_node_star.rs b/src/parser/ast_node/ast_node_star.rs index 4b00590..3a29618 100644 --- a/src/parser/ast_node/ast_node_star.rs +++ b/src/parser/ast_node/ast_node_star.rs @@ -1,11 +1,11 @@ -use crate::parser::ast_node::ast_node::ASTNode; +use crate::parser::ast_node::ast_node::AstNode; #[derive(Debug)] -pub(crate) struct ASTNodeStar { - m_op1: Box, +pub(crate) struct AstNodeStar { + m_op1: Box, } -impl PartialEq for ASTNodeStar { +impl PartialEq for AstNodeStar { fn eq(&self, other: &Self) -> bool { self.m_op1 == other.m_op1 } diff --git a/src/parser/ast_node/ast_node_union.rs b/src/parser/ast_node/ast_node_union.rs index 8f39f2b..4e1b9b3 100644 --- a/src/parser/ast_node/ast_node_union.rs +++ b/src/parser/ast_node/ast_node_union.rs @@ -1,12 +1,12 @@ -use crate::parser::ast_node::ast_node::ASTNode; +use crate::parser::ast_node::ast_node::AstNode; #[derive(Debug)] -pub(crate) struct ASTNodeUnion { - m_op1: Box, - m_op2: Box, +pub(crate) struct AstNodeUnion { + m_op1: Box, + m_op2: Box, } -impl PartialEq for ASTNodeUnion { +impl PartialEq for AstNodeUnion { fn eq(&self, other: &Self) -> bool { self.m_op1 == other.m_op1 && self.m_op2 == other.m_op2 } diff --git a/src/parser/parser.rs b/src/parser/parser.rs index bc43f16..edcf039 100644 --- a/src/parser/parser.rs +++ b/src/parser/parser.rs @@ -1,4 +1,4 @@ -use super::ast_node::ast_node::ASTNode; +use super::ast_node::ast_node::AstNode; use super::token::Token; pub struct ParserStream { @@ -30,7 +30,7 @@ impl ParserStream { } impl ParserStream { - fn parse_regex(&mut self) -> Option { + fn parse_regex(&mut self) -> Option { None } }