diff --git a/src/lib.rs b/src/lib.rs index 6e1170d..22d1b62 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![recursion_limit = "128"] +#![recursion_limit = "256"] pub mod ast; pub mod parser; diff --git a/src/parser/behavioral_statements/assertion_statements.rs b/src/parser/behavioral_statements/assertion_statements.rs index ae80029..f176b46 100644 --- a/src/parser/behavioral_statements/assertion_statements.rs +++ b/src/parser/behavioral_statements/assertion_statements.rs @@ -9,8 +9,8 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum AssertionItem { - Concurrent(ConcurrentAssertionItem), - Immediate(DeferredImmediateAssetionItem), + Concurrent(Box), + Immediate(Box), } #[derive(Clone, Debug, Node)] @@ -23,22 +23,22 @@ pub struct DeferredImmediateAssetionItem { #[derive(Clone, Debug, Node)] pub enum ProceduralAssertionStatement { - Concurrent(ConcurrentAssertionStatement), - Immediate(ImmediateAssetionStatement), - Checker(CheckerInstantiation), + Concurrent(Box), + Immediate(Box), + Checker(Box), } #[derive(Clone, Debug, Node)] pub enum ImmediateAssetionStatement { - Simple(SimpleImmediateAssertionStatement), - Deferred(DeferredImmediateAssertionStatement), + Simple(Box), + Deferred(Box), } #[derive(Clone, Debug, Node)] pub enum SimpleImmediateAssertionStatement { - Assert(SimpleImmediateAssertStatement), - Assume(SimpleImmediateAssumeStatement), - Cover(SimpleImmediateCoverStatement), + Assert(Box), + Assume(Box), + Cover(Box), } #[derive(Clone, Debug, Node)] @@ -58,9 +58,9 @@ pub struct SimpleImmediateCoverStatement { #[derive(Clone, Debug, Node)] pub enum DeferredImmediateAssertionStatement { - Assert(DeferredImmediateAssertStatement), - Assume(DeferredImmediateAssumeStatement), - Cover(DeferredImmediateCoverStatement), + Assert(Box), + Assume(Box), + Cover(Box), } #[derive(Clone, Debug, Node)] @@ -80,8 +80,8 @@ pub struct DeferredImmediateCoverStatement { #[derive(Clone, Debug, Node)] pub enum AssertTiming { - Zero(Symbol), - Final(Keyword), + Zero(Box), + Final(Box), } // ----------------------------------------------------------------------------- @@ -89,9 +89,11 @@ pub enum AssertTiming { #[parser] pub fn assertion_item(s: Span) -> IResult { alt(( - map(concurrent_assertion_item, |x| AssertionItem::Concurrent(x)), + map(concurrent_assertion_item, |x| { + AssertionItem::Concurrent(Box::new(x)) + }), map(deferred_immediate_assertion_item, |x| { - AssertionItem::Immediate(x) + AssertionItem::Immediate(Box::new(x)) }), ))(s) } @@ -107,13 +109,13 @@ pub fn deferred_immediate_assertion_item(s: Span) -> IResult IResult { alt(( map(concurrent_assertion_statement, |x| { - ProceduralAssertionStatement::Concurrent(x) + ProceduralAssertionStatement::Concurrent(Box::new(x)) }), map(immediate_assertion_statement, |x| { - ProceduralAssertionStatement::Immediate(x) + ProceduralAssertionStatement::Immediate(Box::new(x)) }), map(checker_instantiation, |x| { - ProceduralAssertionStatement::Checker(x) + ProceduralAssertionStatement::Checker(Box::new(x)) }), ))(s) } @@ -122,10 +124,10 @@ pub fn procedural_assertion_statement(s: Span) -> IResult IResult { alt(( map(simple_immediate_assertion_statement, |x| { - ImmediateAssetionStatement::Simple(x) + ImmediateAssetionStatement::Simple(Box::new(x)) }), map(deferred_immediate_assertion_statement, |x| { - ImmediateAssetionStatement::Deferred(x) + ImmediateAssetionStatement::Deferred(Box::new(x)) }), ))(s) } @@ -136,13 +138,13 @@ pub fn simple_immediate_assertion_statement( ) -> IResult { alt(( map(simple_immediate_assert_statement, |x| { - SimpleImmediateAssertionStatement::Assert(x) + SimpleImmediateAssertionStatement::Assert(Box::new(x)) }), map(simple_immediate_assume_statement, |x| { - SimpleImmediateAssertionStatement::Assume(x) + SimpleImmediateAssertionStatement::Assume(Box::new(x)) }), map(simple_immediate_cover_statement, |x| { - SimpleImmediateAssertionStatement::Cover(x) + SimpleImmediateAssertionStatement::Cover(Box::new(x)) }), ))(s) } @@ -177,13 +179,13 @@ pub fn deferred_immediate_assertion_statement( ) -> IResult { alt(( map(deferred_immediate_assert_statement, |x| { - DeferredImmediateAssertionStatement::Assert(x) + DeferredImmediateAssertionStatement::Assert(Box::new(x)) }), map(deferred_immediate_assume_statement, |x| { - DeferredImmediateAssertionStatement::Assume(x) + DeferredImmediateAssertionStatement::Assume(Box::new(x)) }), map(deferred_immediate_cover_statement, |x| { - DeferredImmediateAssertionStatement::Cover(x) + DeferredImmediateAssertionStatement::Cover(Box::new(x)) }), ))(s) } @@ -239,8 +241,8 @@ pub fn deferred_immediate_cover_statement( #[parser] pub fn assert_timing(s: Span) -> IResult { alt(( - map(symbol("#0"), |x| AssertTiming::Zero(x)), - map(keyword("final"), |x| AssertTiming::Final(x)), + map(symbol("#0"), |x| AssertTiming::Zero(Box::new(x))), + map(keyword("final"), |x| AssertTiming::Final(Box::new(x))), ))(s) } diff --git a/src/parser/behavioral_statements/case_statements.rs b/src/parser/behavioral_statements/case_statements.rs index 8e38265..12a1719 100644 --- a/src/parser/behavioral_statements/case_statements.rs +++ b/src/parser/behavioral_statements/case_statements.rs @@ -10,9 +10,9 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum CaseStatement { - Normal(CaseStatementNormal), - Matches(CaseStatementMatches), - Inside(CaseStatementInside), + Normal(Box), + Matches(Box), + Inside(Box), } #[derive(Clone, Debug, Node)] @@ -55,9 +55,9 @@ pub struct CaseStatementInside { #[derive(Clone, Debug, Node)] pub enum CaseKeyword { - Case(Keyword), - Casez(Keyword), - Casex(Keyword), + Case(Box), + Casez(Box), + Casex(Box), } #[derive(Clone, Debug, Node)] @@ -67,8 +67,8 @@ pub struct CaseExpression { #[derive(Clone, Debug, Node)] pub enum CaseItem { - NonDefault(CaseItemNondefault), - Default(CaseItemDefault), + NonDefault(Box), + Default(Box), } #[derive(Clone, Debug, Node)] @@ -83,8 +83,8 @@ pub struct CaseItemDefault { #[derive(Clone, Debug, Node)] pub enum CasePatternItem { - NonDefault(CasePatternItemNondefault), - Default(CaseItemDefault), + NonDefault(Box), + Default(Box), } #[derive(Clone, Debug, Node)] @@ -99,8 +99,8 @@ pub struct CasePatternItemNondefault { #[derive(Clone, Debug, Node)] pub enum CaseInsideItem { - NonDefault(CaseInsideItemNondefault), - Default(CaseItemDefault), + NonDefault(Box), + Default(Box), } #[derive(Clone, Debug, Node)] @@ -154,9 +154,9 @@ pub fn case_statement_normal(s: Span) -> IResult { let (s, f) = keyword("endcase")(s)?; Ok(( s, - CaseStatement::Normal(CaseStatementNormal { + CaseStatement::Normal(Box::new(CaseStatementNormal { nodes: (a, b, c, d, e, f), - }), + })), )) } @@ -171,9 +171,9 @@ pub fn case_statement_matches(s: Span) -> IResult { let (s, g) = keyword("endcase")(s)?; Ok(( s, - CaseStatement::Matches(CaseStatementMatches { + CaseStatement::Matches(Box::new(CaseStatementMatches { nodes: (a, b, c, d, e, f, g), - }), + })), )) } @@ -188,18 +188,18 @@ pub fn case_statement_inside(s: Span) -> IResult { let (s, g) = keyword("endcase")(s)?; Ok(( s, - CaseStatement::Inside(CaseStatementInside { + CaseStatement::Inside(Box::new(CaseStatementInside { nodes: (a, b, c, d, e, f, g), - }), + })), )) } #[parser] pub fn case_keyword(s: Span) -> IResult { alt(( - map(keyword("casez"), |x| CaseKeyword::Casez(x)), - map(keyword("casex"), |x| CaseKeyword::Casex(x)), - map(keyword("case"), |x| CaseKeyword::Case(x)), + map(keyword("casez"), |x| CaseKeyword::Casez(Box::new(x))), + map(keyword("casex"), |x| CaseKeyword::Casex(Box::new(x))), + map(keyword("case"), |x| CaseKeyword::Case(Box::new(x))), ))(s) } @@ -213,7 +213,7 @@ pub fn case_expression(s: Span) -> IResult { pub fn case_item(s: Span) -> IResult { alt(( case_item_nondefault, - map(case_item_default, |x| CaseItem::Default(x)), + map(case_item_default, |x| CaseItem::Default(Box::new(x))), ))(s) } @@ -224,7 +224,7 @@ pub fn case_item_nondefault(s: Span) -> IResult { let (s, c) = statement_or_null(s)?; Ok(( s, - CaseItem::NonDefault(CaseItemNondefault { nodes: (a, b, c) }), + CaseItem::NonDefault(Box::new(CaseItemNondefault { nodes: (a, b, c) })), )) } @@ -240,7 +240,7 @@ pub fn case_item_default(s: Span) -> IResult { pub fn case_pattern_item(s: Span) -> IResult { alt(( case_pattern_item_nondefault, - map(case_item_default, |x| CasePatternItem::Default(x)), + map(case_item_default, |x| CasePatternItem::Default(Box::new(x))), ))(s) } @@ -252,9 +252,9 @@ pub fn case_pattern_item_nondefault(s: Span) -> IResult { let (s, d) = statement_or_null(s)?; Ok(( s, - CasePatternItem::NonDefault(CasePatternItemNondefault { + CasePatternItem::NonDefault(Box::new(CasePatternItemNondefault { nodes: (a, b, c, d), - }), + })), )) } @@ -262,7 +262,7 @@ pub fn case_pattern_item_nondefault(s: Span) -> IResult { pub fn case_inside_item(s: Span) -> IResult { alt(( case_inside_item_nondefault, - map(case_item_default, |x| CaseInsideItem::Default(x)), + map(case_item_default, |x| CaseInsideItem::Default(Box::new(x))), ))(s) } @@ -273,7 +273,7 @@ pub fn case_inside_item_nondefault(s: Span) -> IResult { let (s, c) = statement_or_null(s)?; Ok(( s, - CaseInsideItem::NonDefault(CaseInsideItemNondefault { nodes: (a, b, c) }), + CaseInsideItem::NonDefault(Box::new(CaseInsideItemNondefault { nodes: (a, b, c) })), )) } diff --git a/src/parser/behavioral_statements/clocking_block.rs b/src/parser/behavioral_statements/clocking_block.rs index 198e6fd..fc5e999 100644 --- a/src/parser/behavioral_statements/clocking_block.rs +++ b/src/parser/behavioral_statements/clocking_block.rs @@ -10,8 +10,8 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum ClockingDeclaration { - Local(ClockingDeclarationLocal), - Global(ClockingDeclarationGlobal), + Local(Box), + Global(Box), } #[derive(Clone, Debug, Node)] @@ -48,8 +48,8 @@ pub struct ClockingDeclarationGlobal { #[derive(Clone, Debug, Node)] pub enum ClockingEvent { - Identifier(ClockingEventIdentifier), - Expression(ClockingEventExpression), + Identifier(Box), + Expression(Box), } #[derive(Clone, Debug, Node)] @@ -64,9 +64,9 @@ pub struct ClockingEventExpression { #[derive(Clone, Debug, Node)] pub enum ClockingItem { - Default(ClockingItemDefault), - Direction(ClockingItemDirection), - Assertion(ClockingItemAssertion), + Default(Box), + Direction(Box), + Assertion(Box), } #[derive(Clone, Debug, Node)] @@ -86,9 +86,9 @@ pub struct ClockingItemAssertion { #[derive(Clone, Debug, Node)] pub enum DefaultSkew { - Input(DefaultSkewInput), - Output(DefaultSkewOutput), - InputOutput(DefaultSkewInputOutput), + Input(Box), + Output(Box), + InputOutput(Box), } #[derive(Clone, Debug, Node)] @@ -108,10 +108,10 @@ pub struct DefaultSkewInputOutput { #[derive(Clone, Debug, Node)] pub enum ClockingDirection { - Input(ClockingDirectionInput), - Output(ClockingDirectionOutput), - InputOutput(ClockingDirectionInputOutput), - Inout(Keyword), + Input(Box), + Output(Box), + InputOutput(Box), + Inout(Box), } #[derive(Clone, Debug, Node)] @@ -141,8 +141,8 @@ pub struct ClockingDeclAssign { #[derive(Clone, Debug, Node)] pub enum ClockingSkew { - Edge(ClockingSkewEdge), - DelayControl(DelayControl), + Edge(Box), + DelayControl(Box), } #[derive(Clone, Debug, Node)] @@ -157,9 +157,9 @@ pub struct ClockingDrive { #[derive(Clone, Debug, Node)] pub enum CycleDelay { - Integral(CycleDelayIntegral), - Identifier(CycleDelayIdentifier), - Expression(CycleDelayExpression), + Integral(Box), + Identifier(Box), + Expression(Box), } #[derive(Clone, Debug, Node)] @@ -205,9 +205,9 @@ pub fn clocking_declaration_local(s: Span) -> IResult let (s, h) = opt(pair(symbol(":"), clocking_identifier))(s)?; Ok(( s, - ClockingDeclaration::Local(ClockingDeclarationLocal { + ClockingDeclaration::Local(Box::new(ClockingDeclarationLocal { nodes: (a, b, c, d, e, f, g, h), - }), + })), )) } @@ -228,9 +228,9 @@ pub fn clocking_declaration_global(s: Span) -> IResult IResult { let (s, b) = identifier(s)?; Ok(( s, - ClockingEvent::Identifier(ClockingEventIdentifier { nodes: (a, b) }), + ClockingEvent::Identifier(Box::new(ClockingEventIdentifier { nodes: (a, b) })), )) } @@ -255,7 +255,7 @@ pub fn clocking_event_expression(s: Span) -> IResult { let (s, b) = paren(event_expression)(s)?; Ok(( s, - ClockingEvent::Expression(ClockingEventExpression { nodes: (a, b) }), + ClockingEvent::Expression(Box::new(ClockingEventExpression { nodes: (a, b) })), )) } @@ -275,7 +275,7 @@ pub fn clocking_item_default(s: Span) -> IResult { let (s, c) = symbol(";")(s)?; Ok(( s, - ClockingItem::Default(ClockingItemDefault { nodes: (a, b, c) }), + ClockingItem::Default(Box::new(ClockingItemDefault { nodes: (a, b, c) })), )) } @@ -286,7 +286,7 @@ pub fn clocking_item_direction(s: Span) -> IResult { let (s, c) = symbol(";")(s)?; Ok(( s, - ClockingItem::Direction(ClockingItemDirection { nodes: (a, b, c) }), + ClockingItem::Direction(Box::new(ClockingItemDirection { nodes: (a, b, c) })), )) } @@ -296,7 +296,7 @@ pub fn clocking_item_assertion(s: Span) -> IResult { let (s, b) = assertion_item_declaration(s)?; Ok(( s, - ClockingItem::Assertion(ClockingItemAssertion { nodes: (a, b) }), + ClockingItem::Assertion(Box::new(ClockingItemAssertion { nodes: (a, b) })), )) } @@ -313,14 +313,20 @@ pub fn default_skew(s: Span) -> IResult { pub fn default_skew_input(s: Span) -> IResult { let (s, a) = keyword("input")(s)?; let (s, b) = clocking_skew(s)?; - Ok((s, DefaultSkew::Input(DefaultSkewInput { nodes: (a, b) }))) + Ok(( + s, + DefaultSkew::Input(Box::new(DefaultSkewInput { nodes: (a, b) })), + )) } #[parser] pub fn default_skew_output(s: Span) -> IResult { let (s, a) = keyword("output")(s)?; let (s, b) = clocking_skew(s)?; - Ok((s, DefaultSkew::Output(DefaultSkewOutput { nodes: (a, b) }))) + Ok(( + s, + DefaultSkew::Output(Box::new(DefaultSkewOutput { nodes: (a, b) })), + )) } #[parser] @@ -331,9 +337,9 @@ pub fn default_skew_input_output(s: Span) -> IResult { let (s, d) = clocking_skew(s)?; Ok(( s, - DefaultSkew::InputOutput(DefaultSkewInputOutput { + DefaultSkew::InputOutput(Box::new(DefaultSkewInputOutput { nodes: (a, b, c, d), - }), + })), )) } @@ -353,7 +359,7 @@ pub fn clocking_direction_input(s: Span) -> IResult { let (s, b) = opt(clocking_skew)(s)?; Ok(( s, - ClockingDirection::Input(ClockingDirectionInput { nodes: (a, b) }), + ClockingDirection::Input(Box::new(ClockingDirectionInput { nodes: (a, b) })), )) } @@ -363,7 +369,7 @@ pub fn clocking_direction_output(s: Span) -> IResult { let (s, b) = opt(clocking_skew)(s)?; Ok(( s, - ClockingDirection::Output(ClockingDirectionOutput { nodes: (a, b) }), + ClockingDirection::Output(Box::new(ClockingDirectionOutput { nodes: (a, b) })), )) } @@ -375,16 +381,16 @@ pub fn clocking_direction_input_output(s: Span) -> IResult IResult { let (s, a) = keyword("inout")(s)?; - Ok((s, ClockingDirection::Inout(a))) + Ok((s, ClockingDirection::Inout(Box::new(a)))) } #[parser] @@ -404,7 +410,7 @@ pub fn clocking_decl_assign(s: Span) -> IResult { pub fn clocking_skew(s: Span) -> IResult { alt(( clocking_skew_edge, - map(delay_control, |x| ClockingSkew::DelayControl(x)), + map(delay_control, |x| ClockingSkew::DelayControl(Box::new(x))), ))(s) } @@ -412,7 +418,10 @@ pub fn clocking_skew(s: Span) -> IResult { pub fn clocking_skew_edge(s: Span) -> IResult { let (s, a) = edge_identifier(s)?; let (s, b) = opt(delay_control)(s)?; - Ok((s, ClockingSkew::Edge(ClockingSkewEdge { nodes: (a, b) }))) + Ok(( + s, + ClockingSkew::Edge(Box::new(ClockingSkewEdge { nodes: (a, b) })), + )) } #[parser] @@ -444,7 +453,7 @@ pub fn cycle_delay_integral(s: Span) -> IResult { let (s, b) = integral_number(s)?; Ok(( s, - CycleDelay::Integral(CycleDelayIntegral { nodes: (a, b) }), + CycleDelay::Integral(Box::new(CycleDelayIntegral { nodes: (a, b) })), )) } @@ -454,7 +463,7 @@ pub fn cycle_delay_identifier(s: Span) -> IResult { let (s, b) = identifier(s)?; Ok(( s, - CycleDelay::Identifier(CycleDelayIdentifier { nodes: (a, b) }), + CycleDelay::Identifier(Box::new(CycleDelayIdentifier { nodes: (a, b) })), )) } @@ -464,7 +473,7 @@ pub fn cycle_delay_expression(s: Span) -> IResult { let (s, b) = paren(expression)(s)?; Ok(( s, - CycleDelay::Expression(CycleDelayExpression { nodes: (a, b) }), + CycleDelay::Expression(Box::new(CycleDelayExpression { nodes: (a, b) })), )) } diff --git a/src/parser/behavioral_statements/conditional_statements.rs b/src/parser/behavioral_statements/conditional_statements.rs index 75ed0c1..4441605 100644 --- a/src/parser/behavioral_statements/conditional_statements.rs +++ b/src/parser/behavioral_statements/conditional_statements.rs @@ -22,9 +22,9 @@ pub struct ConditionalStatement { #[derive(Clone, Debug, Node)] pub enum UniquePriority { - Unique(Keyword), - Unique0(Keyword), - Priority(Keyword), + Unique(Box), + Unique0(Box), + Priority(Box), } #[derive(Clone, Debug, Node)] @@ -34,8 +34,8 @@ pub struct CondPredicate { #[derive(Clone, Debug, Node)] pub enum ExpressionOrCondPattern { - Expression(Expression), - CondPattern(CondPattern), + Expression(Box), + CondPattern(Box), } #[derive(Clone, Debug, Node)] @@ -70,9 +70,11 @@ pub fn conditional_statement(s: Span) -> IResult { #[parser] pub fn unique_priority(s: Span) -> IResult { alt(( - map(keyword("unique0"), |x| UniquePriority::Unique0(x)), - map(keyword("unique"), |x| UniquePriority::Unique(x)), - map(keyword("priority"), |x| UniquePriority::Priority(x)), + map(keyword("unique0"), |x| UniquePriority::Unique0(Box::new(x))), + map(keyword("unique"), |x| UniquePriority::Unique(Box::new(x))), + map(keyword("priority"), |x| { + UniquePriority::Priority(Box::new(x)) + }), ))(s) } @@ -85,8 +87,12 @@ pub fn cond_predicate(s: Span) -> IResult { #[parser] pub fn expression_or_cond_pattern(s: Span) -> IResult { alt(( - map(expression, |x| ExpressionOrCondPattern::Expression(x)), - map(cond_pattern, |x| ExpressionOrCondPattern::CondPattern(x)), + map(expression, |x| { + ExpressionOrCondPattern::Expression(Box::new(x)) + }), + map(cond_pattern, |x| { + ExpressionOrCondPattern::CondPattern(Box::new(x)) + }), ))(s) } diff --git a/src/parser/behavioral_statements/continuous_assignment_and_net_alias_statements.rs b/src/parser/behavioral_statements/continuous_assignment_and_net_alias_statements.rs index 5a06f0c..66d1bcc 100644 --- a/src/parser/behavioral_statements/continuous_assignment_and_net_alias_statements.rs +++ b/src/parser/behavioral_statements/continuous_assignment_and_net_alias_statements.rs @@ -8,8 +8,8 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum ContinuousAssign { - Net(ContinuousAssignNet), - Variable(ContinuousAssignVariable), + Net(Box), + Variable(Box), } #[derive(Clone, Debug, Node)] @@ -70,9 +70,9 @@ pub fn continuous_assign_net(s: Span) -> IResult { Ok(( s, - ContinuousAssign::Net(ContinuousAssignNet { + ContinuousAssign::Net(Box::new(ContinuousAssignNet { nodes: (a, b, c, d, e), - }), + })), )) } @@ -85,9 +85,9 @@ pub fn continuous_assign_variable(s: Span) -> IResult { Ok(( s, - ContinuousAssign::Variable(ContinuousAssignVariable { + ContinuousAssign::Variable(Box::new(ContinuousAssignVariable { nodes: (a, b, c, d), - }), + })), )) } diff --git a/src/parser/behavioral_statements/looping_statements.rs b/src/parser/behavioral_statements/looping_statements.rs index 9c46bbe..d594e56 100644 --- a/src/parser/behavioral_statements/looping_statements.rs +++ b/src/parser/behavioral_statements/looping_statements.rs @@ -9,12 +9,12 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum LoopStatement { - Forever(LoopStatementForever), - Repeat(LoopStatementRepeat), - While(LoopStatementWhile), - For(LoopStatementFor), - DoWhile(LoopStatementDoWhile), - Foreach(LoopStatementForeach), + Forever(Box), + Repeat(Box), + While(Box), + For(Box), + DoWhile(Box), + Foreach(Box), } #[derive(Clone, Debug, Node)] @@ -63,8 +63,8 @@ pub struct LoopStatementForeach { #[derive(Clone, Debug, Node)] pub enum ForInitialization { - ListOfVariableAssignments(ListOfVariableAssignments), - Declaration(ForInitializationDeclaration), + ListOfVariableAssignments(Box), + Declaration(Box), } #[derive(Clone, Debug, Node)] @@ -93,9 +93,9 @@ pub struct ForStep { #[derive(Clone, Debug, Node)] pub enum ForStepAssignment { - OperatorAssignment(OperatorAssignment), - IncOrDecExpression(IncOrDecExpression), - FunctionSubroutineCall(FunctionSubroutineCall), + OperatorAssignment(Box), + IncOrDecExpression(Box), + FunctionSubroutineCall(Box), } #[derive(Clone, Debug, Node)] @@ -123,7 +123,7 @@ pub fn loop_statement_forever(s: Span) -> IResult { let (s, b) = statement_or_null(s)?; Ok(( s, - LoopStatement::Forever(LoopStatementForever { nodes: (a, b) }), + LoopStatement::Forever(Box::new(LoopStatementForever { nodes: (a, b) })), )) } @@ -134,7 +134,7 @@ pub fn loop_statement_repeat(s: Span) -> IResult { let (s, c) = statement_or_null(s)?; Ok(( s, - LoopStatement::Repeat(LoopStatementRepeat { nodes: (a, b, c) }), + LoopStatement::Repeat(Box::new(LoopStatementRepeat { nodes: (a, b, c) })), )) } @@ -145,7 +145,7 @@ pub fn loop_statement_while(s: Span) -> IResult { let (s, c) = statement_or_null(s)?; Ok(( s, - LoopStatement::While(LoopStatementWhile { nodes: (a, b, c) }), + LoopStatement::While(Box::new(LoopStatementWhile { nodes: (a, b, c) })), )) } @@ -160,7 +160,10 @@ pub fn loop_statement_for(s: Span) -> IResult { opt(for_step), )))(s)?; let (s, c) = statement_or_null(s)?; - Ok((s, LoopStatement::For(LoopStatementFor { nodes: (a, b, c) }))) + Ok(( + s, + LoopStatement::For(Box::new(LoopStatementFor { nodes: (a, b, c) })), + )) } #[parser] @@ -172,9 +175,9 @@ pub fn loop_statement_do_while(s: Span) -> IResult { let (s, e) = symbol(";")(s)?; Ok(( s, - LoopStatement::DoWhile(LoopStatementDoWhile { + LoopStatement::DoWhile(Box::new(LoopStatementDoWhile { nodes: (a, b, c, d, e), - }), + })), )) } @@ -188,7 +191,7 @@ pub fn loop_statement_foreach(s: Span) -> IResult { let (s, c) = statement(s)?; Ok(( s, - LoopStatement::Foreach(LoopStatementForeach { nodes: (a, b, c) }), + LoopStatement::Foreach(Box::new(LoopStatementForeach { nodes: (a, b, c) })), )) } @@ -196,7 +199,7 @@ pub fn loop_statement_foreach(s: Span) -> IResult { pub fn for_initialization(s: Span) -> IResult { alt(( map(list_of_variable_assignments, |x| { - ForInitialization::ListOfVariableAssignments(x) + ForInitialization::ListOfVariableAssignments(Box::new(x)) }), for_initialization_declaration, ))(s) @@ -207,7 +210,7 @@ pub fn for_initialization_declaration(s: Span) -> IResult IResult { pub fn for_step_assignment(s: Span) -> IResult { alt(( map(operator_assignment, |x| { - ForStepAssignment::OperatorAssignment(x) + ForStepAssignment::OperatorAssignment(Box::new(x)) }), map(inc_or_dec_expression, |x| { - ForStepAssignment::IncOrDecExpression(x) + ForStepAssignment::IncOrDecExpression(Box::new(x)) }), map(function_subroutine_call, |x| { - ForStepAssignment::FunctionSubroutineCall(x) + ForStepAssignment::FunctionSubroutineCall(Box::new(x)) }), ))(s) } diff --git a/src/parser/behavioral_statements/parallel_and_sequential_blocks.rs b/src/parser/behavioral_statements/parallel_and_sequential_blocks.rs index ee1b5f3..3255fb5 100644 --- a/src/parser/behavioral_statements/parallel_and_sequential_blocks.rs +++ b/src/parser/behavioral_statements/parallel_and_sequential_blocks.rs @@ -10,8 +10,8 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum ActionBlock { - StatementOrNull(StatementOrNull), - Else(ActionBlockElse), + StatementOrNull(Box), + Else(Box), } #[derive(Clone, Debug, Node)] @@ -45,9 +45,9 @@ pub struct ParBlock { #[derive(Clone, Debug, Node)] pub enum JoinKeyword { - Join(Keyword), - JoinAny(Keyword), - JoinNone(Keyword), + Join(Box), + JoinAny(Box), + JoinNone(Box), } // ----------------------------------------------------------------------------- @@ -55,7 +55,9 @@ pub enum JoinKeyword { #[parser] pub fn action_block(s: Span) -> IResult { alt(( - map(statement_or_null, |x| ActionBlock::StatementOrNull(x)), + map(statement_or_null, |x| { + ActionBlock::StatementOrNull(Box::new(x)) + }), action_block_else, ))(s) } @@ -65,7 +67,10 @@ pub fn action_block_else(s: Span) -> IResult { let (s, a) = opt(statement)(s)?; let (s, b) = keyword("else")(s)?; let (s, c) = statement_or_null(s)?; - Ok((s, ActionBlock::Else(ActionBlockElse { nodes: (a, b, c) }))) + Ok(( + s, + ActionBlock::Else(Box::new(ActionBlockElse { nodes: (a, b, c) })), + )) } #[parser] @@ -103,8 +108,8 @@ pub fn par_block(s: Span) -> IResult { #[parser] pub fn join_keyword(s: Span) -> IResult { alt(( - map(keyword("join_any"), |x| JoinKeyword::JoinAny(x)), - map(keyword("join_none"), |x| JoinKeyword::JoinNone(x)), - map(keyword("join"), |x| JoinKeyword::Join(x)), + map(keyword("join_any"), |x| JoinKeyword::JoinAny(Box::new(x))), + map(keyword("join_none"), |x| JoinKeyword::JoinNone(Box::new(x))), + map(keyword("join"), |x| JoinKeyword::Join(Box::new(x))), ))(s) } diff --git a/src/parser/behavioral_statements/patterns.rs b/src/parser/behavioral_statements/patterns.rs index 3e46995..c093d89 100644 --- a/src/parser/behavioral_statements/patterns.rs +++ b/src/parser/behavioral_statements/patterns.rs @@ -11,7 +11,7 @@ use nom_packrat::packrat_parser; #[derive(Clone, Debug, Node)] pub enum Pattern { Variable(Box), - Asterisk(Symbol), + Asterisk(Box), ConstantExpression(Box), Tagged(Box), List(Box), @@ -40,10 +40,10 @@ pub struct PatternIdentifierList { #[derive(Clone, Debug, Node)] pub enum AssignmentPattern { - List(AssignmentPatternList), - Structure(AssignmentPatternStructure), - Array(AssignmentPatternArray), - Repeat(AssignmentPatternRepeat), + List(Box), + Structure(Box), + Array(Box), + Repeat(Box), } #[derive(Clone, Debug, Node)] @@ -68,20 +68,20 @@ pub struct AssignmentPatternRepeat { #[derive(Clone, Debug, Node)] pub enum StructurePatternKey { - MemberIdentifier(MemberIdentifier), - AssignmentPatternKey(AssignmentPatternKey), + MemberIdentifier(Box), + AssignmentPatternKey(Box), } #[derive(Clone, Debug, Node)] pub enum ArrayPatternKey { - ConstantExpression(ConstantExpression), - AssignmentPatternKey(AssignmentPatternKey), + ConstantExpression(Box), + AssignmentPatternKey(Box), } #[derive(Clone, Debug, Node)] pub enum AssignmentPatternKey { - SimpleType(SimpleType), - Default(Keyword), + SimpleType(Box), + Default(Box), } #[derive(Clone, Debug, Node)] @@ -91,10 +91,10 @@ pub struct AssignmentPatternExpression { #[derive(Clone, Debug, Node)] pub enum AssignmentPatternExpressionType { - PsTypeIdentifier(PsTypeIdentifier), - PsParameterIdentifier(PsParameterIdentifier), - IntegerAtomType(IntegerAtomType), - TypeReference(TypeReference), + PsTypeIdentifier(Box), + PsParameterIdentifier(Box), + IntegerAtomType(Box), + TypeReference(Box), } #[derive(Clone, Debug, Node)] @@ -118,7 +118,7 @@ pub struct AssignmentPatternVariableLvalue { pub fn pattern(s: Span) -> IResult { alt(( pattern_variable, - map(symbol(".*"), |x| Pattern::Asterisk(x)), + map(symbol(".*"), |x| Pattern::Asterisk(Box::new(x))), map(constant_expression, |x| { Pattern::ConstantExpression(Box::new(x)) }), @@ -182,7 +182,7 @@ pub fn assignment_pattern_list(s: Span) -> IResult { let (s, a) = apostrophe_brace(list(symbol(","), expression))(s)?; Ok(( s, - AssignmentPattern::List(AssignmentPatternList { nodes: (a,) }), + AssignmentPattern::List(Box::new(AssignmentPatternList { nodes: (a,) })), )) } @@ -194,7 +194,7 @@ pub fn assignment_pattern_structure(s: Span) -> IResult ))(s)?; Ok(( s, - AssignmentPattern::Structure(AssignmentPatternStructure { nodes: (a,) }), + AssignmentPattern::Structure(Box::new(AssignmentPatternStructure { nodes: (a,) })), )) } @@ -206,7 +206,7 @@ pub fn assignment_pattern_array(s: Span) -> IResult { ))(s)?; Ok(( s, - AssignmentPattern::Array(AssignmentPatternArray { nodes: (a,) }), + AssignmentPattern::Array(Box::new(AssignmentPatternArray { nodes: (a,) })), )) } @@ -218,7 +218,7 @@ pub fn assignment_pattern_repeat(s: Span) -> IResult { ))(s)?; Ok(( s, - AssignmentPattern::Repeat(AssignmentPatternRepeat { nodes: (a,) }), + AssignmentPattern::Repeat(Box::new(AssignmentPatternRepeat { nodes: (a,) })), )) } @@ -226,10 +226,10 @@ pub fn assignment_pattern_repeat(s: Span) -> IResult { pub fn structure_pattern_key(s: Span) -> IResult { alt(( map(member_identifier, |x| { - StructurePatternKey::MemberIdentifier(x) + StructurePatternKey::MemberIdentifier(Box::new(x)) }), map(assignment_pattern_key, |x| { - StructurePatternKey::AssignmentPatternKey(x) + StructurePatternKey::AssignmentPatternKey(Box::new(x)) }), ))(s) } @@ -238,10 +238,10 @@ pub fn structure_pattern_key(s: Span) -> IResult { pub fn array_pattern_key(s: Span) -> IResult { alt(( map(constant_expression, |x| { - ArrayPatternKey::ConstantExpression(x) + ArrayPatternKey::ConstantExpression(Box::new(x)) }), map(assignment_pattern_key, |x| { - ArrayPatternKey::AssignmentPatternKey(x) + ArrayPatternKey::AssignmentPatternKey(Box::new(x)) }), ))(s) } @@ -249,8 +249,12 @@ pub fn array_pattern_key(s: Span) -> IResult { #[parser] pub fn assignment_pattern_key(s: Span) -> IResult { alt(( - map(simple_type, |x| AssignmentPatternKey::SimpleType(x)), - map(keyword("default"), |x| AssignmentPatternKey::Default(x)), + map(simple_type, |x| { + AssignmentPatternKey::SimpleType(Box::new(x)) + }), + map(keyword("default"), |x| { + AssignmentPatternKey::Default(Box::new(x)) + }), ))(s) } @@ -268,16 +272,16 @@ pub fn assignment_pattern_expression_type( ) -> IResult { alt(( map(ps_type_identifier, |x| { - AssignmentPatternExpressionType::PsTypeIdentifier(x) + AssignmentPatternExpressionType::PsTypeIdentifier(Box::new(x)) }), map(ps_parameter_identifier, |x| { - AssignmentPatternExpressionType::PsParameterIdentifier(x) + AssignmentPatternExpressionType::PsParameterIdentifier(Box::new(x)) }), map(integer_atom_type, |x| { - AssignmentPatternExpressionType::IntegerAtomType(x) + AssignmentPatternExpressionType::IntegerAtomType(Box::new(x)) }), map(type_reference, |x| { - AssignmentPatternExpressionType::TypeReference(x) + AssignmentPatternExpressionType::TypeReference(Box::new(x)) }), ))(s) } diff --git a/src/parser/behavioral_statements/procedural_blocks_and_assignments.rs b/src/parser/behavioral_statements/procedural_blocks_and_assignments.rs index 3f19a7d..b23a309 100644 --- a/src/parser/behavioral_statements/procedural_blocks_and_assignments.rs +++ b/src/parser/behavioral_statements/procedural_blocks_and_assignments.rs @@ -18,10 +18,10 @@ pub struct AlwaysConstruct { #[derive(Clone, Debug, Node)] pub enum AlwaysKeyword { - Always(Keyword), - AlwaysComb(Keyword), - AlwaysLatch(Keyword), - AlwaysFf(Keyword), + Always(Box), + AlwaysComb(Box), + AlwaysLatch(Box), + AlwaysFf(Box), } #[derive(Clone, Debug, Node)] @@ -31,10 +31,10 @@ pub struct FinalConstruct { #[derive(Clone, Debug, Node)] pub enum BlockingAssignment { - Variable(BlockingAssignmentVariable), - NonrangeVariable(BlockingAssignmentNonrangeVariable), - HierarchicalVariable(BlockingAssignmentHierarchicalVariable), - OperatorAssignment(OperatorAssignment), + Variable(Box), + NonrangeVariable(Box), + HierarchicalVariable(Box), + OperatorAssignment(Box), } #[derive(Clone, Debug, Node)] @@ -80,12 +80,12 @@ pub struct NonblockingAssignment { #[derive(Clone, Debug, Node)] pub enum ProceduralContinuousAssignment { - Assign(ProceduralContinuousAssignmentAssign), - Deassign(ProceduralContinuousAssignmentDeassign), - ForceVariable(ProceduralContinuousAssignmentForceVariable), - ForceNet(ProceduralContinuousAssignmentForceNet), - ReleaseVariable(ProceduralContinuousAssignmentReleaseVariable), - ReleaseNet(ProceduralContinuousAssignmentReleaseNet), + Assign(Box), + Deassign(Box), + ForceVariable(Box), + ForceNet(Box), + ReleaseVariable(Box), + ReleaseNet(Box), } #[derive(Clone, Debug, Node)] @@ -142,10 +142,16 @@ pub fn always_construct(s: Span) -> IResult { #[parser] pub fn always_keyword(s: Span) -> IResult { alt(( - map(keyword("always_comb"), |x| AlwaysKeyword::AlwaysComb(x)), - map(keyword("always_latch"), |x| AlwaysKeyword::AlwaysLatch(x)), - map(keyword("always_ff"), |x| AlwaysKeyword::AlwaysFf(x)), - map(keyword("always"), |x| AlwaysKeyword::Always(x)), + map(keyword("always_comb"), |x| { + AlwaysKeyword::AlwaysComb(Box::new(x)) + }), + map(keyword("always_latch"), |x| { + AlwaysKeyword::AlwaysLatch(Box::new(x)) + }), + map(keyword("always_ff"), |x| { + AlwaysKeyword::AlwaysFf(Box::new(x)) + }), + map(keyword("always"), |x| AlwaysKeyword::Always(Box::new(x))), ))(s) } @@ -163,7 +169,7 @@ pub fn blocking_assignment(s: Span) -> IResult { blocking_assignment_nonrange_variable, blocking_assignment_hierarchical_variable, map(operator_assignment, |x| { - BlockingAssignment::OperatorAssignment(x) + BlockingAssignment::OperatorAssignment(Box::new(x)) }), ))(s) } @@ -176,9 +182,9 @@ pub fn blocking_assignment_variable(s: Span) -> IResult IResult IResult), + Join(Box), } #[derive(Clone, Debug, Node)] @@ -64,9 +64,9 @@ pub struct RsProductionListJoin { #[derive(Clone, Debug, Node)] pub enum WeightSpecification { - IntegralNumber(IntegralNumber), - PsIdentifier(PsIdentifier), - Expression(WeightSpecificationExpression), + IntegralNumber(Box), + PsIdentifier(Box), + Expression(Box), } #[derive(Clone, Debug, Node)] @@ -81,11 +81,11 @@ pub struct RsCodeBlock { #[derive(Clone, Debug, Node)] pub enum RsProd { - ProductionItem(ProductionItem), - RsCodeBlock(RsCodeBlock), - RsIfElse(RsIfElse), - RsRepeat(RsRepeat), - RsCase(RsCase), + ProductionItem(Box), + RsCodeBlock(Box), + RsIfElse(Box), + RsRepeat(Box), + RsCase(Box), } #[derive(Clone, Debug, Node)] @@ -121,8 +121,8 @@ pub struct RsCase { #[derive(Clone, Debug, Node)] pub enum RsCaseItem { - NonDefault(RsCaseItemNondefault), - Default(RsCaseItemDefault), + NonDefault(Box), + Default(Box), } #[derive(Clone, Debug, Node)] @@ -195,7 +195,7 @@ pub fn rs_production_list_prod(s: Span) -> IResult { let (s, b) = many0(rs_prod)(s)?; Ok(( s, - RsProductionList::Prod(RsProductionListProd { nodes: (a, b) }), + RsProductionList::Prod(Box::new(RsProductionListProd { nodes: (a, b) })), )) } @@ -209,17 +209,21 @@ pub fn rs_production_list_join(s: Span) -> IResult { let (s, f) = many0(production_item)(s)?; Ok(( s, - RsProductionList::Join(RsProductionListJoin { + RsProductionList::Join(Box::new(RsProductionListJoin { nodes: (a, b, c, d, e, f), - }), + })), )) } #[parser] pub fn weight_specification(s: Span) -> IResult { alt(( - map(integral_number, |x| WeightSpecification::IntegralNumber(x)), - map(ps_identifier, |x| WeightSpecification::PsIdentifier(x)), + map(integral_number, |x| { + WeightSpecification::IntegralNumber(Box::new(x)) + }), + map(ps_identifier, |x| { + WeightSpecification::PsIdentifier(Box::new(x)) + }), weight_specification_expression, ))(s) } @@ -229,7 +233,7 @@ pub fn weight_specification_expression(s: Span) -> IResult IResult { #[parser] pub fn rs_prod(s: Span) -> IResult { alt(( - map(production_item, |x| RsProd::ProductionItem(x)), - map(rs_code_block, |x| RsProd::RsCodeBlock(x)), - map(rs_if_else, |x| RsProd::RsIfElse(x)), - map(rs_repeat, |x| RsProd::RsRepeat(x)), - map(rs_case, |x| RsProd::RsCase(x)), + map(production_item, |x| RsProd::ProductionItem(Box::new(x))), + map(rs_code_block, |x| RsProd::RsCodeBlock(Box::new(x))), + map(rs_if_else, |x| RsProd::RsIfElse(Box::new(x))), + map(rs_repeat, |x| RsProd::RsRepeat(Box::new(x))), + map(rs_case, |x| RsProd::RsCase(Box::new(x))), ))(s) } @@ -307,9 +311,9 @@ pub fn rs_case_item_nondefault(s: Span) -> IResult { let (s, d) = symbol(";")(s)?; Ok(( s, - RsCaseItem::NonDefault(RsCaseItemNondefault { + RsCaseItem::NonDefault(Box::new(RsCaseItemNondefault { nodes: (a, b, c, d), - }), + })), )) } @@ -321,8 +325,8 @@ pub fn rs_case_item_default(s: Span) -> IResult { let (s, d) = symbol(";")(s)?; Ok(( s, - RsCaseItem::Default(RsCaseItemDefault { + RsCaseItem::Default(Box::new(RsCaseItemDefault { nodes: (a, b, c, d), - }), + })), )) } diff --git a/src/parser/behavioral_statements/statements.rs b/src/parser/behavioral_statements/statements.rs index 4835859..dabaa9a 100644 --- a/src/parser/behavioral_statements/statements.rs +++ b/src/parser/behavioral_statements/statements.rs @@ -10,8 +10,8 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum StatementOrNull { - Statement(Statement), - Attribute(StatementOrNullAttribute), + Statement(Box), + Attribute(Box), } #[derive(Clone, Debug, Node)] @@ -59,8 +59,8 @@ pub struct FunctionStatement { #[derive(Clone, Debug, Node)] pub enum FunctionStatementOrNull { - Statement(FunctionStatement), - Attribute(FunctionStatementOrNullAttribute), + Statement(Box), + Attribute(Box), } #[derive(Clone, Debug, Node)] @@ -78,7 +78,7 @@ pub struct VariableIdentifierList { #[parser] pub fn statement_or_null(s: Span) -> IResult { alt(( - map(statement, |x| StatementOrNull::Statement(x)), + map(statement, |x| StatementOrNull::Statement(Box::new(x))), statement_or_null_attribute, ))(s) } @@ -89,7 +89,7 @@ pub fn statement_or_null_attribute(s: Span) -> IResult { let (s, b) = symbol(";")(s)?; Ok(( s, - StatementOrNull::Attribute(StatementOrNullAttribute { nodes: (a, b) }), + StatementOrNull::Attribute(Box::new(StatementOrNullAttribute { nodes: (a, b) })), )) } @@ -171,7 +171,7 @@ pub fn function_statement(s: Span) -> IResult { pub fn function_statement_or_null(s: Span) -> IResult { alt(( map(function_statement, |x| { - FunctionStatementOrNull::Statement(x) + FunctionStatementOrNull::Statement(Box::new(x)) }), function_statement_or_null_attribute, ))(s) @@ -183,7 +183,9 @@ pub fn function_statement_or_null_attribute(s: Span) -> IResult), + Function(Box), } #[derive(Clone, Debug, Node)] @@ -24,7 +24,7 @@ pub struct SubroutineCallStatementFunction { pub fn subroutine_call_statement(s: Span) -> IResult { alt(( map(pair(subroutine_call, symbol(";")), |x| { - SubroutineCallStatement::SubroutineCall(x) + SubroutineCallStatement::SubroutineCall(Box::new(x)) }), subroutine_call_statement_function, ))(s) @@ -38,9 +38,9 @@ pub fn subroutine_call_statement_function(s: Span) -> IResult), + Event(Box), + Repeat(Box), } #[derive(Clone, Debug, Node)] @@ -26,8 +26,8 @@ pub struct DelayOrEventControlRepeat { #[derive(Clone, Debug, Node)] pub enum DelayControl { - Delay(DelayControlDelay), - Mintypmax(DelayControlMintypmax), + Delay(Box), + Mintypmax(Box), } #[derive(Clone, Debug, Node)] @@ -42,11 +42,11 @@ pub struct DelayControlMintypmax { #[derive(Clone, Debug, Node)] pub enum EventControl { - EventIdentifier(EventControlEventIdentifier), - EventExpression(EventControlEventExpression), - Asterisk(EventControlAsterisk), - ParenAsterisk(EventControlParenAsterisk), - SequenceIdentifier(EventControlSequenceIdentifier), + EventIdentifier(Box), + EventExpression(Box), + Asterisk(Box), + ParenAsterisk(Box), + SequenceIdentifier(Box), } #[derive(Clone, Debug, Node)] @@ -114,16 +114,16 @@ pub struct EventExpressionParen { #[derive(Clone, Debug, Node)] pub enum ProceduralTimingControl { - DelayControl(DelayControl), - EventControl(EventControl), - CycleDelay(CycleDelay), + DelayControl(Box), + EventControl(Box), + CycleDelay(Box), } #[derive(Clone, Debug, Node)] pub enum JumpStatement { - Return(JumpStatementReturn), - Break(JumpStatementBreak), - Continue(JumpStatementContinue), + Return(Box), + Break(Box), + Continue(Box), } #[derive(Clone, Debug, Node)] @@ -143,9 +143,9 @@ pub struct JumpStatementContinue { #[derive(Clone, Debug, Node)] pub enum WaitStatement { - Wait(WaitStatementWait), - Fork(WaitStatementFork), - Order(WaitStatementOrder), + Wait(Box), + Fork(Box), + Order(Box), } #[derive(Clone, Debug, Node)] @@ -169,8 +169,8 @@ pub struct WaitStatementOrder { #[derive(Clone, Debug, Node)] pub enum EventTrigger { - Named(EventTriggerNamed), - Nonblocking(EventTriggerNonblocking), + Named(Box), + Nonblocking(Box), } #[derive(Clone, Debug, Node)] @@ -190,9 +190,9 @@ pub struct EventTriggerNonblocking { #[derive(Clone, Debug, Node)] pub enum DisableStatement { - Task(DisableStatementTask), - Block(DisableStatementBlock), - Fork(DisableStatementFork), + Task(Box), + Block(Box), + Fork(Box), } #[derive(Clone, Debug, Node)] @@ -224,8 +224,8 @@ pub fn procedural_timing_control_statement( #[parser] pub fn delay_or_event_control(s: Span) -> IResult { alt(( - map(delay_control, |x| DelayOrEventControl::Delay(x)), - map(event_control, |x| DelayOrEventControl::Event(x)), + map(delay_control, |x| DelayOrEventControl::Delay(Box::new(x))), + map(event_control, |x| DelayOrEventControl::Event(Box::new(x))), delay_or_event_control_repeat, ))(s) } @@ -237,7 +237,7 @@ pub fn delay_or_event_control_repeat(s: Span) -> IResult IResult { pub fn delay_control_delay(s: Span) -> IResult { let (s, a) = symbol("#")(s)?; let (s, b) = delay_value(s)?; - Ok((s, DelayControl::Delay(DelayControlDelay { nodes: (a, b) }))) + Ok(( + s, + DelayControl::Delay(Box::new(DelayControlDelay { nodes: (a, b) })), + )) } #[parser] @@ -259,7 +262,7 @@ pub fn delay_control_mintypmax(s: Span) -> IResult { let (s, b) = paren(mintypmax_expression)(s)?; Ok(( s, - DelayControl::Mintypmax(DelayControlMintypmax { nodes: (a, b) }), + DelayControl::Mintypmax(Box::new(DelayControlMintypmax { nodes: (a, b) })), )) } @@ -280,7 +283,7 @@ pub fn event_control_event_identifier(s: Span) -> IResult { let (s, b) = hierarchical_event_identifier(s)?; Ok(( s, - EventControl::EventIdentifier(EventControlEventIdentifier { nodes: (a, b) }), + EventControl::EventIdentifier(Box::new(EventControlEventIdentifier { nodes: (a, b) })), )) } @@ -290,7 +293,7 @@ pub fn event_control_event_expression(s: Span) -> IResult { let (s, b) = paren(event_expression)(s)?; Ok(( s, - EventControl::EventExpression(EventControlEventExpression { nodes: (a, b) }), + EventControl::EventExpression(Box::new(EventControlEventExpression { nodes: (a, b) })), )) } @@ -299,7 +302,7 @@ pub fn event_control_asterisk(s: Span) -> IResult { let (s, a) = symbol("@*")(s)?; Ok(( s, - EventControl::Asterisk(EventControlAsterisk { nodes: (a,) }), + EventControl::Asterisk(Box::new(EventControlAsterisk { nodes: (a,) })), )) } @@ -309,7 +312,7 @@ pub fn event_control_paren_asterisk(s: Span) -> IResult { let (s, b) = paren(symbol("*"))(s)?; Ok(( s, - EventControl::ParenAsterisk(EventControlParenAsterisk { nodes: (a, b) }), + EventControl::ParenAsterisk(Box::new(EventControlParenAsterisk { nodes: (a, b) })), )) } @@ -319,7 +322,9 @@ pub fn event_control_sequence_identifier(s: Span) -> IResult let (s, b) = ps_or_hierarchical_sequence_identifier(s)?; Ok(( s, - EventControl::SequenceIdentifier(EventControlSequenceIdentifier { nodes: (a, b) }), + EventControl::SequenceIdentifier(Box::new(EventControlSequenceIdentifier { + nodes: (a, b), + })), )) } @@ -389,9 +394,15 @@ pub fn event_expression_paren(s: Span) -> IResult { #[parser] pub fn procedural_timing_control(s: Span) -> IResult { alt(( - map(delay_control, |x| ProceduralTimingControl::DelayControl(x)), - map(event_control, |x| ProceduralTimingControl::EventControl(x)), - map(cycle_delay, |x| ProceduralTimingControl::CycleDelay(x)), + map(delay_control, |x| { + ProceduralTimingControl::DelayControl(Box::new(x)) + }), + map(event_control, |x| { + ProceduralTimingControl::EventControl(Box::new(x)) + }), + map(cycle_delay, |x| { + ProceduralTimingControl::CycleDelay(Box::new(x)) + }), ))(s) } @@ -411,7 +422,7 @@ pub fn jump_statement_return(s: Span) -> IResult { let (s, c) = symbol(";")(s)?; Ok(( s, - JumpStatement::Return(JumpStatementReturn { nodes: (a, b, c) }), + JumpStatement::Return(Box::new(JumpStatementReturn { nodes: (a, b, c) })), )) } @@ -421,7 +432,7 @@ pub fn jump_statement_break(s: Span) -> IResult { let (s, b) = symbol(";")(s)?; Ok(( s, - JumpStatement::Break(JumpStatementBreak { nodes: (a, b) }), + JumpStatement::Break(Box::new(JumpStatementBreak { nodes: (a, b) })), )) } @@ -431,7 +442,7 @@ pub fn jump_statement_continue(s: Span) -> IResult { let (s, b) = symbol(";")(s)?; Ok(( s, - JumpStatement::Continue(JumpStatementContinue { nodes: (a, b) }), + JumpStatement::Continue(Box::new(JumpStatementContinue { nodes: (a, b) })), )) } @@ -451,7 +462,7 @@ pub fn wait_statement_wait(s: Span) -> IResult { let (s, c) = statement_or_null(s)?; Ok(( s, - WaitStatement::Wait(WaitStatementWait { nodes: (a, b, c) }), + WaitStatement::Wait(Box::new(WaitStatementWait { nodes: (a, b, c) })), )) } @@ -462,7 +473,7 @@ pub fn wait_statement_fork(s: Span) -> IResult { let (s, c) = symbol(";")(s)?; Ok(( s, - WaitStatement::Fork(WaitStatementFork { nodes: (a, b, c) }), + WaitStatement::Fork(Box::new(WaitStatementFork { nodes: (a, b, c) })), )) } @@ -473,7 +484,7 @@ pub fn wait_statement_order(s: Span) -> IResult { let (s, c) = action_block(s)?; Ok(( s, - WaitStatement::Order(WaitStatementOrder { nodes: (a, b, c) }), + WaitStatement::Order(Box::new(WaitStatementOrder { nodes: (a, b, c) })), )) } @@ -489,7 +500,7 @@ pub fn event_trigger_named(s: Span) -> IResult { let (s, c) = symbol(";")(s)?; Ok(( s, - EventTrigger::Named(EventTriggerNamed { nodes: (a, b, c) }), + EventTrigger::Named(Box::new(EventTriggerNamed { nodes: (a, b, c) })), )) } @@ -501,9 +512,9 @@ pub fn event_trigger_nonblocking(s: Span) -> IResult { let (s, d) = symbol(";")(s)?; Ok(( s, - EventTrigger::Nonblocking(EventTriggerNonblocking { + EventTrigger::Nonblocking(Box::new(EventTriggerNonblocking { nodes: (a, b, c, d), - }), + })), )) } @@ -523,7 +534,7 @@ pub fn disable_statement_task(s: Span) -> IResult { let (s, c) = symbol(";")(s)?; Ok(( s, - DisableStatement::Task(DisableStatementTask { nodes: (a, b, c) }), + DisableStatement::Task(Box::new(DisableStatementTask { nodes: (a, b, c) })), )) } @@ -534,7 +545,7 @@ pub fn disable_statement_block(s: Span) -> IResult { let (s, c) = symbol(";")(s)?; Ok(( s, - DisableStatement::Block(DisableStatementBlock { nodes: (a, b, c) }), + DisableStatement::Block(Box::new(DisableStatementBlock { nodes: (a, b, c) })), )) } @@ -545,6 +556,6 @@ pub fn disable_statement_fork(s: Span) -> IResult { let (s, c) = symbol(";")(s)?; Ok(( s, - DisableStatement::Fork(DisableStatementFork { nodes: (a, b, c) }), + DisableStatement::Fork(Box::new(DisableStatementFork { nodes: (a, b, c) })), )) } diff --git a/src/parser/declarations/assertion_declarations.rs b/src/parser/declarations/assertion_declarations.rs index c650704..cf1f554 100644 --- a/src/parser/declarations/assertion_declarations.rs +++ b/src/parser/declarations/assertion_declarations.rs @@ -10,8 +10,8 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum ConcurrentAssertionItem { - Statement(ConcurrentAssertionItemStatement), - CheckerInstantiation(CheckerInstantiation), + Statement(Box), + CheckerInstantiation(Box), } #[derive(Clone, Debug, Node)] @@ -24,11 +24,11 @@ pub struct ConcurrentAssertionItemStatement { #[derive(Clone, Debug, Node)] pub enum ConcurrentAssertionStatement { - AssertPropertyStatement(AssertPropertyStatement), - AssumePropertyStatement(AssumePropertyStatement), - CoverPropertyStatement(CoverPropertyStatement), - CoverSequenceStatement(CoverSequenceStatement), - RestrictPropertyStatement(RestrictPropertyStatement), + AssertPropertyStatement(Box), + AssumePropertyStatement(Box), + CoverPropertyStatement(Box), + CoverSequenceStatement(Box), + RestrictPropertyStatement(Box), } #[derive(Clone, Debug, Node)] @@ -80,8 +80,8 @@ pub struct PropertyInstance { #[derive(Clone, Debug, Node)] pub enum PropertyListOfArguments { - Ordered(PropertyListOfArgumentsOrdered), - Named(PropertyListOfArgumentsNamed), + Ordered(Box), + Named(Box), } #[derive(Clone, Debug, Node)] @@ -99,15 +99,15 @@ pub struct PropertyListOfArgumentsNamed { #[derive(Clone, Debug, Node)] pub enum PropertyActualArg { - PropertyExpr(PropertyExpr), - SequenceActualArg(SequenceActualArg), + PropertyExpr(Box), + SequenceActualArg(Box), } #[derive(Clone, Debug, Node)] pub enum AssertionItemDeclaration { - PropertyDeclaration(PropertyDeclaration), - SequenceDeclaration(SequenceDeclaration), - LetDeclaration(LetDeclaration), + PropertyDeclaration(Box), + SequenceDeclaration(Box), + LetDeclaration(Box), } #[derive(Clone, Debug, Node)] @@ -144,13 +144,13 @@ pub struct PropertyPortItem { #[derive(Clone, Debug, Node)] pub enum PropertyLvarPortDirection { - Input(Keyword), + Input(Box), } #[derive(Clone, Debug, Node)] pub enum PropertyFormalType { - SequenceFormalType(SequenceFormalType), - Property(Keyword), + SequenceFormalType(Box), + Property(Box), } #[derive(Clone, Debug, Node)] @@ -164,9 +164,9 @@ pub struct PropertySpec { #[derive(Clone, Debug, Node)] pub enum PropertyExpr { - SequenceExpr(SequenceExpr), - Strong(PropertyExprStrong), - Weak(PropertyExprWeak), + SequenceExpr(Box), + Strong(Box), + Weak(Box), Paren(Box), Not(Box), Or(Box), @@ -367,8 +367,8 @@ pub struct PropertyExprClockingEvent { #[derive(Clone, Debug, Node)] pub enum PropertyCaseItem { - Nondefault(PropertyCaseItemNondefault), - Default(PropertyCaseItemDefault), + Nondefault(Box), + Default(Box), } #[derive(Clone, Debug, Node)] @@ -415,23 +415,23 @@ pub struct SequencePortItem { #[derive(Clone, Debug, Node)] pub enum SequenceLvarPortDirection { - Input(Keyword), - Inout(Keyword), - Output(Keyword), + Input(Box), + Inout(Box), + Output(Box), } #[derive(Clone, Debug, Node)] pub enum SequenceFormalType { - DataTypeOrImplicit(DataTypeOrImplicit), - Sequence(Keyword), - Untyped(Keyword), + DataTypeOrImplicit(Box), + Sequence(Box), + Untyped(Box), } #[derive(Clone, Debug, Node)] pub enum SequenceExpr { CycleDelayExpr(Box), ExprCycleDelayExpr(Box), - Expression(SequenceExprExpression), + Expression(Box), Instance(Box), Paren(Box), And(Box), @@ -520,10 +520,10 @@ pub struct SequenceExprClockingEvent { #[derive(Clone, Debug, Node)] pub enum CycleDelayRange { - Primary(CycleDelayRangePrimary), - Expression(CycleDelayRangeExpression), - Asterisk(CycleDelayRangeAsterisk), - Plus(CycleDelayRangePlus), + Primary(Box), + Expression(Box), + Asterisk(Box), + Plus(Box), } #[derive(Clone, Debug, Node)] @@ -553,9 +553,9 @@ pub struct SequenceMethodCall { #[derive(Clone, Debug, Node)] pub enum SequenceMatchItem { - OperatorAssignment(OperatorAssignment), - IncOrDecExpression(IncOrDecExpression), - SubroutineCall(SubroutineCall), + OperatorAssignment(Box), + IncOrDecExpression(Box), + SubroutineCall(Box), } #[derive(Clone, Debug, Node)] @@ -568,8 +568,8 @@ pub struct SequenceInstance { #[derive(Clone, Debug, Node)] pub enum SequenceListOfArguments { - Ordered(SequenceListOfArgumentsOrdered), - Named(SequenceListOfArgumentsNamed), + Ordered(Box), + Named(Box), } #[derive(Clone, Debug, Node)] @@ -587,15 +587,15 @@ pub struct SequenceListOfArgumentsNamed { #[derive(Clone, Debug, Node)] pub enum SequenceActualArg { - EventExpression(EventExpression), - SequenceExpr(SequenceExpr), + EventExpression(Box), + SequenceExpr(Box), } #[derive(Clone, Debug, Node)] pub enum BooleanAbbrev { - ConsecutiveRepetition(ConsecutiveRepetition), - NonConsecutiveRepetition(NonConsecutiveRepetition), - GotoRepetition(GotoRepetition), + ConsecutiveRepetition(Box), + NonConsecutiveRepetition(Box), + GotoRepetition(Box), } #[derive(Clone, Debug, Node)] @@ -605,9 +605,9 @@ pub struct SequenceAbbrev { #[derive(Clone, Debug, Node)] pub enum ConsecutiveRepetition { - Expression(ConsecutiveRepetitionExpression), - Asterisk(ConsecutiveRepetitionAsterisk), - Plus(ConsecutiveRepetitionPlus), + Expression(Box), + Asterisk(Box), + Plus(Box), } #[derive(Clone, Debug, Node)] @@ -637,14 +637,14 @@ pub struct GotoRepetition { #[derive(Clone, Debug, Node)] pub enum ConstOrRangeExpression { - ConstantExpression(ConstantExpression), - CycleDelayConstRangeExpression(CycleDelayConstRangeExpression), + ConstantExpression(Box), + CycleDelayConstRangeExpression(Box), } #[derive(Clone, Debug, Node)] pub enum CycleDelayConstRangeExpression { - Binary(CycleDelayConstRangeExpressionBinary), - Dollar(CycleDelayConstRangeExpressionDollar), + Binary(Box), + Dollar(Box), } #[derive(Clone, Debug, Node)] @@ -674,7 +674,7 @@ pub fn concurrent_assertion_item(s: Span) -> IResult IResult IResult IResult { alt(( map(assert_property_statement, |x| { - ConcurrentAssertionStatement::AssertPropertyStatement(x) + ConcurrentAssertionStatement::AssertPropertyStatement(Box::new(x)) }), map(assume_property_statement, |x| { - ConcurrentAssertionStatement::AssumePropertyStatement(x) + ConcurrentAssertionStatement::AssumePropertyStatement(Box::new(x)) }), map(cover_property_statement, |x| { - ConcurrentAssertionStatement::CoverPropertyStatement(x) + ConcurrentAssertionStatement::CoverPropertyStatement(Box::new(x)) }), map(cover_sequence_statement, |x| { - ConcurrentAssertionStatement::CoverSequenceStatement(x) + ConcurrentAssertionStatement::CoverSequenceStatement(Box::new(x)) }), map(restrict_property_statement, |x| { - ConcurrentAssertionStatement::RestrictPropertyStatement(x) + ConcurrentAssertionStatement::RestrictPropertyStatement(Box::new(x)) }), ))(s) } @@ -822,7 +824,9 @@ pub fn property_list_of_arguments_ordered(s: Span) -> IResult IResult IResult { alt(( - map(property_expr, |x| PropertyActualArg::PropertyExpr(x)), + map(property_expr, |x| { + PropertyActualArg::PropertyExpr(Box::new(x)) + }), map(sequence_actual_arg, |x| { - PropertyActualArg::SequenceActualArg(x) + PropertyActualArg::SequenceActualArg(Box::new(x)) }), ))(s) } @@ -852,13 +858,13 @@ pub fn property_actual_arg(s: Span) -> IResult { pub fn assertion_item_declaration(s: Span) -> IResult { alt(( map(property_declaration, |x| { - AssertionItemDeclaration::PropertyDeclaration(x) + AssertionItemDeclaration::PropertyDeclaration(Box::new(x)) }), map(sequence_declaration, |x| { - AssertionItemDeclaration::SequenceDeclaration(x) + AssertionItemDeclaration::SequenceDeclaration(Box::new(x)) }), map(let_declaration, |x| { - AssertionItemDeclaration::LetDeclaration(x) + AssertionItemDeclaration::LetDeclaration(Box::new(x)) }), ))(s) } @@ -907,16 +913,18 @@ pub fn property_port_item(s: Span) -> IResult { #[parser] pub fn property_lvar_port_direction(s: Span) -> IResult { let (s, a) = keyword("input")(s)?; - Ok((s, PropertyLvarPortDirection::Input(a))) + Ok((s, PropertyLvarPortDirection::Input(Box::new(a)))) } #[parser] pub fn property_formal_type(s: Span) -> IResult { alt(( map(sequence_formal_type, |x| { - PropertyFormalType::SequenceFormalType(x) + PropertyFormalType::SequenceFormalType(Box::new(x)) + }), + map(keyword("property"), |x| { + PropertyFormalType::Property(Box::new(x)) }), - map(keyword("property"), |x| PropertyFormalType::Property(x)), ))(s) } @@ -936,7 +944,7 @@ pub fn property_spec(s: Span) -> IResult { pub fn property_expr(s: Span) -> IResult { alt(( alt(( - map(sequence_expr, |x| PropertyExpr::SequenceExpr(x)), + map(sequence_expr, |x| PropertyExpr::SequenceExpr(Box::new(x))), property_expr_strong, property_expr_weak, property_expr_paren, @@ -981,7 +989,7 @@ pub fn property_expr_strong(s: Span) -> IResult { let (s, b) = paren(sequence_expr)(s)?; Ok(( s, - PropertyExpr::Strong(PropertyExprStrong { nodes: (a, b) }), + PropertyExpr::Strong(Box::new(PropertyExprStrong { nodes: (a, b) })), )) } @@ -991,7 +999,7 @@ pub fn property_expr_weak(s: Span) -> IResult { let (s, b) = paren(sequence_expr)(s)?; Ok(( s, - PropertyExpr::Strong(PropertyExprStrong { nodes: (a, b) }), + PropertyExpr::Strong(Box::new(PropertyExprStrong { nodes: (a, b) })), )) } @@ -1316,9 +1324,9 @@ pub fn property_case_item_nondefault(s: Span) -> IResult let (s, d) = symbol(";")(s)?; Ok(( s, - PropertyCaseItem::Nondefault(PropertyCaseItemNondefault { + PropertyCaseItem::Nondefault(Box::new(PropertyCaseItemNondefault { nodes: (a, b, c, d), - }), + })), )) } @@ -1330,9 +1338,9 @@ pub fn property_case_item_default(s: Span) -> IResult { let (s, d) = symbol(";")(s)?; Ok(( s, - PropertyCaseItem::Default(PropertyCaseItemDefault { + PropertyCaseItem::Default(Box::new(PropertyCaseItemDefault { nodes: (a, b, c, d), - }), + })), )) } @@ -1380,9 +1388,15 @@ pub fn sequence_port_item(s: Span) -> IResult { #[parser] pub fn sequence_lvar_port_direction(s: Span) -> IResult { alt(( - map(keyword("input"), |x| SequenceLvarPortDirection::Input(x)), - map(keyword("inout"), |x| SequenceLvarPortDirection::Inout(x)), - map(keyword("output"), |x| SequenceLvarPortDirection::Output(x)), + map(keyword("input"), |x| { + SequenceLvarPortDirection::Input(Box::new(x)) + }), + map(keyword("inout"), |x| { + SequenceLvarPortDirection::Inout(Box::new(x)) + }), + map(keyword("output"), |x| { + SequenceLvarPortDirection::Output(Box::new(x)) + }), ))(s) } @@ -1390,10 +1404,14 @@ pub fn sequence_lvar_port_direction(s: Span) -> IResult IResult { alt(( map(data_type_or_implicit, |x| { - SequenceFormalType::DataTypeOrImplicit(x) + SequenceFormalType::DataTypeOrImplicit(Box::new(x)) + }), + map(keyword("sequence"), |x| { + SequenceFormalType::Sequence(Box::new(x)) + }), + map(keyword("untyped"), |x| { + SequenceFormalType::Untyped(Box::new(x)) }), - map(keyword("sequence"), |x| SequenceFormalType::Sequence(x)), - map(keyword("untyped"), |x| SequenceFormalType::Untyped(x)), ))(s) } @@ -1446,7 +1464,7 @@ pub fn sequence_expr_expression(s: Span) -> IResult { let (s, b) = opt(boolean_abbrev)(s)?; Ok(( s, - SequenceExpr::Expression(SequenceExprExpression { nodes: (a, b) }), + SequenceExpr::Expression(Box::new(SequenceExprExpression { nodes: (a, b) })), )) } @@ -1567,7 +1585,7 @@ pub fn cycle_delay_range_primary(s: Span) -> IResult { let (s, b) = constant_primary(s)?; Ok(( s, - CycleDelayRange::Primary(CycleDelayRangePrimary { nodes: (a, b) }), + CycleDelayRange::Primary(Box::new(CycleDelayRangePrimary { nodes: (a, b) })), )) } @@ -1577,7 +1595,7 @@ pub fn cycle_delay_range_expression(s: Span) -> IResult { let (s, b) = bracket(cycle_delay_const_range_expression)(s)?; Ok(( s, - CycleDelayRange::Expression(CycleDelayRangeExpression { nodes: (a, b) }), + CycleDelayRange::Expression(Box::new(CycleDelayRangeExpression { nodes: (a, b) })), )) } @@ -1587,7 +1605,7 @@ pub fn cycle_delay_range_asterisk(s: Span) -> IResult { let (s, b) = bracket(symbol("*"))(s)?; Ok(( s, - CycleDelayRange::Asterisk(CycleDelayRangeAsterisk { nodes: (a, b) }), + CycleDelayRange::Asterisk(Box::new(CycleDelayRangeAsterisk { nodes: (a, b) })), )) } @@ -1597,7 +1615,7 @@ pub fn cycle_delay_range_plus(s: Span) -> IResult { let (s, b) = bracket(symbol("+"))(s)?; Ok(( s, - CycleDelayRange::Plus(CycleDelayRangePlus { nodes: (a, b) }), + CycleDelayRange::Plus(Box::new(CycleDelayRangePlus { nodes: (a, b) })), )) } @@ -1613,12 +1631,14 @@ pub fn sequence_method_call(s: Span) -> IResult { pub fn sequence_match_item(s: Span) -> IResult { alt(( map(operator_assignment, |x| { - SequenceMatchItem::OperatorAssignment(x) + SequenceMatchItem::OperatorAssignment(Box::new(x)) }), map(inc_or_dec_expression, |x| { - SequenceMatchItem::IncOrDecExpression(x) + SequenceMatchItem::IncOrDecExpression(Box::new(x)) + }), + map(subroutine_call, |x| { + SequenceMatchItem::SubroutineCall(Box::new(x)) }), - map(subroutine_call, |x| SequenceMatchItem::SubroutineCall(x)), ))(s) } @@ -1648,7 +1668,9 @@ pub fn sequence_list_of_arguments_ordered(s: Span) -> IResult IResult IResult { alt(( - map(event_expression, |x| SequenceActualArg::EventExpression(x)), - map(sequence_expr, |x| SequenceActualArg::SequenceExpr(x)), + map(event_expression, |x| { + SequenceActualArg::EventExpression(Box::new(x)) + }), + map(sequence_expr, |x| { + SequenceActualArg::SequenceExpr(Box::new(x)) + }), ))(s) } @@ -1676,12 +1702,14 @@ pub fn sequence_actual_arg(s: Span) -> IResult { pub fn boolean_abbrev(s: Span) -> IResult { alt(( map(consecutive_repetition, |x| { - BooleanAbbrev::ConsecutiveRepetition(x) + BooleanAbbrev::ConsecutiveRepetition(Box::new(x)) }), map(non_consecutive_repetition, |x| { - BooleanAbbrev::NonConsecutiveRepetition(x) + BooleanAbbrev::NonConsecutiveRepetition(Box::new(x)) + }), + map(goto_repetition, |x| { + BooleanAbbrev::GotoRepetition(Box::new(x)) }), - map(goto_repetition, |x| BooleanAbbrev::GotoRepetition(x)), ))(s) } @@ -1705,7 +1733,9 @@ pub fn consecutive_repetition_expression(s: Span) -> IResult IResult IResult IResult { pub fn const_or_range_expression(s: Span) -> IResult { alt(( map(constant_expression, |x| { - ConstOrRangeExpression::ConstantExpression(x) + ConstOrRangeExpression::ConstantExpression(Box::new(x)) }), map(cycle_delay_const_range_expression, |x| { - ConstOrRangeExpression::CycleDelayConstRangeExpression(x) + ConstOrRangeExpression::CycleDelayConstRangeExpression(Box::new(x)) }), ))(s) } @@ -1770,9 +1800,9 @@ pub fn cycle_delay_const_range_expression_binary( let (s, c) = constant_expression(s)?; Ok(( s, - CycleDelayConstRangeExpression::Binary(CycleDelayConstRangeExpressionBinary { + CycleDelayConstRangeExpression::Binary(Box::new(CycleDelayConstRangeExpressionBinary { nodes: (a, b, c), - }), + })), )) } @@ -1785,9 +1815,9 @@ pub fn cycle_delay_const_range_expression_dollar( let (s, c) = symbol("$")(s)?; Ok(( s, - CycleDelayConstRangeExpression::Dollar(CycleDelayConstRangeExpressionDollar { + CycleDelayConstRangeExpression::Dollar(Box::new(CycleDelayConstRangeExpressionDollar { nodes: (a, b, c), - }), + })), )) } diff --git a/src/parser/declarations/block_item_declarations.rs b/src/parser/declarations/block_item_declarations.rs index d248f77..07d55ca 100644 --- a/src/parser/declarations/block_item_declarations.rs +++ b/src/parser/declarations/block_item_declarations.rs @@ -8,10 +8,10 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum BlockItemDeclaration { - Data(BlockItemDeclarationData), - LocalParameter(BlockItemDeclarationLocalParameter), - Parameter(BlockItemDeclarationParameter), - Let(BlockItemDeclarationLet), + Data(Box), + LocalParameter(Box), + Parameter(Box), + Let(Box), } #[derive(Clone, Debug, Node)] @@ -52,7 +52,7 @@ pub fn block_item_declaration_data(s: Span) -> IResult IResult IResult IResult), + Option(Box), } #[derive(Clone, Debug, Node)] @@ -40,8 +40,8 @@ pub struct CoverageSpecOrOptionOption { #[derive(Clone, Debug, Node)] pub enum CoverageOption { - Option(CoverageOptionOption), - TypeOption(CoverageOptionTypeOption), + Option(Box), + TypeOption(Box), } #[derive(Clone, Debug, Node)] @@ -62,15 +62,15 @@ pub struct CoverageOptionTypeOption { #[derive(Clone, Debug, Node)] pub enum CoverageSpec { - CoverPoint(CoverPoint), - CoverCross(CoverCross), + CoverPoint(Box), + CoverCross(Box), } #[derive(Clone, Debug, Node)] pub enum CoverageEvent { - ClockingEvent(ClockingEvent), - Sample(CoverageEventSample), - At(CoverageEventAt), + ClockingEvent(Box), + Sample(Box), + At(Box), } #[derive(Clone, Debug, Node)] @@ -86,8 +86,8 @@ pub struct CoverageEventAt { #[derive(Clone, Debug, Node)] pub enum BlockEventExpression { Or(Box), - Begin(BlockEventExpressionBegin), - End(BlockEventExpressionEnd), + Begin(Box), + End(Box), } #[derive(Clone, Debug, Node)] @@ -107,9 +107,9 @@ pub struct BlockEventExpressionEnd { #[derive(Clone, Debug, Node)] pub enum HierarchicalBtfIdentifier { - HierarchicalTfIdentifier(HierarchicalTfIdentifier), - HierarchicalBlockIdentifier(HierarchicalBlockIdentifier), - Method(HierarchicalBtfIdentifierMethod), + HierarchicalTfIdentifier(Box), + HierarchicalBlockIdentifier(Box), + Method(Box), } #[derive(Clone, Debug, Node)] @@ -119,8 +119,8 @@ pub struct HierarchicalBtfIdentifierMethod { #[derive(Clone, Debug, Node)] pub enum HierarchicalIdentifierOrClassScope { - HierarchicalIdentifier((HierarchicalIdentifier, Symbol)), - ClassScope(ClassScope), + HierarchicalIdentifier(Box<(HierarchicalIdentifier, Symbol)>), + ClassScope(Box), } #[derive(Clone, Debug, Node)] @@ -136,8 +136,8 @@ pub struct CoverPoint { #[derive(Clone, Debug, Node)] pub enum BinsOrEmpty { - NonEmpty(BinsOrEmptyNonEmpty), - Empty(Symbol), + NonEmpty(Box), + Empty(Box), } #[derive(Clone, Debug, Node)] @@ -147,13 +147,13 @@ pub struct BinsOrEmptyNonEmpty { #[derive(Clone, Debug, Node)] pub enum BinsOrOptions { - CoverageOption(CoverageOption), - Covergroup(BinsOrOptionsCovergroup), - CoverPoint(BinsOrOptionsCoverPoint), - SetCovergroup(BinsOrOptionsSetCovergroup), - TransList(BinsOrOptionsTransList), - Default(BinsOrOptionsDefault), - DefaultSequence(BinsOrOptionsDefaultSequence), + CoverageOption(Box), + Covergroup(Box), + CoverPoint(Box), + SetCovergroup(Box), + TransList(Box), + Default(Box), + DefaultSequence(Box), } #[derive(Clone, Debug, Node)] @@ -242,9 +242,9 @@ pub struct BinsOrOptionsDefaultSequence { #[derive(Clone, Debug, Node)] pub enum BinsKeyword { - Bins(Keyword), - IllegalBins(Keyword), - IgnoreBins(Keyword), + Bins(Box), + IllegalBins(Box), + IgnoreBins(Box), } #[derive(Clone, Debug, Node)] @@ -259,10 +259,10 @@ pub struct TransSet { #[derive(Clone, Debug, Node)] pub enum TransRangeList { - TransItem(TransItem), - Asterisk(TransRangeListAsterisk), - Arrow(TransRangeListArrow), - Equal(TransRangeListEqual), + TransItem(Box), + Asterisk(Box), + Arrow(Box), + Equal(Box), } #[derive(Clone, Debug, Node)] @@ -287,8 +287,8 @@ pub struct TransItem { #[derive(Clone, Debug, Node)] pub enum RepeatRange { - CovergroupExpression(CovergroupExpression), - Binary(RepeatRangeBinary), + CovergroupExpression(Box), + Binary(Box), } #[derive(Clone, Debug, Node)] @@ -314,14 +314,14 @@ pub struct ListOfCrossItems { #[derive(Clone, Debug, Node)] pub enum CrossItem { - CoverPointIdentifier(CoverPointIdentifier), - VariableIdentifier(VariableIdentifier), + CoverPointIdentifier(Box), + VariableIdentifier(Box), } #[derive(Clone, Debug, Node)] pub enum CrossBody { - NonEmpty(CrossBodyNonEmpty), - Empty(Symbol), + NonEmpty(Box), + Empty(Box), } #[derive(Clone, Debug, Node)] @@ -331,14 +331,14 @@ pub struct CrossBodyNonEmpty { #[derive(Clone, Debug, Node)] pub enum CrossBodyItem { - FunctionDeclaration(FunctionDeclaration), - BinsSelectionOrOption((BinsSelectionOrOption, Symbol)), + FunctionDeclaration(Box), + BinsSelectionOrOption(Box<(BinsSelectionOrOption, Symbol)>), } #[derive(Clone, Debug, Node)] pub enum BinsSelectionOrOption { - Coverage(BinsSelectionOrOptionCoverage), - Bins(BinsSelectionOrOptionBins), + Coverage(Box), + Bins(Box), } #[derive(Clone, Debug, Node)] @@ -364,14 +364,14 @@ pub struct BinsSelection { #[derive(Clone, Debug, Node)] pub enum SelectExpression { - SelectCondition(SelectCondition), - Not(SelectExpressionNot), + SelectCondition(Box), + Not(Box), And(Box), Or(Box), Paren(Box), With(Box), - CrossIdentifier(CrossIdentifier), - CrossSet(SelectExpressionCrossSet), + CrossIdentifier(Box), + CrossSet(Box), } #[derive(Clone, Debug, Node)] @@ -423,8 +423,8 @@ pub struct SelectCondition { #[derive(Clone, Debug, Node)] pub enum BinsExpression { - VariableIdentifier(VariableIdentifier), - CoverPoint(BinsExpressionCoverPoint), + VariableIdentifier(Box), + CoverPoint(Box), } #[derive(Clone, Debug, Node)] @@ -439,8 +439,8 @@ pub struct CovergroupRangeList { #[derive(Clone, Debug, Node)] pub enum CovergroupValueRange { - CovergroupExpression(CovergroupExpression), - Binary(CovergroupValueRangeBinary), + CovergroupExpression(Box), + Binary(Box), } #[derive(Clone, Debug, Node)] @@ -504,7 +504,7 @@ pub fn coverage_spec_or_option_spec(s: Span) -> IResult IResult IResult { let (s, e) = expression(s)?; Ok(( s, - CoverageOption::Option(CoverageOptionOption { + CoverageOption::Option(Box::new(CoverageOptionOption { nodes: (a, b, c, d, e), - }), + })), )) } @@ -548,24 +548,26 @@ pub fn coverage_option_type_option(s: Span) -> IResult { let (s, e) = constant_expression(s)?; Ok(( s, - CoverageOption::TypeOption(CoverageOptionTypeOption { + CoverageOption::TypeOption(Box::new(CoverageOptionTypeOption { nodes: (a, b, c, d, e), - }), + })), )) } #[parser] pub fn coverage_spec(s: Span) -> IResult { alt(( - map(cover_point, |x| CoverageSpec::CoverPoint(x)), - map(cover_cross, |x| CoverageSpec::CoverCross(x)), + map(cover_point, |x| CoverageSpec::CoverPoint(Box::new(x))), + map(cover_cross, |x| CoverageSpec::CoverCross(Box::new(x))), ))(s) } #[parser] pub fn coverage_event(s: Span) -> IResult { alt(( - map(clocking_event, |x| CoverageEvent::ClockingEvent(x)), + map(clocking_event, |x| { + CoverageEvent::ClockingEvent(Box::new(x)) + }), coverage_event_sample, coverage_event_at, ))(s) @@ -579,9 +581,9 @@ pub fn coverage_event_sample(s: Span) -> IResult { let (s, d) = paren(opt(tf_port_list))(s)?; Ok(( s, - CoverageEvent::Sample(CoverageEventSample { + CoverageEvent::Sample(Box::new(CoverageEventSample { nodes: (a, b, c, d), - }), + })), )) } @@ -589,7 +591,10 @@ pub fn coverage_event_sample(s: Span) -> IResult { pub fn coverage_event_at(s: Span) -> IResult { let (s, a) = symbol("@@")(s)?; let (s, b) = paren(block_event_expression)(s)?; - Ok((s, CoverageEvent::At(CoverageEventAt { nodes: (a, b) }))) + Ok(( + s, + CoverageEvent::At(Box::new(CoverageEventAt { nodes: (a, b) })), + )) } #[parser] @@ -618,7 +623,7 @@ pub fn block_event_expression_begin(s: Span) -> IResult IResult IResult IResult { alt(( map(hierarchical_tf_identifier, |x| { - HierarchicalBtfIdentifier::HierarchicalTfIdentifier(x) + HierarchicalBtfIdentifier::HierarchicalTfIdentifier(Box::new(x)) }), map(hierarchical_block_identifier, |x| { - HierarchicalBtfIdentifier::HierarchicalBlockIdentifier(x) + HierarchicalBtfIdentifier::HierarchicalBlockIdentifier(Box::new(x)) }), hierarchical_btf_identifier_method, ))(s) @@ -651,7 +656,9 @@ pub fn hierarchical_btf_identifier_method(s: Span) -> IResult IResult { alt(( map(pair(hierarchical_identifier, symbol(".")), |x| { - HierarchicalIdentifierOrClassScope::HierarchicalIdentifier(x) + HierarchicalIdentifierOrClassScope::HierarchicalIdentifier(Box::new(x)) }), map(class_scope, |x| { - HierarchicalIdentifierOrClassScope::ClassScope(x) + HierarchicalIdentifierOrClassScope::ClassScope(Box::new(x)) }), ))(s) } @@ -692,7 +699,7 @@ pub fn cover_point(s: Span) -> IResult { pub fn bins_or_empty(s: Span) -> IResult { alt(( bins_or_empty_non_empty, - map(symbol(";"), |x| BinsOrEmpty::Empty(x)), + map(symbol(";"), |x| BinsOrEmpty::Empty(Box::new(x))), ))(s) } @@ -704,14 +711,16 @@ pub fn bins_or_empty_non_empty(s: Span) -> IResult { ))(s)?; Ok(( s, - BinsOrEmpty::NonEmpty(BinsOrEmptyNonEmpty { nodes: (a,) }), + BinsOrEmpty::NonEmpty(Box::new(BinsOrEmptyNonEmpty { nodes: (a,) })), )) } #[parser] pub fn bins_or_options(s: Span) -> IResult { alt(( - map(coverage_option, |x| BinsOrOptions::CoverageOption(x)), + map(coverage_option, |x| { + BinsOrOptions::CoverageOption(Box::new(x)) + }), bins_or_options_covergroup, bins_or_options_cover_point, bins_or_options_set_covergroup, @@ -733,9 +742,9 @@ pub fn bins_or_options_covergroup(s: Span) -> IResult { let (s, h) = opt(pair(keyword("iff"), paren(expression)))(s)?; Ok(( s, - BinsOrOptions::Covergroup(BinsOrOptionsCovergroup { + BinsOrOptions::Covergroup(Box::new(BinsOrOptionsCovergroup { nodes: (a, b, c, d, e, f, g, h), - }), + })), )) } @@ -758,9 +767,9 @@ pub fn bins_or_options_cover_point(s: Span) -> IResult { let (s, i) = opt(pair(keyword("iff"), paren(expression)))(s)?; Ok(( s, - BinsOrOptions::CoverPoint(BinsOrOptionsCoverPoint { + BinsOrOptions::CoverPoint(Box::new(BinsOrOptionsCoverPoint { nodes: (a, b, c, d, e, f, g, h, i), - }), + })), )) } @@ -775,9 +784,9 @@ pub fn bins_or_options_set_covergroup(s: Span) -> IResult { let (s, g) = opt(pair(keyword("iff"), paren(expression)))(s)?; Ok(( s, - BinsOrOptions::SetCovergroup(BinsOrOptionsSetCovergroup { + BinsOrOptions::SetCovergroup(Box::new(BinsOrOptionsSetCovergroup { nodes: (a, b, c, d, e, f, g), - }), + })), )) } @@ -792,9 +801,9 @@ pub fn bins_or_options_trans_list(s: Span) -> IResult { let (s, g) = opt(pair(keyword("iff"), paren(expression)))(s)?; Ok(( s, - BinsOrOptions::TransList(BinsOrOptionsTransList { + BinsOrOptions::TransList(Box::new(BinsOrOptionsTransList { nodes: (a, b, c, d, e, f, g), - }), + })), )) } @@ -808,9 +817,9 @@ pub fn bins_or_options_default(s: Span) -> IResult { let (s, f) = opt(pair(keyword("iff"), paren(expression)))(s)?; Ok(( s, - BinsOrOptions::Default(BinsOrOptionsDefault { + BinsOrOptions::Default(Box::new(BinsOrOptionsDefault { nodes: (a, b, c, d, e, f), - }), + })), )) } @@ -824,18 +833,22 @@ pub fn bins_or_options_default_sequence(s: Span) -> IResult let (s, f) = opt(pair(keyword("iff"), paren(expression)))(s)?; Ok(( s, - BinsOrOptions::DefaultSequence(BinsOrOptionsDefaultSequence { + BinsOrOptions::DefaultSequence(Box::new(BinsOrOptionsDefaultSequence { nodes: (a, b, c, d, e, f), - }), + })), )) } #[parser] pub fn bins_keyword(s: Span) -> IResult { alt(( - map(keyword("bins"), |x| BinsKeyword::Bins(x)), - map(keyword("illegal_bins"), |x| BinsKeyword::IllegalBins(x)), - map(keyword("ignore_bins"), |x| BinsKeyword::IgnoreBins(x)), + map(keyword("bins"), |x| BinsKeyword::Bins(Box::new(x))), + map(keyword("illegal_bins"), |x| { + BinsKeyword::IllegalBins(Box::new(x)) + }), + map(keyword("ignore_bins"), |x| { + BinsKeyword::IgnoreBins(Box::new(x)) + }), ))(s) } @@ -854,7 +867,7 @@ pub fn trans_set(s: Span) -> IResult { #[parser] pub fn trans_range_list(s: Span) -> IResult { alt(( - map(trans_item, |x| TransRangeList::TransItem(x)), + map(trans_item, |x| TransRangeList::TransItem(Box::new(x))), trans_range_list_asterisk, trans_range_list_arrow, trans_range_list_equal, @@ -867,7 +880,7 @@ pub fn trans_range_list_asterisk(s: Span) -> IResult { let (s, b) = bracket(pair(symbol("*"), repeat_range))(s)?; Ok(( s, - TransRangeList::Asterisk(TransRangeListAsterisk { nodes: (a, b) }), + TransRangeList::Asterisk(Box::new(TransRangeListAsterisk { nodes: (a, b) })), )) } @@ -877,7 +890,7 @@ pub fn trans_range_list_arrow(s: Span) -> IResult { let (s, b) = bracket(pair(symbol("->"), repeat_range))(s)?; Ok(( s, - TransRangeList::Arrow(TransRangeListArrow { nodes: (a, b) }), + TransRangeList::Arrow(Box::new(TransRangeListArrow { nodes: (a, b) })), )) } @@ -887,7 +900,7 @@ pub fn trans_range_list_equal(s: Span) -> IResult { let (s, b) = bracket(pair(symbol("="), repeat_range))(s)?; Ok(( s, - TransRangeList::Equal(TransRangeListEqual { nodes: (a, b) }), + TransRangeList::Equal(Box::new(TransRangeListEqual { nodes: (a, b) })), )) } @@ -901,7 +914,7 @@ pub fn trans_item(s: Span) -> IResult { pub fn repeat_range(s: Span) -> IResult { alt(( map(covergroup_expression, |x| { - RepeatRange::CovergroupExpression(x) + RepeatRange::CovergroupExpression(Box::new(x)) }), repeat_range_binary, ))(s) @@ -914,7 +927,7 @@ pub fn repeat_range_binary(s: Span) -> IResult { let (s, c) = covergroup_expression(s)?; Ok(( s, - RepeatRange::Binary(RepeatRangeBinary { nodes: (a, b, c) }), + RepeatRange::Binary(Box::new(RepeatRangeBinary { nodes: (a, b, c) })), )) } @@ -944,9 +957,11 @@ pub fn list_of_cross_items(s: Span) -> IResult { pub fn cross_item(s: Span) -> IResult { alt(( map(cover_point_identifier, |x| { - CrossItem::CoverPointIdentifier(x) + CrossItem::CoverPointIdentifier(Box::new(x)) + }), + map(variable_identifier, |x| { + CrossItem::VariableIdentifier(Box::new(x)) }), - map(variable_identifier, |x| CrossItem::VariableIdentifier(x)), ))(s) } @@ -954,24 +969,27 @@ pub fn cross_item(s: Span) -> IResult { pub fn cross_body(s: Span) -> IResult { alt(( cross_body_non_empty, - map(symbol(";"), |x| CrossBody::Empty(x)), + map(symbol(";"), |x| CrossBody::Empty(Box::new(x))), ))(s) } #[parser] pub fn cross_body_non_empty(s: Span) -> IResult { let (s, a) = brace(many0(pair(cross_body_item, symbol(";"))))(s)?; - Ok((s, CrossBody::NonEmpty(CrossBodyNonEmpty { nodes: (a,) }))) + Ok(( + s, + CrossBody::NonEmpty(Box::new(CrossBodyNonEmpty { nodes: (a,) })), + )) } #[parser] pub fn cross_body_item(s: Span) -> IResult { alt(( map(function_declaration, |x| { - CrossBodyItem::FunctionDeclaration(x) + CrossBodyItem::FunctionDeclaration(Box::new(x)) }), map(pair(bins_selection_or_option, symbol(";")), |x| { - CrossBodyItem::BinsSelectionOrOption(x) + CrossBodyItem::BinsSelectionOrOption(Box::new(x)) }), ))(s) } @@ -990,7 +1008,7 @@ pub fn bins_selection_or_option_coverage(s: Span) -> IResult IResult IResult { #[parser] pub fn select_expression(s: Span) -> IResult { alt(( - map(select_condition, |x| SelectExpression::SelectCondition(x)), + map(select_condition, |x| { + SelectExpression::SelectCondition(Box::new(x)) + }), select_expression_not, select_expression_and, select_expression_or, select_expression_paren, select_expression_with, - map(cross_identifier, |x| SelectExpression::CrossIdentifier(x)), + map(cross_identifier, |x| { + SelectExpression::CrossIdentifier(Box::new(x)) + }), select_expression_cross_set, ))(s) } @@ -1039,7 +1061,7 @@ pub fn select_expression_not(s: Span) -> IResult { let (s, b) = select_condition(s)?; Ok(( s, - SelectExpression::Not(SelectExpressionNot { nodes: (a, b) }), + SelectExpression::Not(Box::new(SelectExpressionNot { nodes: (a, b) })), )) } @@ -1094,7 +1116,7 @@ pub fn select_expression_cross_set(s: Span) -> IResult { let (s, b) = opt(pair(keyword("matches"), integer_covergroup_expression))(s)?; Ok(( s, - SelectExpression::CrossSet(SelectExpressionCrossSet { nodes: (a, b) }), + SelectExpression::CrossSet(Box::new(SelectExpressionCrossSet { nodes: (a, b) })), )) } @@ -1110,7 +1132,7 @@ pub fn select_condition(s: Span) -> IResult { pub fn bins_expression(s: Span) -> IResult { alt(( map(variable_identifier, |x| { - BinsExpression::VariableIdentifier(x) + BinsExpression::VariableIdentifier(Box::new(x)) }), bins_expression_cover_point, ))(s) @@ -1122,7 +1144,7 @@ pub fn bins_expression_cover_point(s: Span) -> IResult { let (s, b) = opt(pair(symbol("."), bin_identifier))(s)?; Ok(( s, - BinsExpression::CoverPoint(BinsExpressionCoverPoint { nodes: (a, b) }), + BinsExpression::CoverPoint(Box::new(BinsExpressionCoverPoint { nodes: (a, b) })), )) } @@ -1136,7 +1158,7 @@ pub fn covergroup_range_list(s: Span) -> IResult { pub fn covergroup_value_range(s: Span) -> IResult { alt(( map(covergroup_expression, |x| { - CovergroupValueRange::CovergroupExpression(x) + CovergroupValueRange::CovergroupExpression(Box::new(x)) }), covergroup_value_range_binary, ))(s) @@ -1151,7 +1173,7 @@ pub fn covergroup_value_range_binary(s: Span) -> IResult), + PulseControlSpecparam(Box), } #[derive(Clone, Debug, Node)] @@ -53,8 +53,8 @@ pub struct TypeAssignment { #[derive(Clone, Debug, Node)] pub enum PulseControlSpecparam { - WithoutDescriptor(PulseControlSpecparamWithoutDescriptor), - WithDescriptor(PulseControlSpecparamWithDescriptor), + WithoutDescriptor(Box), + WithDescriptor(Box), } #[derive(Clone, Debug, Node)] @@ -95,9 +95,9 @@ pub struct LimitValue { #[derive(Clone, Debug, Node)] pub enum VariableDeclAssignment { - Variable(VariableDeclAssignmentVariable), - DynamicArray(VariableDeclAssignmentDynamicArray), - Class(VariableDeclAssignmentClass), + Variable(Box), + DynamicArray(Box), + Class(Box), } #[derive(Clone, Debug, Node)] @@ -126,8 +126,8 @@ pub struct VariableDeclAssignmentClass { #[derive(Clone, Debug, Node)] pub enum ClassNew { - Argument(ClassNewArgument), - Expression(ClassNewExpression), + Argument(Box), + Expression(Box), } #[derive(Clone, Debug, Node)] @@ -176,7 +176,7 @@ pub fn specparam_assignment(s: Span) -> IResult { alt(( specparam_assignment_mintypmax, map(pulse_control_specparam, |x| { - SpecparamAssignment::PulseControlSpecparam(x) + SpecparamAssignment::PulseControlSpecparam(Box::new(x)) }), ))(s) } @@ -188,7 +188,7 @@ pub fn specparam_assignment_mintypmax(s: Span) -> IResult IResult IResult IResult IResult IResult IResult { let (s, a) = opt(class_scope)(s)?; let (s, b) = keyword("new")(s)?; let (s, c) = opt(paren(list_of_arguments))(s)?; - Ok((s, ClassNew::Argument(ClassNewArgument { nodes: (a, b, c) }))) + Ok(( + s, + ClassNew::Argument(Box::new(ClassNewArgument { nodes: (a, b, c) })), + )) } #[parser] @@ -323,7 +328,7 @@ pub fn class_new_expression(s: Span) -> IResult { let (s, b) = expression(s)?; Ok(( s, - ClassNew::Expression(ClassNewExpression { nodes: (a, b) }), + ClassNew::Expression(Box::new(ClassNewExpression { nodes: (a, b) })), )) } diff --git a/src/parser/declarations/declaration_ranges.rs b/src/parser/declarations/declaration_ranges.rs index 28e30a3..bc36fb1 100644 --- a/src/parser/declarations/declaration_ranges.rs +++ b/src/parser/declarations/declaration_ranges.rs @@ -9,8 +9,8 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum UnpackedDimension { - Range(UnpackedDimensionRange), - Expression(UnpackedDimensionExpression), + Range(Box), + Expression(Box), } #[derive(Clone, Debug, Node)] @@ -25,8 +25,8 @@ pub struct UnpackedDimensionExpression { #[derive(Clone, Debug, Node)] pub enum PackedDimension { - Range(PackedDimensionRange), - UnsizedDimension(UnsizedDimension), + Range(Box), + UnsizedDimension(Box), } #[derive(Clone, Debug, Node)] @@ -36,8 +36,8 @@ pub struct PackedDimensionRange { #[derive(Clone, Debug, Node)] pub enum AssociativeDimension { - DataType(AssociativeDimensionDataType), - Asterisk(AssociativeDimensionAsterisk), + DataType(Box), + Asterisk(Box), } #[derive(Clone, Debug, Node)] @@ -52,10 +52,10 @@ pub struct AssociativeDimensionAsterisk { #[derive(Clone, Debug, Node)] pub enum VariableDimension { - UnsizedDimension(UnsizedDimension), - UnpackedDimension(UnpackedDimension), - AssociativeDimension(AssociativeDimension), - QueueDimension(QueueDimension), + UnsizedDimension(Box), + UnpackedDimension(Box), + AssociativeDimension(Box), + QueueDimension(Box), } #[derive(Clone, Debug, Node)] @@ -80,7 +80,7 @@ pub fn unpacked_dimension_range(s: Span) -> IResult { let (s, a) = bracket(constant_range)(s)?; Ok(( s, - UnpackedDimension::Range(UnpackedDimensionRange { nodes: (a,) }), + UnpackedDimension::Range(Box::new(UnpackedDimensionRange { nodes: (a,) })), )) } @@ -89,7 +89,7 @@ pub fn unpacked_dimension_expression(s: Span) -> IResult IResult IResult { alt(( packed_dimension_range, - map(unsized_dimension, |x| PackedDimension::UnsizedDimension(x)), + map(unsized_dimension, |x| { + PackedDimension::UnsizedDimension(Box::new(x)) + }), ))(s) } @@ -106,7 +108,7 @@ pub fn packed_dimension_range(s: Span) -> IResult { let (s, a) = bracket(constant_range)(s)?; Ok(( s, - PackedDimension::Range(PackedDimensionRange { nodes: (a,) }), + PackedDimension::Range(Box::new(PackedDimensionRange { nodes: (a,) })), )) } @@ -123,7 +125,7 @@ pub fn associative_dimension_data_type(s: Span) -> IResult IResult IResult IResult { alt(( map(unsized_dimension, |x| { - VariableDimension::UnsizedDimension(x) + VariableDimension::UnsizedDimension(Box::new(x)) }), map(unpacked_dimension, |x| { - VariableDimension::UnpackedDimension(x) + VariableDimension::UnpackedDimension(Box::new(x)) }), map(associative_dimension, |x| { - VariableDimension::AssociativeDimension(x) + VariableDimension::AssociativeDimension(Box::new(x)) + }), + map(queue_dimension, |x| { + VariableDimension::QueueDimension(Box::new(x)) }), - map(queue_dimension, |x| VariableDimension::QueueDimension(x)), ))(s) } diff --git a/src/parser/declarations/delays.rs b/src/parser/declarations/delays.rs index c42bae4..b48cbe8 100644 --- a/src/parser/declarations/delays.rs +++ b/src/parser/declarations/delays.rs @@ -9,8 +9,8 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum Delay3 { - Single(Delay3Single), - Mintypmax(Delay3Mintypmax), + Single(Box), + Mintypmax(Box), } #[derive(Clone, Debug, Node)] @@ -35,8 +35,8 @@ pub struct Delay3Mintypmax { #[derive(Clone, Debug, Node)] pub enum Delay2 { - Single(Delay2Single), - Mintypmax(Delay2Mintypmax), + Single(Box), + Mintypmax(Box), } #[derive(Clone, Debug, Node)] @@ -54,11 +54,11 @@ pub struct Delay2Mintypmax { #[derive(Clone, Debug, Node)] pub enum DelayValue { - UnsignedNumber(UnsignedNumber), - RealNumber(RealNumber), - PsIdentifier(PsIdentifier), - TimeLiteral(TimeLiteral), - Step1(Keyword), + UnsignedNumber(Box), + RealNumber(Box), + PsIdentifier(Box), + TimeLiteral(Box), + Step1(Box), } // ----------------------------------------------------------------------------- @@ -72,7 +72,7 @@ pub fn delay3(s: Span) -> IResult { pub fn delay3_single(s: Span) -> IResult { let (s, a) = symbol("#")(s)?; let (s, b) = delay_value(s)?; - Ok((s, Delay3::Single(Delay3Single { nodes: (a, b) }))) + Ok((s, Delay3::Single(Box::new(Delay3Single { nodes: (a, b) })))) } #[parser] @@ -86,7 +86,10 @@ pub fn delay3_mintypmax(s: Span) -> IResult { opt(pair(symbol(","), mintypmax_expression)), )), ))(s)?; - Ok((s, Delay3::Mintypmax(Delay3Mintypmax { nodes: (a, b) }))) + Ok(( + s, + Delay3::Mintypmax(Box::new(Delay3Mintypmax { nodes: (a, b) })), + )) } #[parser] @@ -98,7 +101,7 @@ pub fn delay2(s: Span) -> IResult { pub fn delay2_single(s: Span) -> IResult { let (s, a) = symbol("#")(s)?; let (s, b) = delay_value(s)?; - Ok((s, Delay2::Single(Delay2Single { nodes: (a, b) }))) + Ok((s, Delay2::Single(Box::new(Delay2Single { nodes: (a, b) })))) } #[parser] @@ -108,16 +111,19 @@ pub fn delay2_mintypmax(s: Span) -> IResult { mintypmax_expression, opt(pair(symbol(","), mintypmax_expression)), ))(s)?; - Ok((s, Delay2::Mintypmax(Delay2Mintypmax { nodes: (a, b) }))) + Ok(( + s, + Delay2::Mintypmax(Box::new(Delay2Mintypmax { nodes: (a, b) })), + )) } #[parser] pub fn delay_value(s: Span) -> IResult { alt(( - map(unsigned_number, |x| DelayValue::UnsignedNumber(x)), - map(real_number, |x| DelayValue::RealNumber(x)), - map(ps_identifier, |x| DelayValue::PsIdentifier(x)), - map(time_literal, |x| DelayValue::TimeLiteral(x)), - map(keyword("1step"), |x| DelayValue::Step1(x)), + map(unsigned_number, |x| DelayValue::UnsignedNumber(Box::new(x))), + map(real_number, |x| DelayValue::RealNumber(Box::new(x))), + map(ps_identifier, |x| DelayValue::PsIdentifier(Box::new(x))), + map(time_literal, |x| DelayValue::TimeLiteral(Box::new(x))), + map(keyword("1step"), |x| DelayValue::Step1(Box::new(x))), ))(s) } diff --git a/src/parser/declarations/function_declarations.rs b/src/parser/declarations/function_declarations.rs index 89ad295..928ed19 100644 --- a/src/parser/declarations/function_declarations.rs +++ b/src/parser/declarations/function_declarations.rs @@ -10,8 +10,8 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum FunctionDataTypeOrImplicit { - DataTypeOrVoid(DataTypeOrVoid), - ImplicitDataType(ImplicitDataType), + DataTypeOrVoid(Box), + ImplicitDataType(Box), } #[derive(Clone, Debug, Node)] @@ -21,8 +21,8 @@ pub struct FunctionDeclaration { #[derive(Clone, Debug, Node)] pub enum FunctionBodyDeclaration { - WithoutPort(FunctionBodyDeclarationWithoutPort), - WithPort(FunctionBodyDeclarationWithPort), + WithoutPort(Box), + WithPort(Box), } #[derive(Clone, Debug, Node)] @@ -56,8 +56,8 @@ pub struct FunctionBodyDeclarationWithPort { #[derive(Clone, Debug, Node)] pub enum InterfaceIdentifierOrClassScope { - InterfaceIdentifier((InterfaceIdentifier, Symbol)), - ClassScope(ClassScope), + InterfaceIdentifier(Box<(InterfaceIdentifier, Symbol)>), + ClassScope(Box), } #[derive(Clone, Debug, Node)] @@ -72,10 +72,10 @@ pub struct FunctionPrototype { #[derive(Clone, Debug, Node)] pub enum DpiImportExport { - ImportFunction(DpiImportExportImportFunction), - ImportTask(DpiImportExportImportTask), - ExportFunction(DpiImportExportExportFunction), - ExportTask(DpiImportExportExportTask), + ImportFunction(Box), + ImportTask(Box), + ExportFunction(Box), + ExportTask(Box), } #[derive(Clone, Debug, Node)] @@ -128,19 +128,19 @@ pub struct DpiImportExportExportTask { #[derive(Clone, Debug, Node)] pub enum DpiSpecString { - DpiC(Keyword), - Dpi(Keyword), + DpiC(Box), + Dpi(Box), } #[derive(Clone, Debug, Node)] pub enum DpiFunctionImportProperty { - Context(Keyword), - Pure(Keyword), + Context(Box), + Pure(Box), } #[derive(Clone, Debug, Node)] pub enum DpiTaskImportProperty { - Context(Keyword), + Context(Box), } #[derive(Clone, Debug, Node)] @@ -159,10 +159,10 @@ pub struct DpiTaskProto { pub fn function_data_type_or_implicit(s: Span) -> IResult { alt(( map(data_type_or_void, |x| { - FunctionDataTypeOrImplicit::DataTypeOrVoid(x) + FunctionDataTypeOrImplicit::DataTypeOrVoid(Box::new(x)) }), map(implicit_data_type, |x| { - FunctionDataTypeOrImplicit::ImplicitDataType(x) + FunctionDataTypeOrImplicit::ImplicitDataType(Box::new(x)) }), ))(s) } @@ -195,9 +195,9 @@ pub fn function_body_declaration_without_port(s: Span) -> IResult IResult IResult { alt(( map(pair(interface_identifier, symbol(".")), |x| { - InterfaceIdentifierOrClassScope::InterfaceIdentifier(x) + InterfaceIdentifierOrClassScope::InterfaceIdentifier(Box::new(x)) }), map(class_scope, |x| { - InterfaceIdentifierOrClassScope::ClassScope(x) + InterfaceIdentifierOrClassScope::ClassScope(Box::new(x)) }), ))(s) } @@ -268,9 +268,9 @@ pub fn dpi_import_export_import_function(s: Span) -> IResult IResult let (s, f) = symbol(";")(s)?; Ok(( s, - DpiImportExport::ImportTask(DpiImportExportImportTask { + DpiImportExport::ImportTask(Box::new(DpiImportExportImportTask { nodes: (a, b, c, d, e, f), - }), + })), )) } @@ -300,9 +300,9 @@ pub fn dpi_import_export_export_function(s: Span) -> IResult IResult let (s, f) = symbol(";")(s)?; Ok(( s, - DpiImportExport::ExportTask(DpiImportExportExportTask { + DpiImportExport::ExportTask(Box::new(DpiImportExportExportTask { nodes: (a, b, c, d, e, f), - }), + })), )) } #[parser] pub fn dpi_spec_string(s: Span) -> IResult { alt(( - map(keyword("DPI-C"), |x| DpiSpecString::DpiC(x)), - map(keyword("DPI"), |x| DpiSpecString::Dpi(x)), + map(keyword("DPI-C"), |x| DpiSpecString::DpiC(Box::new(x))), + map(keyword("DPI"), |x| DpiSpecString::Dpi(Box::new(x))), ))(s) } @@ -334,16 +334,18 @@ pub fn dpi_spec_string(s: Span) -> IResult { pub fn dpi_function_import_property(s: Span) -> IResult { alt(( map(keyword("context"), |x| { - DpiFunctionImportProperty::Context(x) + DpiFunctionImportProperty::Context(Box::new(x)) + }), + map(keyword("pure"), |x| { + DpiFunctionImportProperty::Pure(Box::new(x)) }), - map(keyword("pure"), |x| DpiFunctionImportProperty::Pure(x)), ))(s) } #[parser] pub fn dpi_task_import_property(s: Span) -> IResult { let (s, a) = keyword("context")(s)?; - Ok((s, DpiTaskImportProperty::Context(a))) + Ok((s, DpiTaskImportProperty::Context(Box::new(a)))) } #[parser] diff --git a/src/parser/declarations/interface_declarations.rs b/src/parser/declarations/interface_declarations.rs index a770796..a55307c 100644 --- a/src/parser/declarations/interface_declarations.rs +++ b/src/parser/declarations/interface_declarations.rs @@ -22,9 +22,9 @@ pub struct ModportItem { #[derive(Clone, Debug, Node)] pub enum ModportPortsDeclaraton { - Simple(ModportPortsDeclaratonSimple), - Tf(ModportPortsDeclaratonTf), - Clocking(ModportPortsDeclaratonClocking), + Simple(Box), + Tf(Box), + Clocking(Box), } #[derive(Clone, Debug, Node)] @@ -54,8 +54,8 @@ pub struct ModportSimplePortsDeclaration { #[derive(Clone, Debug, Node)] pub enum ModportSimplePort { - Ordered(ModportSimplePortOrdered), - Named(ModportSimplePortNamed), + Ordered(Box), + Named(Box), } #[derive(Clone, Debug, Node)] @@ -75,14 +75,14 @@ pub struct ModportTfPortsDeclaration { #[derive(Clone, Debug, Node)] pub enum ModportTfPort { - MethodPrototype(MethodPrototype), - TfIdentifier(TfIdentifier), + MethodPrototype(Box), + TfIdentifier(Box), } #[derive(Clone, Debug, Node)] pub enum ImportExport { - Import(Keyword), - Export(Keyword), + Import(Box), + Export(Box), } // ----------------------------------------------------------------------------- @@ -117,7 +117,7 @@ pub fn modport_ports_declaration_simple(s: Span) -> IResult IResult IResult IResult let (s, a) = port_identifier(s)?; Ok(( s, - ModportSimplePort::Ordered(ModportSimplePortOrdered { nodes: (a,) }), + ModportSimplePort::Ordered(Box::new(ModportSimplePortOrdered { nodes: (a,) })), )) } @@ -176,7 +178,7 @@ pub fn modport_simple_port_named(s: Span) -> IResult { let (s, c) = paren(opt(expression))(s)?; Ok(( s, - ModportSimplePort::Named(ModportSimplePortNamed { nodes: (a, b, c) }), + ModportSimplePort::Named(Box::new(ModportSimplePortNamed { nodes: (a, b, c) })), )) } @@ -190,15 +192,17 @@ pub fn modport_tf_ports_declaration(s: Span) -> IResult IResult { alt(( - map(method_prototype, |x| ModportTfPort::MethodPrototype(x)), - map(tf_identifier, |x| ModportTfPort::TfIdentifier(x)), + map(method_prototype, |x| { + ModportTfPort::MethodPrototype(Box::new(x)) + }), + map(tf_identifier, |x| ModportTfPort::TfIdentifier(Box::new(x))), ))(s) } #[parser] pub fn import_export(s: Span) -> IResult { alt(( - map(keyword("import"), |x| ImportExport::Import(x)), - map(keyword("export"), |x| ImportExport::Export(x)), + map(keyword("import"), |x| ImportExport::Import(Box::new(x))), + map(keyword("export"), |x| ImportExport::Export(Box::new(x))), ))(s) } diff --git a/src/parser/declarations/let_declarations.rs b/src/parser/declarations/let_declarations.rs index 92d47f1..c010711 100644 --- a/src/parser/declarations/let_declarations.rs +++ b/src/parser/declarations/let_declarations.rs @@ -43,8 +43,8 @@ pub struct LetPortItem { #[derive(Clone, Debug, Node)] pub enum LetFormalType { - DataTypeOrImplicit(DataTypeOrImplicit), - Untyped(Keyword), + DataTypeOrImplicit(Box), + Untyped(Box), } #[derive(Clone, Debug, Node)] @@ -58,8 +58,8 @@ pub struct LetExpression { #[derive(Clone, Debug, Node)] pub enum LetListOfArguments { - Ordered(LetListOfArgumentsOrdered), - Named(LetListOfArgumentsNamed), + Ordered(Box), + Named(Box), } #[derive(Clone, Debug, Node)] @@ -129,9 +129,9 @@ pub fn let_port_item(s: Span) -> IResult { pub fn let_formal_type(s: Span) -> IResult { alt(( map(data_type_or_implicit, |x| { - LetFormalType::DataTypeOrImplicit(x) + LetFormalType::DataTypeOrImplicit(Box::new(x)) }), - map(keyword("untyped"), |x| LetFormalType::Untyped(x)), + map(keyword("untyped"), |x| LetFormalType::Untyped(Box::new(x))), ))(s) } @@ -159,7 +159,7 @@ pub fn let_list_of_arguments_ordered(s: Span) -> IResult IResult )(s)?; Ok(( s, - LetListOfArguments::Named(LetListOfArgumentsNamed { nodes: (a,) }), + LetListOfArguments::Named(Box::new(LetListOfArgumentsNamed { nodes: (a,) })), )) } diff --git a/src/parser/declarations/module_parameter_declarations.rs b/src/parser/declarations/module_parameter_declarations.rs index f64f4e3..04d5f01 100644 --- a/src/parser/declarations/module_parameter_declarations.rs +++ b/src/parser/declarations/module_parameter_declarations.rs @@ -8,8 +8,8 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum LocalParameterDeclaration { - Param(LocalParameterDeclarationParam), - Type(LocalParameterDeclarationType), + Param(Box), + Type(Box), } #[derive(Clone, Debug, Node)] @@ -24,8 +24,8 @@ pub struct LocalParameterDeclarationType { #[derive(Clone, Debug, Node)] pub enum ParameterDeclaration { - Param(ParameterDeclarationParam), - Type(ParameterDeclarationType), + Param(Box), + Type(Box), } #[derive(Clone, Debug, Node)] @@ -65,7 +65,9 @@ pub fn local_parameter_declaration_param(s: Span) -> IResult IResult IResult IResult), ConstantPrimary(Box), Signing(Box), - String(Keyword), - Const(Keyword), + String(Box), + Const(Box), } #[derive(Clone, Debug, Node)] pub enum DataType { - Vector(DataTypeVector), - Atom(DataTypeAtom), - NonIntegerType(NonIntegerType), + Vector(Box), + Atom(Box), + NonIntegerType(Box), StructUnion(Box), - Enum(DataTypeEnum), - String(Keyword), - Chandle(Keyword), - Virtual(DataTypeVirtual), - Type(DataTypeType), - ClassType(ClassType), - Event(Keyword), - PsCovergroupIdentifier(PsCovergroupIdentifier), + Enum(Box), + String(Box), + Chandle(Box), + Virtual(Box), + Type(Box), + ClassType(Box), + Event(Box), + PsCovergroupIdentifier(Box), TypeReference(Box), } @@ -97,8 +97,8 @@ pub struct DataTypeType { #[derive(Clone, Debug, Node)] pub enum DataTypeOrImplicit { - DataType(DataType), - ImplicitDataType(ImplicitDataType), + DataType(Box), + ImplicitDataType(Box), } #[derive(Clone, Debug, Node)] @@ -108,9 +108,9 @@ pub struct ImplicitDataType { #[derive(Clone, Debug, Node)] pub enum EnumBaseType { - Atom(EnumBaseTypeAtom), - Vector(EnumBaseTypeVector), - Type(EnumBaseTypeType), + Atom(Box), + Vector(Box), + Type(Box), } #[derive(Clone, Debug, Node)] @@ -153,55 +153,55 @@ pub struct ClassType { #[derive(Clone, Debug, Node)] pub enum IntegerType { - IntegerVectorType(IntegerVectorType), - IntegerAtomType(IntegerAtomType), + IntegerVectorType(Box), + IntegerAtomType(Box), } #[derive(Clone, Debug, Node)] pub enum IntegerAtomType { - Byte(Keyword), - Shortint(Keyword), - Int(Keyword), - Longint(Keyword), - Integer(Keyword), - Time(Keyword), + Byte(Box), + Shortint(Box), + Int(Box), + Longint(Box), + Integer(Box), + Time(Box), } #[derive(Clone, Debug, Node)] pub enum IntegerVectorType { - Bit(Keyword), - Logic(Keyword), - Reg(Keyword), + Bit(Box), + Logic(Box), + Reg(Box), } #[derive(Clone, Debug, Node)] pub enum NonIntegerType { - Shortreal(Keyword), - Real(Keyword), - Realtime(Keyword), + Shortreal(Box), + Real(Box), + Realtime(Box), } #[derive(Clone, Debug, Node)] pub enum NetType { - Supply0(Keyword), - Supply1(Keyword), - Tri(Keyword), - Triand(Keyword), - Trior(Keyword), - Trireg(Keyword), - Tri0(Keyword), - Tri1(Keyword), - Uwire(Keyword), - Wire(Keyword), - Wand(Keyword), - Wor(Keyword), + Supply0(Box), + Supply1(Box), + Tri(Box), + Triand(Box), + Trior(Box), + Trireg(Box), + Tri0(Box), + Tri1(Box), + Uwire(Box), + Wire(Box), + Wand(Box), + Wor(Box), } #[derive(Clone, Debug, Node)] pub enum NetPortType { - DataType(NetPortTypeDataType), - NetTypeIdentifier(NetTypeIdentifier), - Interconnect(NetPortTypeInterconnect), + DataType(Box), + NetTypeIdentifier(Box), + Interconnect(Box), } #[derive(Clone, Debug, Node)] @@ -221,8 +221,8 @@ pub struct VariablePortType { #[derive(Clone, Debug, Node)] pub enum VarDataType { - DataType(DataType), - Var(VarDataTypeVar), + DataType(Box), + Var(Box), } #[derive(Clone, Debug, Node)] @@ -232,16 +232,16 @@ pub struct VarDataTypeVar { #[derive(Clone, Debug, Node)] pub enum Signing { - Signed(Keyword), - Unsigned(Keyword), + Signed(Box), + Unsigned(Box), } #[derive(Clone, Debug, Node)] pub enum SimpleType { - IntegerType(IntegerType), - NonIntegerType(NonIntegerType), - PsTypeIdentifier(PsTypeIdentifier), - PsParameterIdentifier(PsParameterIdentifier), + IntegerType(Box), + NonIntegerType(Box), + PsTypeIdentifier(Box), + PsParameterIdentifier(Box), } #[derive(Clone, Debug, Node)] @@ -257,21 +257,21 @@ pub struct StructUnionMember { #[derive(Clone, Debug, Node)] pub enum DataTypeOrVoid { - DataType(DataType), - Void(Keyword), + DataType(Box), + Void(Box), } #[derive(Clone, Debug, Node)] pub enum StructUnion { - Struct(Keyword), - Union(Keyword), - UnionTagged((Keyword, Keyword)), + Struct(Box), + Union(Box), + UnionTagged(Box<(Keyword, Keyword)>), } #[derive(Clone, Debug, Node)] pub enum TypeReference { - Expression(TypeReferenceExpression), - DataType(TypeReferenceDataType), + Expression(Box), + DataType(Box), } #[derive(Clone, Debug, Node)] @@ -292,8 +292,8 @@ pub fn casting_type(s: Span) -> IResult { alt(( map(simple_type, |x| CastingType::SimpleType(Box::new(x))), map(signing, |x| CastingType::Signing(Box::new(x))), - map(keyword("string"), |x| CastingType::String(x)), - map(keyword("const"), |x| CastingType::Const(x)), + map(keyword("string"), |x| CastingType::String(Box::new(x))), + map(keyword("const"), |x| CastingType::Const(Box::new(x))), map(constant_primary, |x| { CastingType::ConstantPrimary(Box::new(x)) }), @@ -305,17 +305,17 @@ pub fn data_type(s: Span) -> IResult { alt(( data_type_vector, data_type_atom, - map(non_integer_type, |x| DataType::NonIntegerType(x)), + map(non_integer_type, |x| DataType::NonIntegerType(Box::new(x))), data_type_struct_union, data_type_enum, - map(keyword("string"), |x| DataType::String(x)), - map(keyword("chandle"), |x| DataType::Chandle(x)), + map(keyword("string"), |x| DataType::String(Box::new(x))), + map(keyword("chandle"), |x| DataType::Chandle(Box::new(x))), data_type_virtual, data_type_type, - map(class_type, |x| DataType::ClassType(x)), - map(keyword("event"), |x| DataType::Chandle(x)), + map(class_type, |x| DataType::ClassType(Box::new(x))), + map(keyword("event"), |x| DataType::Chandle(Box::new(x))), map(ps_covergroup_identifier, |x| { - DataType::PsCovergroupIdentifier(x) + DataType::PsCovergroupIdentifier(Box::new(x)) }), map(type_reference, |x| DataType::TypeReference(Box::new(x))), ))(s) @@ -326,14 +326,17 @@ pub fn data_type_vector(s: Span) -> IResult { let (s, a) = integer_vector_type(s)?; let (s, b) = opt(signing)(s)?; let (s, c) = many0(packed_dimension)(s)?; - Ok((s, DataType::Vector(DataTypeVector { nodes: (a, b, c) }))) + Ok(( + s, + DataType::Vector(Box::new(DataTypeVector { nodes: (a, b, c) })), + )) } #[parser] pub fn data_type_atom(s: Span) -> IResult { let (s, a) = integer_atom_type(s)?; let (s, b) = opt(signing)(s)?; - Ok((s, DataType::Atom(DataTypeAtom { nodes: (a, b) }))) + Ok((s, DataType::Atom(Box::new(DataTypeAtom { nodes: (a, b) })))) } #[parser] @@ -364,9 +367,9 @@ pub fn data_type_enum(s: Span) -> IResult { let (s, d) = many0(packed_dimension)(s)?; Ok(( s, - DataType::Enum(DataTypeEnum { + DataType::Enum(Box::new(DataTypeEnum { nodes: (a, b, c, d), - }), + })), )) } @@ -379,9 +382,9 @@ pub fn data_type_virtual(s: Span) -> IResult { let (s, e) = opt(pair(symbol("."), modport_identifier))(s)?; Ok(( s, - DataType::Virtual(DataTypeVirtual { + DataType::Virtual(Box::new(DataTypeVirtual { nodes: (a, b, c, d, e), - }), + })), )) } @@ -396,15 +399,18 @@ pub fn data_type_type(s: Span) -> IResult { let (s, a) = opt(package_scope_or_class_scope)(s)?; let (s, b) = type_identifier(s)?; let (s, c) = many0(packed_dimension)(s)?; - Ok((s, DataType::Type(DataTypeType { nodes: (a, b, c) }))) + Ok(( + s, + DataType::Type(Box::new(DataTypeType { nodes: (a, b, c) })), + )) } #[parser] pub fn data_type_or_implicit(s: Span) -> IResult { alt(( - map(data_type, |x| DataTypeOrImplicit::DataType(x)), + map(data_type, |x| DataTypeOrImplicit::DataType(Box::new(x))), map(implicit_data_type, |x| { - DataTypeOrImplicit::ImplicitDataType(x) + DataTypeOrImplicit::ImplicitDataType(Box::new(x)) }), ))(s) } @@ -429,7 +435,10 @@ pub fn enum_base_type(s: Span) -> IResult { pub fn enum_base_type_atom(s: Span) -> IResult { let (s, a) = integer_atom_type(s)?; let (s, b) = opt(signing)(s)?; - Ok((s, EnumBaseType::Atom(EnumBaseTypeAtom { nodes: (a, b) }))) + Ok(( + s, + EnumBaseType::Atom(Box::new(EnumBaseTypeAtom { nodes: (a, b) })), + )) } #[parser] @@ -439,7 +448,7 @@ pub fn enum_base_type_vector(s: Span) -> IResult { let (s, c) = opt(packed_dimension)(s)?; Ok(( s, - EnumBaseType::Vector(EnumBaseTypeVector { nodes: (a, b, c) }), + EnumBaseType::Vector(Box::new(EnumBaseTypeVector { nodes: (a, b, c) })), )) } @@ -447,7 +456,10 @@ pub fn enum_base_type_vector(s: Span) -> IResult { pub fn enum_base_type_type(s: Span) -> IResult { let (s, a) = type_identifier(s)?; let (s, b) = opt(packed_dimension)(s)?; - Ok((s, EnumBaseType::Type(EnumBaseTypeType { nodes: (a, b) }))) + Ok(( + s, + EnumBaseType::Type(Box::new(EnumBaseTypeType { nodes: (a, b) })), + )) } #[parser] @@ -484,56 +496,70 @@ pub fn class_type(s: Span) -> IResult { #[parser] pub fn integer_type(s: Span) -> IResult { alt(( - map(integer_vector_type, |x| IntegerType::IntegerVectorType(x)), - map(integer_atom_type, |x| IntegerType::IntegerAtomType(x)), + map(integer_vector_type, |x| { + IntegerType::IntegerVectorType(Box::new(x)) + }), + map(integer_atom_type, |x| { + IntegerType::IntegerAtomType(Box::new(x)) + }), ))(s) } #[parser] pub fn integer_atom_type(s: Span) -> IResult { alt(( - map(keyword("byte"), |x| IntegerAtomType::Byte(x)), - map(keyword("shortint"), |x| IntegerAtomType::Shortint(x)), - map(keyword("int"), |x| IntegerAtomType::Int(x)), - map(keyword("longint"), |x| IntegerAtomType::Longint(x)), - map(keyword("integer"), |x| IntegerAtomType::Integer(x)), - map(keyword("time"), |x| IntegerAtomType::Time(x)), + map(keyword("byte"), |x| IntegerAtomType::Byte(Box::new(x))), + map(keyword("shortint"), |x| { + IntegerAtomType::Shortint(Box::new(x)) + }), + map(keyword("int"), |x| IntegerAtomType::Int(Box::new(x))), + map(keyword("longint"), |x| { + IntegerAtomType::Longint(Box::new(x)) + }), + map(keyword("integer"), |x| { + IntegerAtomType::Integer(Box::new(x)) + }), + map(keyword("time"), |x| IntegerAtomType::Time(Box::new(x))), ))(s) } #[parser] pub fn integer_vector_type(s: Span) -> IResult { alt(( - map(keyword("bit"), |x| IntegerVectorType::Bit(x)), - map(keyword("logic"), |x| IntegerVectorType::Logic(x)), - map(keyword("reg"), |x| IntegerVectorType::Reg(x)), + map(keyword("bit"), |x| IntegerVectorType::Bit(Box::new(x))), + map(keyword("logic"), |x| IntegerVectorType::Logic(Box::new(x))), + map(keyword("reg"), |x| IntegerVectorType::Reg(Box::new(x))), ))(s) } #[parser] pub fn non_integer_type(s: Span) -> IResult { alt(( - map(keyword("shortreal"), |x| NonIntegerType::Shortreal(x)), - map(keyword("realtime"), |x| NonIntegerType::Realtime(x)), - map(keyword("real"), |x| NonIntegerType::Real(x)), + map(keyword("shortreal"), |x| { + NonIntegerType::Shortreal(Box::new(x)) + }), + map(keyword("realtime"), |x| { + NonIntegerType::Realtime(Box::new(x)) + }), + map(keyword("real"), |x| NonIntegerType::Real(Box::new(x))), ))(s) } #[parser] pub fn net_type(s: Span) -> IResult { alt(( - map(keyword("supply0"), |x| NetType::Supply0(x)), - map(keyword("supply1"), |x| NetType::Supply1(x)), - map(keyword("triand"), |x| NetType::Triand(x)), - map(keyword("trior"), |x| NetType::Trior(x)), - map(keyword("trireg"), |x| NetType::Trireg(x)), - map(keyword("tri0"), |x| NetType::Tri0(x)), - map(keyword("tri1"), |x| NetType::Tri1(x)), - map(keyword("tri"), |x| NetType::Tri(x)), - map(keyword("uwire"), |x| NetType::Uwire(x)), - map(keyword("wire"), |x| NetType::Wire(x)), - map(keyword("wand"), |x| NetType::Wand(x)), - map(keyword("wor"), |x| NetType::Wor(x)), + map(keyword("supply0"), |x| NetType::Supply0(Box::new(x))), + map(keyword("supply1"), |x| NetType::Supply1(Box::new(x))), + map(keyword("triand"), |x| NetType::Triand(Box::new(x))), + map(keyword("trior"), |x| NetType::Trior(Box::new(x))), + map(keyword("trireg"), |x| NetType::Trireg(Box::new(x))), + map(keyword("tri0"), |x| NetType::Tri0(Box::new(x))), + map(keyword("tri1"), |x| NetType::Tri1(Box::new(x))), + map(keyword("tri"), |x| NetType::Tri(Box::new(x))), + map(keyword("uwire"), |x| NetType::Uwire(Box::new(x))), + map(keyword("wire"), |x| NetType::Wire(Box::new(x))), + map(keyword("wand"), |x| NetType::Wand(Box::new(x))), + map(keyword("wor"), |x| NetType::Wor(Box::new(x))), ))(s) } @@ -541,7 +567,9 @@ pub fn net_type(s: Span) -> IResult { pub fn net_port_type(s: Span) -> IResult { alt(( net_port_type_data_type, - map(net_type_identifier, |x| NetPortType::NetTypeIdentifier(x)), + map(net_type_identifier, |x| { + NetPortType::NetTypeIdentifier(Box::new(x)) + }), net_port_type_interconnect, ))(s) } @@ -552,7 +580,7 @@ pub fn net_port_type_data_type(s: Span) -> IResult { let (s, b) = data_type_or_implicit(s)?; Ok(( s, - NetPortType::DataType(NetPortTypeDataType { nodes: (a, b) }), + NetPortType::DataType(Box::new(NetPortTypeDataType { nodes: (a, b) })), )) } @@ -562,7 +590,7 @@ pub fn net_port_type_interconnect(s: Span) -> IResult { let (s, b) = implicit_data_type(s)?; Ok(( s, - NetPortType::Interconnect(NetPortTypeInterconnect { nodes: (a, b) }), + NetPortType::Interconnect(Box::new(NetPortTypeInterconnect { nodes: (a, b) })), )) } @@ -575,7 +603,7 @@ pub fn variable_port_type(s: Span) -> IResult { #[parser] pub fn var_data_type(s: Span) -> IResult { alt(( - map(data_type, |x| VarDataType::DataType(x)), + map(data_type, |x| VarDataType::DataType(Box::new(x))), var_data_type_var, ))(s) } @@ -584,14 +612,17 @@ pub fn var_data_type(s: Span) -> IResult { pub fn var_data_type_var(s: Span) -> IResult { let (s, a) = keyword("var")(s)?; let (s, b) = data_type_or_implicit(s)?; - Ok((s, VarDataType::Var(VarDataTypeVar { nodes: (a, b) }))) + Ok(( + s, + VarDataType::Var(Box::new(VarDataTypeVar { nodes: (a, b) })), + )) } #[parser] pub fn signing(s: Span) -> IResult { alt(( - map(keyword("signed"), |x| Signing::Signed(x)), - map(keyword("unsigned"), |x| Signing::Unsigned(x)), + map(keyword("signed"), |x| Signing::Signed(Box::new(x))), + map(keyword("unsigned"), |x| Signing::Unsigned(Box::new(x))), ))(s) } @@ -599,11 +630,15 @@ pub fn signing(s: Span) -> IResult { #[parser] pub fn simple_type(s: Span) -> IResult { alt(( - map(integer_type, |x| SimpleType::IntegerType(x)), - map(non_integer_type, |x| SimpleType::NonIntegerType(x)), - map(ps_type_identifier, |x| SimpleType::PsTypeIdentifier(x)), + map(integer_type, |x| SimpleType::IntegerType(Box::new(x))), + map(non_integer_type, |x| { + SimpleType::NonIntegerType(Box::new(x)) + }), + map(ps_type_identifier, |x| { + SimpleType::PsTypeIdentifier(Box::new(x)) + }), map(ps_parameter_identifier, |x| { - SimpleType::PsParameterIdentifier(x) + SimpleType::PsParameterIdentifier(Box::new(x)) }), ))(s) } @@ -626,19 +661,19 @@ pub fn struct_union_member(s: Span) -> IResult { #[parser] pub fn data_type_or_void(s: Span) -> IResult { alt(( - map(data_type, |x| DataTypeOrVoid::DataType(x)), - map(keyword("void"), |x| DataTypeOrVoid::Void(x)), + map(data_type, |x| DataTypeOrVoid::DataType(Box::new(x))), + map(keyword("void"), |x| DataTypeOrVoid::Void(Box::new(x))), ))(s) } #[parser] pub fn struct_union(s: Span) -> IResult { alt(( - map(keyword("struct"), |x| StructUnion::Struct(x)), + map(keyword("struct"), |x| StructUnion::Struct(Box::new(x))), map(pair(keyword("union"), keyword("tagged")), |x| { - StructUnion::UnionTagged(x) + StructUnion::UnionTagged(Box::new(x)) }), - map(keyword("union"), |x| StructUnion::Union(x)), + map(keyword("union"), |x| StructUnion::Union(Box::new(x))), ))(s) } @@ -653,7 +688,7 @@ pub fn type_reference_expression(s: Span) -> IResult { let (s, b) = paren(expression)(s)?; Ok(( s, - TypeReference::Expression(TypeReferenceExpression { nodes: (a, b) }), + TypeReference::Expression(Box::new(TypeReferenceExpression { nodes: (a, b) })), )) } @@ -663,7 +698,7 @@ pub fn type_reference_data_type(s: Span) -> IResult { let (s, b) = paren(data_type)(s)?; Ok(( s, - TypeReference::DataType(TypeReferenceDataType { nodes: (a, b) }), + TypeReference::DataType(Box::new(TypeReferenceDataType { nodes: (a, b) })), )) } diff --git a/src/parser/declarations/port_declarations.rs b/src/parser/declarations/port_declarations.rs index 1fbe791..5b1a9aa 100644 --- a/src/parser/declarations/port_declarations.rs +++ b/src/parser/declarations/port_declarations.rs @@ -14,8 +14,8 @@ pub struct InoutDeclaration { #[derive(Clone, Debug, Node)] pub enum InputDeclaration { - Net(InputDeclarationNet), - Variable(InputDeclarationVariable), + Net(Box), + Variable(Box), } #[derive(Clone, Debug, Node)] @@ -30,8 +30,8 @@ pub struct InputDeclarationVariable { #[derive(Clone, Debug, Node)] pub enum OutputDeclaration { - Net(OutputDeclarationNet), - Variable(OutputDeclarationVariable), + Net(Box), + Variable(Box), } #[derive(Clone, Debug, Node)] @@ -80,7 +80,7 @@ pub fn input_declaration_net(s: Span) -> IResult { let (s, c) = list_of_port_identifiers(s)?; Ok(( s, - InputDeclaration::Net(InputDeclarationNet { nodes: (a, b, c) }), + InputDeclaration::Net(Box::new(InputDeclarationNet { nodes: (a, b, c) })), )) } @@ -91,7 +91,7 @@ pub fn input_declaration_variable(s: Span) -> IResult { let (s, c) = list_of_variable_identifiers(s)?; Ok(( s, - InputDeclaration::Variable(InputDeclarationVariable { nodes: (a, b, c) }), + InputDeclaration::Variable(Box::new(InputDeclarationVariable { nodes: (a, b, c) })), )) } @@ -107,7 +107,7 @@ pub fn output_declaration_net(s: Span) -> IResult { let (s, c) = list_of_port_identifiers(s)?; Ok(( s, - OutputDeclaration::Net(OutputDeclarationNet { nodes: (a, b, c) }), + OutputDeclaration::Net(Box::new(OutputDeclarationNet { nodes: (a, b, c) })), )) } @@ -118,7 +118,7 @@ pub fn output_declaration_variable(s: Span) -> IResult let (s, c) = list_of_variable_identifiers(s)?; Ok(( s, - OutputDeclaration::Variable(OutputDeclarationVariable { nodes: (a, b, c) }), + OutputDeclaration::Variable(Box::new(OutputDeclarationVariable { nodes: (a, b, c) })), )) } @@ -144,14 +144,14 @@ pub fn implicit_var(s: Span) -> IResult { Ok(( s, VariablePortType { - nodes: (VarDataType::Var(VarDataTypeVar { + nodes: (VarDataType::Var(Box::new(VarDataTypeVar { nodes: ( a, - DataTypeOrImplicit::ImplicitDataType(ImplicitDataType { + DataTypeOrImplicit::ImplicitDataType(Box::new(ImplicitDataType { nodes: (None, vec![]), - }), + })), ), - }),), + })),), }, )) } diff --git a/src/parser/declarations/strengths.rs b/src/parser/declarations/strengths.rs index 6cc896c..a38d5a3 100644 --- a/src/parser/declarations/strengths.rs +++ b/src/parser/declarations/strengths.rs @@ -8,12 +8,12 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum DriveStrength { - Strength01(DriveStrength01), - Strength10(DriveStrength10), - Strength0z(DriveStrength0z), - Strength1z(DriveStrength1z), - Strengthz0(DriveStrengthz0), - Strengthz1(DriveStrengthz1), + Strength01(Box), + Strength10(Box), + Strength0z(Box), + Strength1z(Box), + Strengthz0(Box), + Strengthz1(Box), } #[derive(Clone, Debug, Node)] @@ -48,25 +48,25 @@ pub struct DriveStrengthz0 { #[derive(Clone, Debug, Node)] pub enum Strength0 { - Supply0(Keyword), - Strong0(Keyword), - Pull0(Keyword), - Weak0(Keyword), + Supply0(Box), + Strong0(Box), + Pull0(Box), + Weak0(Box), } #[derive(Clone, Debug, Node)] pub enum Strength1 { - Supply1(Keyword), - Strong1(Keyword), - Pull1(Keyword), - Weak1(Keyword), + Supply1(Box), + Strong1(Box), + Pull1(Box), + Weak1(Box), } #[derive(Clone, Debug, Node)] pub enum ChargeStrength { - Small(ChargeStrengthSmall), - Medium(ChargeStrengthMedium), - Large(ChargeStrengthLarge), + Small(Box), + Medium(Box), + Large(Box), } #[derive(Clone, Debug, Node)] @@ -103,7 +103,7 @@ pub fn drive_strength01(s: Span) -> IResult { let (s, a) = paren(triple(strength0, symbol(","), strength1))(s)?; Ok(( s, - DriveStrength::Strength01(DriveStrength01 { nodes: (a,) }), + DriveStrength::Strength01(Box::new(DriveStrength01 { nodes: (a,) })), )) } @@ -112,7 +112,7 @@ pub fn drive_strength10(s: Span) -> IResult { let (s, a) = paren(triple(strength1, symbol(","), strength0))(s)?; Ok(( s, - DriveStrength::Strength10(DriveStrength10 { nodes: (a,) }), + DriveStrength::Strength10(Box::new(DriveStrength10 { nodes: (a,) })), )) } @@ -121,7 +121,7 @@ pub fn drive_strength0z(s: Span) -> IResult { let (s, a) = paren(triple(strength0, symbol(","), keyword("highz1")))(s)?; Ok(( s, - DriveStrength::Strength0z(DriveStrength0z { nodes: (a,) }), + DriveStrength::Strength0z(Box::new(DriveStrength0z { nodes: (a,) })), )) } @@ -130,7 +130,7 @@ pub fn drive_strength1z(s: Span) -> IResult { let (s, a) = paren(triple(strength1, symbol(","), keyword("highz0")))(s)?; Ok(( s, - DriveStrength::Strength1z(DriveStrength1z { nodes: (a,) }), + DriveStrength::Strength1z(Box::new(DriveStrength1z { nodes: (a,) })), )) } @@ -139,7 +139,7 @@ pub fn drive_strengthz1(s: Span) -> IResult { let (s, a) = paren(triple(keyword("highz0"), symbol(","), strength1))(s)?; Ok(( s, - DriveStrength::Strengthz1(DriveStrengthz1 { nodes: (a,) }), + DriveStrength::Strengthz1(Box::new(DriveStrengthz1 { nodes: (a,) })), )) } @@ -148,27 +148,27 @@ pub fn drive_strengthz0(s: Span) -> IResult { let (s, a) = paren(triple(keyword("highz1"), symbol(","), strength0))(s)?; Ok(( s, - DriveStrength::Strengthz0(DriveStrengthz0 { nodes: (a,) }), + DriveStrength::Strengthz0(Box::new(DriveStrengthz0 { nodes: (a,) })), )) } #[parser] pub fn strength0(s: Span) -> IResult { alt(( - map(keyword("supply0"), |x| Strength0::Supply0(x)), - map(keyword("strong0"), |x| Strength0::Strong0(x)), - map(keyword("pull0"), |x| Strength0::Pull0(x)), - map(keyword("weak0"), |x| Strength0::Weak0(x)), + map(keyword("supply0"), |x| Strength0::Supply0(Box::new(x))), + map(keyword("strong0"), |x| Strength0::Strong0(Box::new(x))), + map(keyword("pull0"), |x| Strength0::Pull0(Box::new(x))), + map(keyword("weak0"), |x| Strength0::Weak0(Box::new(x))), ))(s) } #[parser] pub fn strength1(s: Span) -> IResult { alt(( - map(keyword("supply1"), |x| Strength1::Supply1(x)), - map(keyword("strong1"), |x| Strength1::Strong1(x)), - map(keyword("pull1"), |x| Strength1::Pull1(x)), - map(keyword("weak1"), |x| Strength1::Weak1(x)), + map(keyword("supply1"), |x| Strength1::Supply1(Box::new(x))), + map(keyword("strong1"), |x| Strength1::Strong1(Box::new(x))), + map(keyword("pull1"), |x| Strength1::Pull1(Box::new(x))), + map(keyword("weak1"), |x| Strength1::Weak1(Box::new(x))), ))(s) } @@ -186,7 +186,7 @@ pub fn charge_strength_small(s: Span) -> IResult { let (s, a) = paren(keyword("small"))(s)?; Ok(( s, - ChargeStrength::Small(ChargeStrengthSmall { nodes: (a,) }), + ChargeStrength::Small(Box::new(ChargeStrengthSmall { nodes: (a,) })), )) } @@ -195,7 +195,7 @@ pub fn charge_strength_medium(s: Span) -> IResult { let (s, a) = paren(keyword("medium"))(s)?; Ok(( s, - ChargeStrength::Medium(ChargeStrengthMedium { nodes: (a,) }), + ChargeStrength::Medium(Box::new(ChargeStrengthMedium { nodes: (a,) })), )) } @@ -204,7 +204,7 @@ pub fn charge_strength_large(s: Span) -> IResult { let (s, a) = paren(keyword("large"))(s)?; Ok(( s, - ChargeStrength::Large(ChargeStrengthLarge { nodes: (a,) }), + ChargeStrength::Large(Box::new(ChargeStrengthLarge { nodes: (a,) })), )) } diff --git a/src/parser/declarations/task_declarations.rs b/src/parser/declarations/task_declarations.rs index 6d9d528..7bacc82 100644 --- a/src/parser/declarations/task_declarations.rs +++ b/src/parser/declarations/task_declarations.rs @@ -15,8 +15,8 @@ pub struct TaskDeclaration { #[derive(Clone, Debug, Node)] pub enum TaskBodyDeclaration { - WithoutPort(TaskBodyDeclarationWithoutPort), - WithPort(TaskBodyDeclarationWithPort), + WithoutPort(Box), + WithPort(Box), } #[derive(Clone, Debug, Node)] @@ -48,8 +48,8 @@ pub struct TaskBodyDeclarationWithPort { #[derive(Clone, Debug, Node)] pub enum TfItemDeclaration { - BlockItemDeclaration(BlockItemDeclaration), - TfPortDeclaration(TfPortDeclaration), + BlockItemDeclaration(Box), + TfPortDeclaration(Box), } #[derive(Clone, Debug, Node)] @@ -74,8 +74,8 @@ pub struct TfPortItem { #[derive(Clone, Debug, Node)] pub enum TfPortDirection { - PortDirection(PortDirection), - ConstRef((Keyword, Keyword)), + PortDirection(Box), + ConstRef(Box<(Keyword, Keyword)>), } #[derive(Clone, Debug, Node)] @@ -124,9 +124,9 @@ pub fn task_body_declaration_without_port(s: Span) -> IResult IResult IResult IResult { alt(( map(block_item_declaration, |x| { - TfItemDeclaration::BlockItemDeclaration(x) + TfItemDeclaration::BlockItemDeclaration(Box::new(x)) }), map(tf_port_declaration, |x| { - TfItemDeclaration::TfPortDeclaration(x) + TfItemDeclaration::TfPortDeclaration(Box::new(x)) }), ))(s) } @@ -188,9 +188,11 @@ pub fn tf_port_item(s: Span) -> IResult { #[parser] pub fn tf_port_direction(s: Span) -> IResult { alt(( - map(port_direction, |x| TfPortDirection::PortDirection(x)), + map(port_direction, |x| { + TfPortDirection::PortDirection(Box::new(x)) + }), map(pair(keyword("const"), keyword("ref")), |x| { - TfPortDirection::ConstRef(x) + TfPortDirection::ConstRef(Box::new(x)) }), ))(s) } diff --git a/src/parser/declarations/type_declarations.rs b/src/parser/declarations/type_declarations.rs index e9da1c0..e3ee90d 100644 --- a/src/parser/declarations/type_declarations.rs +++ b/src/parser/declarations/type_declarations.rs @@ -10,10 +10,10 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum DataDeclaration { - Variable(DataDeclarationVariable), - TypeDeclaration(TypeDeclaration), - PackageImportDeclaration(PackageImportDeclaration), - NetTypeDeclaration(NetTypeDeclaration), + Variable(Box), + TypeDeclaration(Box), + PackageImportDeclaration(Box), + NetTypeDeclaration(Box), } #[derive(Clone, Debug, Node)] @@ -40,8 +40,8 @@ pub struct PackageImportDeclaration { #[derive(Clone, Debug, Node)] pub enum PackageImportItem { - Identifier(PackageImportItemIdentifier), - Asterisk(PackageImportItemAsterisk), + Identifier(Box), + Asterisk(Box), } #[derive(Clone, Debug, Node)] @@ -56,8 +56,8 @@ pub struct PackageImportItemAsterisk { #[derive(Clone, Debug, Node)] pub enum PackageExportDeclaration { - Asterisk(PackageExportDeclarationAsterisk), - Item(PackageExportDeclarationItem), + Asterisk(Box), + Item(Box), } #[derive(Clone, Debug, Node)] @@ -77,9 +77,9 @@ pub struct GenvarDeclaration { #[derive(Clone, Debug, Node)] pub enum NetDeclaration { - NetType(NetDeclarationNetType), - NetTypeIdentifier(NetDeclarationNetTypeIdentifier), - Interconnect(NetDeclarationInterconnect), + NetType(Box), + NetTypeIdentifier(Box), + Interconnect(Box), } #[derive(Clone, Debug, Node)] @@ -97,14 +97,14 @@ pub struct NetDeclarationNetType { #[derive(Clone, Debug, Node)] pub enum Strength { - Drive(DriveStrength), - Charge(ChargeStrength), + Drive(Box), + Charge(Box), } #[derive(Clone, Debug, Node)] pub enum VectorScalar { - Vectored(Keyword), - Scalared(Keyword), + Vectored(Box), + Scalared(Box), } #[derive(Clone, Debug, Node)] @@ -132,9 +132,9 @@ pub struct NetDeclarationInterconnect { #[derive(Clone, Debug, Node)] pub enum TypeDeclaration { - DataType(TypeDeclarationDataType), - Interface(TypeDeclarationInterface), - Reserved(TypeDeclarationReserved), + DataType(Box), + Interface(Box), + Reserved(Box), } #[derive(Clone, Debug, Node)] @@ -173,17 +173,17 @@ pub struct TypeDeclarationReserved { #[derive(Clone, Debug, Node)] pub enum TypeDeclarationKeyword { - Enum(Keyword), - Struct(Keyword), - Union(Keyword), - Class(Keyword), - InterfaceClass((Keyword, Keyword)), + Enum(Box), + Struct(Box), + Union(Box), + Class(Box), + InterfaceClass(Box<(Keyword, Keyword)>), } #[derive(Clone, Debug, Node)] pub enum NetTypeDeclaration { - DataType(NetTypeDeclarationDataType), - NetType(NetTypeDeclarationNetType), + DataType(Box), + NetType(Box), } #[derive(Clone, Debug, Node)] @@ -210,8 +210,8 @@ pub struct NetTypeDeclarationNetType { #[derive(Clone, Debug, Node)] pub enum Lifetime { - Static(Keyword), - Automatic(Keyword), + Static(Box), + Automatic(Box), } // ----------------------------------------------------------------------------- @@ -220,12 +220,14 @@ pub enum Lifetime { pub fn data_declaration(s: Span) -> IResult { alt(( data_declaration_variable, - map(type_declaration, |x| DataDeclaration::TypeDeclaration(x)), + map(type_declaration, |x| { + DataDeclaration::TypeDeclaration(Box::new(x)) + }), map(package_import_declaration, |x| { - DataDeclaration::PackageImportDeclaration(x) + DataDeclaration::PackageImportDeclaration(Box::new(x)) }), map(net_type_declaration, |x| { - DataDeclaration::NetTypeDeclaration(x) + DataDeclaration::NetTypeDeclaration(Box::new(x)) }), ))(s) } @@ -240,9 +242,9 @@ pub fn data_declaration_variable(s: Span) -> IResult { let (s, f) = symbol(";")(s)?; Ok(( s, - DataDeclaration::Variable(DataDeclarationVariable { + DataDeclaration::Variable(Box::new(DataDeclarationVariable { nodes: (a, b, c, d, e, f), - }), + })), )) } @@ -272,7 +274,7 @@ pub fn package_import_item_identifier(s: Span) -> IResult IResult let (s, c) = symbol("*")(s)?; Ok(( s, - PackageImportItem::Asterisk(PackageImportItemAsterisk { nodes: (a, b, c) }), + PackageImportItem::Asterisk(Box::new(PackageImportItemAsterisk { nodes: (a, b, c) })), )) } @@ -302,7 +304,9 @@ pub fn package_export_declaration_asterisk(s: Span) -> IResult IResult IResult { let (s, g) = symbol(";")(s)?; Ok(( s, - NetDeclaration::NetType(NetDeclarationNetType { + NetDeclaration::NetType(Box::new(NetDeclarationNetType { nodes: (a, b, c, d, e, f, g), - }), + })), )) } #[parser] pub fn strength(s: Span) -> IResult { alt(( - map(drive_strength, |x| Strength::Drive(x)), - map(charge_strength, |x| Strength::Charge(x)), + map(drive_strength, |x| Strength::Drive(Box::new(x))), + map(charge_strength, |x| Strength::Charge(Box::new(x))), ))(s) } #[parser] pub fn vector_scalar(s: Span) -> IResult { alt(( - map(keyword("vectored"), |x| VectorScalar::Vectored(x)), - map(keyword("scalared"), |x| VectorScalar::Scalared(x)), + map(keyword("vectored"), |x| VectorScalar::Vectored(Box::new(x))), + map(keyword("scalared"), |x| VectorScalar::Scalared(Box::new(x))), ))(s) } @@ -375,9 +379,9 @@ pub fn net_declaration_net_type_identifier(s: Span) -> IResult IResult { let (s, g) = symbol(";")(s)?; Ok(( s, - NetDeclaration::Interconnect(NetDeclarationInterconnect { + NetDeclaration::Interconnect(Box::new(NetDeclarationInterconnect { nodes: (a, b, c, d, e, f, g), - }), + })), )) } @@ -420,9 +424,9 @@ pub fn type_declaration_data_type(s: Span) -> IResult { let (s, e) = symbol(";")(s)?; Ok(( s, - TypeDeclaration::DataType(TypeDeclarationDataType { + TypeDeclaration::DataType(Box::new(TypeDeclarationDataType { nodes: (a, b, c, d, e), - }), + })), )) } @@ -437,9 +441,9 @@ pub fn type_declaration_interface(s: Span) -> IResult { let (s, g) = symbol(";")(s)?; Ok(( s, - TypeDeclaration::Interface(TypeDeclarationInterface { + TypeDeclaration::Interface(Box::new(TypeDeclarationInterface { nodes: (a, b, c, d, e, f, g), - }), + })), )) } @@ -451,21 +455,29 @@ pub fn type_declaration_reserved(s: Span) -> IResult { let (s, d) = symbol(";")(s)?; Ok(( s, - TypeDeclaration::Reserved(TypeDeclarationReserved { + TypeDeclaration::Reserved(Box::new(TypeDeclarationReserved { nodes: (a, b, c, d), - }), + })), )) } #[parser] pub fn type_declaration_keyword(s: Span) -> IResult { alt(( - map(keyword("enum"), |x| TypeDeclarationKeyword::Enum(x)), - map(keyword("struct"), |x| TypeDeclarationKeyword::Struct(x)), - map(keyword("union"), |x| TypeDeclarationKeyword::Union(x)), - map(keyword("class"), |x| TypeDeclarationKeyword::Class(x)), + map(keyword("enum"), |x| { + TypeDeclarationKeyword::Enum(Box::new(x)) + }), + map(keyword("struct"), |x| { + TypeDeclarationKeyword::Struct(Box::new(x)) + }), + map(keyword("union"), |x| { + TypeDeclarationKeyword::Union(Box::new(x)) + }), + map(keyword("class"), |x| { + TypeDeclarationKeyword::Class(Box::new(x)) + }), map(pair(keyword("interface"), keyword("class")), |x| { - TypeDeclarationKeyword::InterfaceClass(x) + TypeDeclarationKeyword::InterfaceClass(Box::new(x)) }), ))(s) } @@ -491,9 +503,9 @@ pub fn net_type_declaration_data_type(s: Span) -> IResult IResult IResult { alt(( - map(keyword("static"), |x| Lifetime::Static(x)), - map(keyword("automatic"), |x| Lifetime::Automatic(x)), + map(keyword("static"), |x| Lifetime::Static(Box::new(x))), + map(keyword("automatic"), |x| Lifetime::Automatic(Box::new(x))), ))(s) } diff --git a/src/parser/expressions/concatenations.rs b/src/parser/expressions/concatenations.rs index ce5d7c0..95bb580 100644 --- a/src/parser/expressions/concatenations.rs +++ b/src/parser/expressions/concatenations.rs @@ -49,8 +49,8 @@ pub struct StreamOperator { #[derive(Clone, Debug, Node)] pub enum SliceSize { - SimpleType(SimpleType), - ConstantExpression(ConstantExpression), + SimpleType(Box), + ConstantExpression(Box), } #[derive(Clone, Debug, Node)] @@ -65,10 +65,10 @@ pub struct StreamExpression { #[derive(Clone, Debug, Node)] pub enum ArrayRangeExpression { - Expression(Expression), - Colon(ArrayRangeExpressionColon), - PlusColon(ArrayRangeExpressionPlusColon), - MinusColon(ArrayRangeExpressionMinusColon), + Expression(Box), + Colon(Box), + PlusColon(Box), + MinusColon(Box), } #[derive(Clone, Debug, Node)] @@ -152,8 +152,10 @@ pub fn stream_operator(s: Span) -> IResult { #[parser] pub fn slice_size(s: Span) -> IResult { alt(( - map(simple_type, |x| SliceSize::SimpleType(x)), - map(constant_expression, |x| SliceSize::ConstantExpression(x)), + map(simple_type, |x| SliceSize::SimpleType(Box::new(x))), + map(constant_expression, |x| { + SliceSize::ConstantExpression(Box::new(x)) + }), ))(s) } @@ -173,7 +175,9 @@ pub fn stream_expression(s: Span) -> IResult { #[parser] pub fn array_range_expression(s: Span) -> IResult { alt(( - map(expression, |x| ArrayRangeExpression::Expression(x)), + map(expression, |x| { + ArrayRangeExpression::Expression(Box::new(x)) + }), array_range_expression_colon, array_range_expression_plus_colon, array_range_expression_minus_colon, @@ -187,7 +191,7 @@ pub fn array_range_expression_colon(s: Span) -> IResult IResult IResult), Lvalue(Box), Pattern(Box), } @@ -34,10 +34,10 @@ pub struct NetLvaluePattern { #[derive(Clone, Debug, Node)] pub enum VariableLvalue { - Identifier(VariableLvalueIdentifier), + Identifier(Box), Lvalue(Box), Pattern(Box), - StreamingConcatenation(StreamingConcatenation), + StreamingConcatenation(Box), } #[derive(Clone, Debug, Node)] @@ -85,7 +85,7 @@ pub fn net_lvalue_identifier(s: Span) -> IResult { let (s, b) = constant_select(s)?; Ok(( s, - NetLvalue::Identifier(NetLvalueIdentifier { nodes: (a, b) }), + NetLvalue::Identifier(Box::new(NetLvalueIdentifier { nodes: (a, b) })), )) } @@ -116,7 +116,7 @@ pub fn variable_lvalue(s: Span) -> IResult { variable_lvalue_lvalue, variable_lvalue_pattern, map(streaming_concatenation, |x| { - VariableLvalue::StreamingConcatenation(x) + VariableLvalue::StreamingConcatenation(Box::new(x)) }), ))(s) } @@ -128,7 +128,7 @@ pub fn variable_lvalue_identifier(s: Span) -> IResult { let (s, c) = select(s)?; Ok(( s, - VariableLvalue::Identifier(VariableLvalueIdentifier { nodes: (a, b, c) }), + VariableLvalue::Identifier(Box::new(VariableLvalueIdentifier { nodes: (a, b, c) })), )) } diff --git a/src/parser/expressions/expressions.rs b/src/parser/expressions/expressions.rs index 1c4c3dd..9c4bb74 100644 --- a/src/parser/expressions/expressions.rs +++ b/src/parser/expressions/expressions.rs @@ -10,8 +10,8 @@ use nom_packrat::packrat_parser; #[derive(Clone, Debug, Node)] pub enum IncOrDecExpression { - Prefix(IncOrDecExpressionPrefix), - Suffix(IncOrDecExpressionSuffix), + Prefix(Box), + Suffix(Box), } #[derive(Clone, Debug, Node)] @@ -73,8 +73,8 @@ pub struct ConstantExpressionTernary { #[derive(Clone, Debug, Node)] pub enum ConstantMintypmaxExpression { - Unary(ConstantExpression), - Ternary(ConstantMintypmaxExpressionTernary), + Unary(Box), + Ternary(Box), } #[derive(Clone, Debug, Node)] @@ -90,28 +90,28 @@ pub struct ConstantMintypmaxExpressionTernary { #[derive(Clone, Debug, Node)] pub enum ConstantParamExpression { - ConstantMintypmaxExpression(ConstantMintypmaxExpression), - DataType(DataType), - Dollar(Symbol), + ConstantMintypmaxExpression(Box), + DataType(Box), + Dollar(Box), } #[derive(Clone, Debug, Node)] pub enum ParamExpression { - MintypmaxExpression(MintypmaxExpression), + MintypmaxExpression(Box), DataType(Box), - Dollar(Symbol), + Dollar(Box), } #[derive(Clone, Debug, Node)] pub enum ConstantRangeExpression { - ConstantExpression(ConstantExpression), - ConstantPartSelectRange(ConstantPartSelectRange), + ConstantExpression(Box), + ConstantPartSelectRange(Box), } #[derive(Clone, Debug, Node)] pub enum ConstantPartSelectRange { - ConstantRange(ConstantRange), - ConstantIndexedRange(ConstantIndexedRange), + ConstantRange(Box), + ConstantIndexedRange(Box), } #[derive(Clone, Debug, Node)] @@ -168,8 +168,8 @@ pub struct InsideExpression { #[derive(Clone, Debug, Node)] pub enum ValueRange { - Expression(Expression), - Binary(ValueRangeBinary), + Expression(Box), + Binary(Box), } #[derive(Clone, Debug, Node)] @@ -179,8 +179,8 @@ pub struct ValueRangeBinary { #[derive(Clone, Debug, Node)] pub enum MintypmaxExpression { - Expression(Expression), - Ternary(MintypmaxExpressionTernary), + Expression(Box), + Ternary(Box), } #[derive(Clone, Debug, Node)] @@ -229,8 +229,8 @@ pub struct ModulePathExpressionBinary { #[derive(Clone, Debug, Node)] pub enum ModulePathMintypmaxExpression { - ModulePathExpression(ModulePathExpression), - Ternary(ModulePathMintypmaxExpressionTernary), + ModulePathExpression(Box), + Ternary(Box), } #[derive(Clone, Debug, Node)] @@ -246,8 +246,8 @@ pub struct ModulePathMintypmaxExpressionTernary { #[derive(Clone, Debug, Node)] pub enum PartSelectRange { - ConstantRange(ConstantRange), - IndexedRange(IndexedRange), + ConstantRange(Box), + IndexedRange(Box), } #[derive(Clone, Debug, Node)] @@ -274,7 +274,7 @@ pub fn inc_or_dec_expression_prefix(s: Span) -> IResult IResult IResult IResult { alt(( - map(symbol("$"), |x| ConstantParamExpression::Dollar(x)), - map(constant_mintypmax_expression, |x| { - ConstantParamExpression::ConstantMintypmaxExpression(x) + map(symbol("$"), |x| { + ConstantParamExpression::Dollar(Box::new(x)) + }), + map(constant_mintypmax_expression, |x| { + ConstantParamExpression::ConstantMintypmaxExpression(Box::new(x)) + }), + map(data_type, |x| { + ConstantParamExpression::DataType(Box::new(x)) }), - map(data_type, |x| ConstantParamExpression::DataType(x)), ))(s) } #[parser] pub fn param_expression(s: Span) -> IResult { alt(( - map(symbol("$"), |x| ParamExpression::Dollar(x)), + map(symbol("$"), |x| ParamExpression::Dollar(Box::new(x))), map(mintypmax_expression, |x| { - ParamExpression::MintypmaxExpression(x) + ParamExpression::MintypmaxExpression(Box::new(x)) }), map(data_type, |x| ParamExpression::DataType(Box::new(x))), ))(s) @@ -412,10 +416,10 @@ pub fn param_expression(s: Span) -> IResult { pub fn constant_range_expression(s: Span) -> IResult { alt(( map(constant_part_select_range, |x| { - ConstantRangeExpression::ConstantPartSelectRange(x) + ConstantRangeExpression::ConstantPartSelectRange(Box::new(x)) }), map(constant_expression, |x| { - ConstantRangeExpression::ConstantExpression(x) + ConstantRangeExpression::ConstantExpression(Box::new(x)) }), ))(s) } @@ -424,10 +428,10 @@ pub fn constant_range_expression(s: Span) -> IResult IResult { alt(( map(constant_range, |x| { - ConstantPartSelectRange::ConstantRange(x) + ConstantPartSelectRange::ConstantRange(Box::new(x)) }), map(constant_indexed_range, |x| { - ConstantPartSelectRange::ConstantIndexedRange(x) + ConstantPartSelectRange::ConstantIndexedRange(Box::new(x)) }), ))(s) } @@ -525,21 +529,24 @@ pub fn inside_expression(s: Span) -> IResult { pub fn value_range(s: Span) -> IResult { alt(( value_range_binary, - map(expression, |x| ValueRange::Expression(x)), + map(expression, |x| ValueRange::Expression(Box::new(x))), ))(s) } #[parser] pub fn value_range_binary(s: Span) -> IResult { let (s, a) = bracket(triple(expression, symbol(":"), expression))(s)?; - Ok((s, ValueRange::Binary(ValueRangeBinary { nodes: (a,) }))) + Ok(( + s, + ValueRange::Binary(Box::new(ValueRangeBinary { nodes: (a,) })), + )) } #[parser] pub fn mintypmax_expression(s: Span) -> IResult { alt(( mintypmax_expression_ternary, - map(expression, |x| MintypmaxExpression::Expression(x)), + map(expression, |x| MintypmaxExpression::Expression(Box::new(x))), ))(s) } @@ -552,9 +559,9 @@ pub fn mintypmax_expression_ternary(s: Span) -> IResult IResult IResult { alt(( - map(constant_range, |x| PartSelectRange::ConstantRange(x)), - map(indexed_range, |x| PartSelectRange::IndexedRange(x)), + map(constant_range, |x| { + PartSelectRange::ConstantRange(Box::new(x)) + }), + map(indexed_range, |x| { + PartSelectRange::IndexedRange(Box::new(x)) + }), ))(s) } diff --git a/src/parser/expressions/numbers.rs b/src/parser/expressions/numbers.rs index 52ef326..fe7ab1c 100644 --- a/src/parser/expressions/numbers.rs +++ b/src/parser/expressions/numbers.rs @@ -13,24 +13,24 @@ use nom_packrat::packrat_parser; #[derive(Clone, Debug, Node)] pub enum Number { - IntegralNumber(IntegralNumber), - RealNumber(RealNumber), + IntegralNumber(Box), + RealNumber(Box), } #[derive(Clone, Debug, Node)] pub enum IntegralNumber { - DecimalNumber(DecimalNumber), - OctalNumber(OctalNumber), - BinaryNumber(BinaryNumber), - HexNumber(HexNumber), + DecimalNumber(Box), + OctalNumber(Box), + BinaryNumber(Box), + HexNumber(Box), } #[derive(Clone, Debug, Node)] pub enum DecimalNumber { - UnsignedNumber(UnsignedNumber), - BaseUnsigned(DecimalNumberBaseUnsigned), - BaseXNumber(DecimalNumberBaseXNumber), - BaseZNumber(DecimalNumberBaseZNumber), + UnsignedNumber(Box), + BaseUnsigned(Box), + BaseXNumber(Box), + BaseZNumber(Box), } #[derive(Clone, Debug, Node)] @@ -65,8 +65,8 @@ pub struct HexNumber { #[derive(Clone, Debug, Node)] pub enum Sign { - Plus(Symbol), - Minus(Symbol), + Plus(Box), + Minus(Box), } #[derive(Clone, Debug, Node)] @@ -81,8 +81,8 @@ pub struct NonZeroUnsignedNumber { #[derive(Clone, Debug, Node)] pub enum RealNumber { - FixedPointNumber(FixedPointNumber), - Floating(RealNumberFloating), + FixedPointNumber(Box), + Floating(Box), } #[derive(Clone, Debug, Node)] @@ -167,18 +167,20 @@ pub struct UnbasedUnsizedLiteral { #[parser] pub fn number(s: Span) -> IResult { alt(( - map(real_number, |x| Number::RealNumber(x)), - map(integral_number, |x| Number::IntegralNumber(x)), + map(real_number, |x| Number::RealNumber(Box::new(x))), + map(integral_number, |x| Number::IntegralNumber(Box::new(x))), ))(s) } #[parser] pub fn integral_number(s: Span) -> IResult { alt(( - map(octal_number, |x| IntegralNumber::OctalNumber(x)), - map(binary_number, |x| IntegralNumber::BinaryNumber(x)), - map(hex_number, |x| IntegralNumber::HexNumber(x)), - map(decimal_number, |x| IntegralNumber::DecimalNumber(x)), + map(octal_number, |x| IntegralNumber::OctalNumber(Box::new(x))), + map(binary_number, |x| IntegralNumber::BinaryNumber(Box::new(x))), + map(hex_number, |x| IntegralNumber::HexNumber(Box::new(x))), + map(decimal_number, |x| { + IntegralNumber::DecimalNumber(Box::new(x)) + }), ))(s) } @@ -188,7 +190,9 @@ pub fn decimal_number(s: Span) -> IResult { decimal_number_base_unsigned, decimal_number_base_x_number, decimal_number_base_z_number, - map(unsigned_number, |x| DecimalNumber::UnsignedNumber(x)), + map(unsigned_number, |x| { + DecimalNumber::UnsignedNumber(Box::new(x)) + }), ))(s) } @@ -199,7 +203,7 @@ pub fn decimal_number_base_unsigned(s: Span) -> IResult { let (s, c) = unsigned_number(s)?; Ok(( s, - DecimalNumber::BaseUnsigned(DecimalNumberBaseUnsigned { nodes: (a, b, c) }), + DecimalNumber::BaseUnsigned(Box::new(DecimalNumberBaseUnsigned { nodes: (a, b, c) })), )) } @@ -210,7 +214,7 @@ pub fn decimal_number_base_x_number(s: Span) -> IResult { let (s, c) = x_number(s)?; Ok(( s, - DecimalNumber::BaseXNumber(DecimalNumberBaseXNumber { nodes: (a, b, c) }), + DecimalNumber::BaseXNumber(Box::new(DecimalNumberBaseXNumber { nodes: (a, b, c) })), )) } @@ -221,7 +225,7 @@ pub fn decimal_number_base_z_number(s: Span) -> IResult { let (s, c) = z_number(s)?; Ok(( s, - DecimalNumber::BaseZNumber(DecimalNumberBaseZNumber { nodes: (a, b, c) }), + DecimalNumber::BaseZNumber(Box::new(DecimalNumberBaseZNumber { nodes: (a, b, c) })), )) } @@ -252,8 +256,8 @@ pub fn hex_number(s: Span) -> IResult { #[parser] pub fn sign(s: Span) -> IResult { alt(( - map(symbol("+"), |x| Sign::Plus(x)), - map(symbol("-"), |x| Sign::Minus(x)), + map(symbol("+"), |x| Sign::Plus(Box::new(x))), + map(symbol("-"), |x| Sign::Minus(Box::new(x))), ))(s) } @@ -282,7 +286,9 @@ pub fn non_zero_unsigned_number_impl(s: Span) -> IResult { pub fn real_number(s: Span) -> IResult { alt(( real_number_floating, - map(fixed_point_number, |x| RealNumber::FixedPointNumber(x)), + map(fixed_point_number, |x| { + RealNumber::FixedPointNumber(Box::new(x)) + }), ))(s) } @@ -295,9 +301,9 @@ pub fn real_number_floating(s: Span) -> IResult { let (s, e) = unsigned_number(s)?; Ok(( s, - RealNumber::Floating(RealNumberFloating { + RealNumber::Floating(Box::new(RealNumberFloating { nodes: (a, b, c, d, e), - }), + })), )) } @@ -471,123 +477,39 @@ mod tests { #[test] fn test_number() { - parser_test!( - number, - "659", - Ok((_, Number::IntegralNumber(IntegralNumber::DecimalNumber(_)))) - ); - parser_test!( - number, - "'h 837FF", - Ok((_, Number::IntegralNumber(IntegralNumber::HexNumber(_)))) - ); - parser_test!( - number, - "'h 837FF", - Ok((_, Number::IntegralNumber(IntegralNumber::HexNumber(_)))) - ); - parser_test!( - number, - "'o7460", - Ok((_, Number::IntegralNumber(IntegralNumber::OctalNumber(_)))) - ); + parser_test!(number, "659", Ok((_, Number::IntegralNumber(_)))); + parser_test!(number, "'h 837FF", Ok((_, Number::IntegralNumber(_)))); + parser_test!(number, "'h 837FF", Ok((_, Number::IntegralNumber(_)))); + parser_test!(number, "'o7460", Ok((_, Number::IntegralNumber(_)))); parser_test!(number, "'4af", Err(_)); - parser_test!( - number, - "4'b1001", - Ok((_, Number::IntegralNumber(IntegralNumber::BinaryNumber(_)))) - ); - parser_test!( - number, - "5 'D 3", - Ok((_, Number::IntegralNumber(IntegralNumber::DecimalNumber(_)))) - ); - parser_test!( - number, - "3'b01x", - Ok((_, Number::IntegralNumber(IntegralNumber::BinaryNumber(_)))) - ); - parser_test!( - number, - "12'hx", - Ok((_, Number::IntegralNumber(IntegralNumber::HexNumber(_)))) - ); - parser_test!( - number, - "16'hz", - Ok((_, Number::IntegralNumber(IntegralNumber::HexNumber(_)))) - ); + parser_test!(number, "4'b1001", Ok((_, Number::IntegralNumber(_)))); + parser_test!(number, "5 'D 3", Ok((_, Number::IntegralNumber(_)))); + parser_test!(number, "3'b01x", Ok((_, Number::IntegralNumber(_)))); + parser_test!(number, "12'hx", Ok((_, Number::IntegralNumber(_)))); + parser_test!(number, "16'hz", Ok((_, Number::IntegralNumber(_)))); parser_test!(number, "8 'd -6", Err(_)); - parser_test!( - number, - "4 'shf", - Ok((_, Number::IntegralNumber(IntegralNumber::HexNumber(_)))) - ); - parser_test!( - number, - "16'sd?", - Ok((_, Number::IntegralNumber(IntegralNumber::DecimalNumber(_)))) - ); - parser_test!( - number, - "27_195_000", - Ok((_, Number::IntegralNumber(IntegralNumber::DecimalNumber(_)))) - ); + parser_test!(number, "4 'shf", Ok((_, Number::IntegralNumber(_)))); + parser_test!(number, "16'sd?", Ok((_, Number::IntegralNumber(_)))); + parser_test!(number, "27_195_000", Ok((_, Number::IntegralNumber(_)))); parser_test!( number, "16'b0011_0101_0001_1111", - Ok((_, Number::IntegralNumber(IntegralNumber::BinaryNumber(_)))) + Ok((_, Number::IntegralNumber(_))) ); parser_test!( number, "32 'h 12ab_f001", - Ok((_, Number::IntegralNumber(IntegralNumber::HexNumber(_)))) - ); - parser_test!( - number, - "1.2", - Ok((_, Number::RealNumber(RealNumber::FixedPointNumber(_)))) - ); - parser_test!( - number, - "0.1", - Ok((_, Number::RealNumber(RealNumber::FixedPointNumber(_)))) - ); - parser_test!( - number, - "2394.26331", - Ok((_, Number::RealNumber(RealNumber::FixedPointNumber(_)))) - ); - parser_test!( - number, - "1.2E12", - Ok((_, Number::RealNumber(RealNumber::Floating(_)))) - ); - parser_test!( - number, - "1.30e-2", - Ok((_, Number::RealNumber(RealNumber::Floating(_)))) - ); - parser_test!( - number, - "0.1e-0", - Ok((_, Number::RealNumber(RealNumber::Floating(_)))) - ); - parser_test!( - number, - "23E10", - Ok((_, Number::RealNumber(RealNumber::Floating(_)))) - ); - parser_test!( - number, - "29E-2", - Ok((_, Number::RealNumber(RealNumber::Floating(_)))) - ); - parser_test!( - number, - "236.123_763_e-12", - Ok((_, Number::RealNumber(RealNumber::Floating(_)))) + Ok((_, Number::IntegralNumber(_))) ); + parser_test!(number, "1.2", Ok((_, Number::RealNumber(_)))); + parser_test!(number, "0.1", Ok((_, Number::RealNumber(_)))); + parser_test!(number, "2394.26331", Ok((_, Number::RealNumber(_)))); + parser_test!(number, "1.2E12", Ok((_, Number::RealNumber(_)))); + parser_test!(number, "1.30e-2", Ok((_, Number::RealNumber(_)))); + parser_test!(number, "0.1e-0", Ok((_, Number::RealNumber(_)))); + parser_test!(number, "23E10", Ok((_, Number::RealNumber(_)))); + parser_test!(number, "29E-2", Ok((_, Number::RealNumber(_)))); + parser_test!(number, "236.123_763_e-12", Ok((_, Number::RealNumber(_)))); parser_test!(number, ".12", Err(_)); parser_test!(number, "9.", Err(_)); parser_test!(number, "4.E3", Err(_)); diff --git a/src/parser/expressions/primaries.rs b/src/parser/expressions/primaries.rs index 4b09fcb..74848ee 100644 --- a/src/parser/expressions/primaries.rs +++ b/src/parser/expressions/primaries.rs @@ -10,21 +10,21 @@ use nom_packrat::packrat_parser; #[derive(Clone, Debug, Node)] pub enum ConstantPrimary { - PrimaryLiteral(PrimaryLiteral), - PsParameter(ConstantPrimaryPsParameter), - Specparam(ConstantPrimarySpecparam), - GenvarIdentifier(GenvarIdentifier), - FormalPort(ConstantPrimaryFormalPort), - Enum(ConstantPrimaryEnum), - Concatenation(ConstantPrimaryConcatenation), - MultipleConcatenation(ConstantPrimaryMultipleConcatenation), - ConstantFunctionCall(ConstantFunctionCall), - ConstantLetExpression(ConstantLetExpression), - MintypmaxExpression(ConstantPrimaryMintypmaxExpression), - ConstantCast(ConstantCast), - ConstantAssignmentPatternExpression(ConstantAssignmentPatternExpression), - TypeReference(TypeReference), - Null(Keyword), + PrimaryLiteral(Box), + PsParameter(Box), + Specparam(Box), + GenvarIdentifier(Box), + FormalPort(Box), + Enum(Box), + Concatenation(Box), + MultipleConcatenation(Box), + ConstantFunctionCall(Box), + ConstantLetExpression(Box), + MintypmaxExpression(Box), + ConstantCast(Box), + ConstantAssignmentPatternExpression(Box), + TypeReference(Box), + Null(Box), } #[derive(Clone, Debug, Node)] @@ -73,12 +73,12 @@ pub struct ConstantPrimaryMintypmaxExpression { #[derive(Clone, Debug, Node)] pub enum ModulePathPrimary { - Number(Number), - Identifier(Identifier), - ModulePathConcatenation(ModulePathConcatenation), - ModulePathMultipleConcatenation(ModulePathMultipleConcatenation), - FunctionSubroutineCall(FunctionSubroutineCall), - Mintypmax(ModulePathPrimaryMintypmax), + Number(Box), + Identifier(Box), + ModulePathConcatenation(Box), + ModulePathMultipleConcatenation(Box), + FunctionSubroutineCall(Box), + Mintypmax(Box), } #[derive(Clone, Debug, Node)] @@ -88,21 +88,21 @@ pub struct ModulePathPrimaryMintypmax { #[derive(Clone, Debug, Node)] pub enum Primary { - PrimaryLiteral(PrimaryLiteral), - Hierarchical(PrimaryHierarchical), - EmptyUnpackedArrayConcatenation(EmptyUnpackedArrayConcatenation), - Concatenation(PrimaryConcatenation), - MultipleConcatenation(PrimaryMultipleConcatenation), - FunctionSubroutineCall(FunctionSubroutineCall), - LetExpression(LetExpression), - MintypmaxExpression(PrimaryMintypmaxExpression), - Cast(Cast), - AssignmentPatternExpression(AssignmentPatternExpression), - StreamingConcatenation(StreamingConcatenation), - SequenceMethodCall(SequenceMethodCall), - This(Keyword), - Dollar(Symbol), - Null(Keyword), + PrimaryLiteral(Box), + Hierarchical(Box), + EmptyUnpackedArrayConcatenation(Box), + Concatenation(Box), + MultipleConcatenation(Box), + FunctionSubroutineCall(Box), + LetExpression(Box), + MintypmaxExpression(Box), + Cast(Box), + AssignmentPatternExpression(Box), + StreamingConcatenation(Box), + SequenceMethodCall(Box), + This(Box), + Dollar(Box), + Null(Box), } #[derive(Clone, Debug, Node)] @@ -131,8 +131,8 @@ pub struct PrimaryMintypmaxExpression { #[derive(Clone, Debug, Node)] pub enum ClassQualifierOrPackageScope { - ClassQualifier(ClassQualifier), - PackageScope(PackageScope), + ClassQualifier(Box), + PackageScope(Box), } #[derive(Clone, Debug, Node)] @@ -142,22 +142,22 @@ pub struct ClassQualifier { #[derive(Clone, Debug, Node)] pub enum RangeExpression { - Expression(Expression), - PartSelectRange(PartSelectRange), + Expression(Box), + PartSelectRange(Box), } #[derive(Clone, Debug, Node)] pub enum PrimaryLiteral { - Number(Number), - TimeLiteral(TimeLiteral), - UnbasedUnsizedLiteral(UnbasedUnsizedLiteral), - StringLiteral(StringLiteral), + Number(Box), + TimeLiteral(Box), + UnbasedUnsizedLiteral(Box), + StringLiteral(Box), } #[derive(Clone, Debug, Node)] pub enum TimeLiteral { - Unsigned(TimeLiteralUnsigned), - FixedPoint(TimeLiteralFixedPoint), + Unsigned(Box), + FixedPoint(Box), } #[derive(Clone, Debug, Node)] @@ -172,19 +172,19 @@ pub struct TimeLiteralFixedPoint { #[derive(Clone, Debug, Node)] pub enum TimeUnit { - S(Keyword), - MS(Keyword), - US(Keyword), - NS(Keyword), - PS(Keyword), - FS(Keyword), + S(Box), + MS(Box), + US(Box), + NS(Box), + PS(Box), + FS(Box), } #[derive(Clone, Debug, Node)] pub enum ImplicitClassHandle { - This(Keyword), - Super(Keyword), - ThisSuper((Keyword, Symbol, Keyword)), + This(Box), + Super(Box), + ThisSuper(Box<(Keyword, Symbol, Keyword)>), } #[derive(Clone, Debug, Node)] @@ -256,27 +256,35 @@ pub struct Cast { #[parser] pub fn constant_primary(s: Span) -> IResult { alt(( - map(keyword("null"), |x| ConstantPrimary::Null(x)), - map(primary_literal, |x| ConstantPrimary::PrimaryLiteral(x)), + map(keyword("null"), |x| ConstantPrimary::Null(Box::new(x))), + map(primary_literal, |x| { + ConstantPrimary::PrimaryLiteral(Box::new(x)) + }), constant_primary_ps_parameter, constant_primary_specparam, - map(genvar_identifier, |x| ConstantPrimary::GenvarIdentifier(x)), + map(genvar_identifier, |x| { + ConstantPrimary::GenvarIdentifier(Box::new(x)) + }), constant_primary_formal_port, constant_primary_enum, constant_primary_concatenation, constant_primary_multiple_concatenation, map(constant_function_call, |x| { - ConstantPrimary::ConstantFunctionCall(x) + ConstantPrimary::ConstantFunctionCall(Box::new(x)) }), map(constant_let_expression, |x| { - ConstantPrimary::ConstantLetExpression(x) + ConstantPrimary::ConstantLetExpression(Box::new(x)) }), constant_primary_mintypmax_expression, - map(constant_cast, |x| ConstantPrimary::ConstantCast(x)), - map(constant_assignment_pattern_expression, |x| { - ConstantPrimary::ConstantAssignmentPatternExpression(x) + map(constant_cast, |x| { + ConstantPrimary::ConstantCast(Box::new(x)) + }), + map(constant_assignment_pattern_expression, |x| { + ConstantPrimary::ConstantAssignmentPatternExpression(Box::new(x)) + }), + map(type_reference, |x| { + ConstantPrimary::TypeReference(Box::new(x)) }), - map(type_reference, |x| ConstantPrimary::TypeReference(x)), ))(s) } @@ -286,7 +294,7 @@ pub fn constant_primary_ps_parameter(s: Span) -> IResult let (s, b) = constant_select(s)?; Ok(( s, - ConstantPrimary::PsParameter(ConstantPrimaryPsParameter { nodes: (a, b) }), + ConstantPrimary::PsParameter(Box::new(ConstantPrimaryPsParameter { nodes: (a, b) })), )) } @@ -296,7 +304,7 @@ pub fn constant_primary_specparam(s: Span) -> IResult { let (s, b) = opt(bracket(constant_range_expression))(s)?; Ok(( s, - ConstantPrimary::Specparam(ConstantPrimarySpecparam { nodes: (a, b) }), + ConstantPrimary::Specparam(Box::new(ConstantPrimarySpecparam { nodes: (a, b) })), )) } @@ -306,7 +314,7 @@ pub fn constant_primary_formal_port(s: Span) -> IResult { let (s, b) = constant_select(s)?; Ok(( s, - ConstantPrimary::FormalPort(ConstantPrimaryFormalPort { nodes: (a, b) }), + ConstantPrimary::FormalPort(Box::new(ConstantPrimaryFormalPort { nodes: (a, b) })), )) } @@ -316,7 +324,7 @@ pub fn constant_primary_enum(s: Span) -> IResult { let (s, b) = enum_identifier(s)?; Ok(( s, - ConstantPrimary::Enum(ConstantPrimaryEnum { nodes: (a, b) }), + ConstantPrimary::Enum(Box::new(ConstantPrimaryEnum { nodes: (a, b) })), )) } @@ -326,7 +334,7 @@ pub fn constant_primary_concatenation(s: Span) -> IResult let (s, b) = opt(bracket(constant_range_expression))(s)?; Ok(( s, - ConstantPrimary::Concatenation(ConstantPrimaryConcatenation { nodes: (a, b) }), + ConstantPrimary::Concatenation(Box::new(ConstantPrimaryConcatenation { nodes: (a, b) })), )) } @@ -336,9 +344,9 @@ pub fn constant_primary_multiple_concatenation(s: Span) -> IResult IResult IResult { alt(( - map(number, |x| ModulePathPrimary::Number(x)), - map(identifier, |x| ModulePathPrimary::Identifier(x)), + map(number, |x| ModulePathPrimary::Number(Box::new(x))), + map(identifier, |x| ModulePathPrimary::Identifier(Box::new(x))), map(module_path_concatenation, |x| { - ModulePathPrimary::ModulePathConcatenation(x) + ModulePathPrimary::ModulePathConcatenation(Box::new(x)) }), map(module_path_multiple_concatenation, |x| { - ModulePathPrimary::ModulePathMultipleConcatenation(x) + ModulePathPrimary::ModulePathMultipleConcatenation(Box::new(x)) }), map(function_subroutine_call, |x| { - ModulePathPrimary::FunctionSubroutineCall(x) + ModulePathPrimary::FunctionSubroutineCall(Box::new(x)) }), module_path_primary_mintypmax_expression, ))(s) @@ -374,7 +384,7 @@ pub fn module_path_primary_mintypmax_expression(s: Span) -> IResult IResult IResult { alt(( - map(keyword("this"), |x| Primary::This(x)), - map(symbol("$"), |x| Primary::Dollar(x)), - map(keyword("null"), |x| Primary::Null(x)), - map(primary_literal, |x| Primary::PrimaryLiteral(x)), + map(keyword("this"), |x| Primary::This(Box::new(x))), + map(symbol("$"), |x| Primary::Dollar(Box::new(x))), + map(keyword("null"), |x| Primary::Null(Box::new(x))), + map(primary_literal, |x| Primary::PrimaryLiteral(Box::new(x))), primary_hierarchical, map(empty_unpacked_array_concatenation, |x| { - Primary::EmptyUnpackedArrayConcatenation(x) + Primary::EmptyUnpackedArrayConcatenation(Box::new(x)) }), primary_concatenation, map(function_subroutine_call, |x| { - Primary::FunctionSubroutineCall(x) + Primary::FunctionSubroutineCall(Box::new(x)) }), - map(let_expression, |x| Primary::LetExpression(x)), + map(let_expression, |x| Primary::LetExpression(Box::new(x))), primary_mintypmax_expression, - map(cast, |x| Primary::Cast(x)), + map(cast, |x| Primary::Cast(Box::new(x))), map(assignment_pattern_expression, |x| { - Primary::AssignmentPatternExpression(x) + Primary::AssignmentPatternExpression(Box::new(x)) }), map(streaming_concatenation, |x| { - Primary::StreamingConcatenation(x) + Primary::StreamingConcatenation(Box::new(x)) + }), + map(sequence_method_call, |x| { + Primary::SequenceMethodCall(Box::new(x)) }), - map(sequence_method_call, |x| Primary::SequenceMethodCall(x)), ))(s) } @@ -414,7 +426,7 @@ pub fn primary_hierarchical(s: Span) -> IResult { let (s, c) = select(s)?; Ok(( s, - Primary::Hierarchical(PrimaryHierarchical { nodes: (a, b, c) }), + Primary::Hierarchical(Box::new(PrimaryHierarchical { nodes: (a, b, c) })), )) } @@ -424,7 +436,7 @@ pub fn primary_concatenation(s: Span) -> IResult { let (s, b) = opt(bracket(range_expression))(s)?; Ok(( s, - Primary::Concatenation(PrimaryConcatenation { nodes: (a, b) }), + Primary::Concatenation(Box::new(PrimaryConcatenation { nodes: (a, b) })), )) } @@ -434,7 +446,7 @@ pub fn primary_multiple_concatenation(s: Span) -> IResult { let (s, b) = opt(bracket(range_expression))(s)?; Ok(( s, - Primary::MultipleConcatenation(PrimaryMultipleConcatenation { nodes: (a, b) }), + Primary::MultipleConcatenation(Box::new(PrimaryMultipleConcatenation { nodes: (a, b) })), )) } @@ -443,7 +455,7 @@ pub fn primary_mintypmax_expression(s: Span) -> IResult { let (s, a) = paren(mintypmax_expression)(s)?; Ok(( s, - Primary::MintypmaxExpression(PrimaryMintypmaxExpression { nodes: (a,) }), + Primary::MintypmaxExpression(Box::new(PrimaryMintypmaxExpression { nodes: (a,) })), )) } @@ -451,10 +463,10 @@ pub fn primary_mintypmax_expression(s: Span) -> IResult { pub fn class_qualifier_or_package_scope(s: Span) -> IResult { alt(( map(class_qualifier, |x| { - ClassQualifierOrPackageScope::ClassQualifier(x) + ClassQualifierOrPackageScope::ClassQualifier(Box::new(x)) }), map(package_scope, |x| { - ClassQualifierOrPackageScope::PackageScope(x) + ClassQualifierOrPackageScope::PackageScope(Box::new(x)) }), ))(s) } @@ -469,8 +481,10 @@ pub fn class_qualifier(s: Span) -> IResult { #[parser] pub fn range_expression(s: Span) -> IResult { alt(( - map(expression, |x| RangeExpression::Expression(x)), - map(part_select_range, |x| RangeExpression::PartSelectRange(x)), + map(expression, |x| RangeExpression::Expression(Box::new(x))), + map(part_select_range, |x| { + RangeExpression::PartSelectRange(Box::new(x)) + }), ))(s) } @@ -478,12 +492,14 @@ pub fn range_expression(s: Span) -> IResult { #[parser] pub fn primary_literal(s: Span) -> IResult { alt(( - map(time_literal, |x| PrimaryLiteral::TimeLiteral(x)), - map(number, |x| PrimaryLiteral::Number(x)), + map(time_literal, |x| PrimaryLiteral::TimeLiteral(Box::new(x))), + map(number, |x| PrimaryLiteral::Number(Box::new(x))), map(unbased_unsized_literal, |x| { - PrimaryLiteral::UnbasedUnsizedLiteral(x) + PrimaryLiteral::UnbasedUnsizedLiteral(Box::new(x)) + }), + map(string_literal, |x| { + PrimaryLiteral::StringLiteral(Box::new(x)) }), - map(string_literal, |x| PrimaryLiteral::StringLiteral(x)), ))(s) } @@ -498,7 +514,7 @@ pub fn time_literal_unsigned(s: Span) -> IResult { let (s, b) = time_unit(s)?; Ok(( s, - TimeLiteral::Unsigned(TimeLiteralUnsigned { nodes: (a, b) }), + TimeLiteral::Unsigned(Box::new(TimeLiteralUnsigned { nodes: (a, b) })), )) } @@ -508,19 +524,19 @@ pub fn time_literal_fixed_point(s: Span) -> IResult { let (s, b) = time_unit(s)?; Ok(( s, - TimeLiteral::FixedPoint(TimeLiteralFixedPoint { nodes: (a, b) }), + TimeLiteral::FixedPoint(Box::new(TimeLiteralFixedPoint { nodes: (a, b) })), )) } #[parser] pub fn time_unit(s: Span) -> IResult { alt(( - map(keyword("s"), |x| TimeUnit::S(x)), - map(keyword("ms"), |x| TimeUnit::MS(x)), - map(keyword("us"), |x| TimeUnit::US(x)), - map(keyword("ns"), |x| TimeUnit::NS(x)), - map(keyword("ps"), |x| TimeUnit::PS(x)), - map(keyword("fs"), |x| TimeUnit::FS(x)), + map(keyword("s"), |x| TimeUnit::S(Box::new(x))), + map(keyword("ms"), |x| TimeUnit::MS(Box::new(x))), + map(keyword("us"), |x| TimeUnit::US(Box::new(x))), + map(keyword("ns"), |x| TimeUnit::NS(Box::new(x))), + map(keyword("ps"), |x| TimeUnit::PS(Box::new(x))), + map(keyword("fs"), |x| TimeUnit::FS(Box::new(x))), ))(s) } @@ -529,10 +545,12 @@ pub fn implicit_class_handle(s: Span) -> IResult { alt(( map( triple(keyword("this"), symbol("."), keyword("super")), - |(x, y, z)| ImplicitClassHandle::ThisSuper((x, y, z)), + |(x, y, z)| ImplicitClassHandle::ThisSuper(Box::new((x, y, z))), ), - map(keyword("this"), |x| ImplicitClassHandle::This(x)), - map(keyword("super"), |x| ImplicitClassHandle::Super(x)), + map(keyword("this"), |x| ImplicitClassHandle::This(Box::new(x))), + map(keyword("super"), |x| { + ImplicitClassHandle::Super(Box::new(x)) + }), ))(s) } @@ -613,36 +631,11 @@ mod tests { #[test] fn test_primary() { - parser_test!( - primary, - "2.1ns ", - Ok((_, Primary::PrimaryLiteral(PrimaryLiteral::TimeLiteral(_)))) - ); - parser_test!( - primary, - "40 ps ", - Ok((_, Primary::PrimaryLiteral(PrimaryLiteral::TimeLiteral(_)))) - ); - parser_test!( - primary, - "'0", - Ok( - ( - _, - Primary::PrimaryLiteral(PrimaryLiteral::UnbasedUnsizedLiteral(_)) - ), - ) - ); - parser_test!( - primary, - "10", - Ok((_, Primary::PrimaryLiteral(PrimaryLiteral::Number(_)))) - ); - parser_test!( - primary, - "\"aaa\"", - Ok((_, Primary::PrimaryLiteral(PrimaryLiteral::StringLiteral(_)))) - ); + parser_test!(primary, "2.1ns ", Ok((_, Primary::PrimaryLiteral(_)))); + parser_test!(primary, "40 ps ", Ok((_, Primary::PrimaryLiteral(_)))); + parser_test!(primary, "'0", Ok((_, Primary::PrimaryLiteral(_)))); + parser_test!(primary, "10", Ok((_, Primary::PrimaryLiteral(_)))); + parser_test!(primary, "\"aaa\"", Ok((_, Primary::PrimaryLiteral(_)))); parser_test!(primary, "this ", Ok((_, Primary::This(_)))); parser_test!(primary, "$", Ok((_, Primary::Dollar(_)))); parser_test!(primary, "null ", Ok((_, Primary::Null(_)))); diff --git a/src/parser/expressions/subroutine_calls.rs b/src/parser/expressions/subroutine_calls.rs index 22cb3b9..25a80c8 100644 --- a/src/parser/expressions/subroutine_calls.rs +++ b/src/parser/expressions/subroutine_calls.rs @@ -25,9 +25,9 @@ pub struct TfCall { #[derive(Clone, Debug, Node)] pub enum SystemTfCall { - ArgOptionl(SystemTfCallArgOptional), - ArgDataType(SystemTfCallArgDataType), - ArgExpression(SystemTfCallArgExpression), + ArgOptionl(Box), + ArgDataType(Box), + ArgExpression(Box), } #[derive(Clone, Debug, Node)] @@ -74,8 +74,8 @@ pub struct FunctionSubroutineCall { #[derive(Clone, Debug, Node)] pub enum ListOfArguments { - Ordered(ListOfArgumentsOrdered), - Named(ListOfArgumentsNamed), + Ordered(Box), + Named(Box), } #[derive(Clone, Debug, Node)] @@ -103,8 +103,8 @@ pub struct MethodCall { #[derive(Clone, Debug, Node)] pub enum MethodCallBody { - User(MethodCallBodyUser), - BuiltInMethodCall(BuiltInMethodCall), + User(Box), + BuiltInMethodCall(Box), } #[derive(Clone, Debug, Node)] @@ -118,8 +118,8 @@ pub struct MethodCallBodyUser { #[derive(Clone, Debug, Node)] pub enum BuiltInMethodCall { - ArrayManipulationCall(ArrayManipulationCall), - RandomizeCall(RandomizeCall), + ArrayManipulationCall(Box), + RandomizeCall(Box), } #[derive(Clone, Debug, Node)] @@ -148,23 +148,23 @@ pub struct RandomizeCall { #[derive(Clone, Debug, Node)] pub enum VariableIdentifierListOrNull { - VariableIdentifierList(VariableIdentifierList), - Null(Keyword), + VariableIdentifierList(Box), + Null(Box), } #[derive(Clone, Debug, Node)] pub enum MethodCallRoot { - Primary(Primary), - ImplicitClassHandle(ImplicitClassHandle), + Primary(Box), + ImplicitClassHandle(Box), } #[derive(Clone, Debug, Node)] pub enum ArrayMethodName { - MethodIdentifier(MethodIdentifier), - Unique(Keyword), - And(Keyword), - Or(Keyword), - Xor(Keyword), + MethodIdentifier(Box), + Unique(Box), + And(Box), + Or(Box), + Xor(Box), } // ----------------------------------------------------------------------------- @@ -198,7 +198,7 @@ pub fn system_tf_call_arg_optional(s: Span) -> IResult { let (s, b) = opt(paren(list_of_arguments))(s)?; Ok(( s, - SystemTfCall::ArgOptionl(SystemTfCallArgOptional { nodes: (a, b) }), + SystemTfCall::ArgOptionl(Box::new(SystemTfCallArgOptional { nodes: (a, b) })), )) } @@ -208,7 +208,7 @@ pub fn system_tf_call_arg_data_type(s: Span) -> IResult { let (s, b) = paren(pair(data_type, opt(pair(symbol(","), expression))))(s)?; Ok(( s, - SystemTfCall::ArgDataType(SystemTfCallArgDataType { nodes: (a, b) }), + SystemTfCall::ArgDataType(Box::new(SystemTfCallArgDataType { nodes: (a, b) })), )) } @@ -221,7 +221,7 @@ pub fn system_tf_call_arg_expression(s: Span) -> IResult { ))(s)?; Ok(( s, - SystemTfCall::ArgExpression(SystemTfCallArgExpression { nodes: (a, b) }), + SystemTfCall::ArgExpression(Box::new(SystemTfCallArgExpression { nodes: (a, b) })), )) } @@ -269,7 +269,7 @@ pub fn list_of_arguments_ordered(s: Span) -> IResult { )))(s)?; Ok(( s, - ListOfArguments::Ordered(ListOfArgumentsOrdered { nodes: (a, b) }), + ListOfArguments::Ordered(Box::new(ListOfArgumentsOrdered { nodes: (a, b) })), )) } @@ -286,9 +286,9 @@ pub fn list_of_arguments_named(s: Span) -> IResult { )))(s)?; Ok(( s, - ListOfArguments::Named(ListOfArgumentsNamed { + ListOfArguments::Named(Box::new(ListOfArgumentsNamed { nodes: (a, b, c, d), - }), + })), )) } @@ -306,7 +306,7 @@ pub fn method_call_body(s: Span) -> IResult { alt(( method_call_body_user, map(built_in_method_call, |x| { - MethodCallBody::BuiltInMethodCall(x) + MethodCallBody::BuiltInMethodCall(Box::new(x)) }), ))(s) } @@ -318,7 +318,7 @@ pub fn method_call_body_user(s: Span) -> IResult { let (s, c) = opt(paren(list_of_arguments))(s)?; Ok(( s, - MethodCallBody::User(MethodCallBodyUser { nodes: (a, b, c) }), + MethodCallBody::User(Box::new(MethodCallBodyUser { nodes: (a, b, c) })), )) } @@ -326,9 +326,11 @@ pub fn method_call_body_user(s: Span) -> IResult { pub fn built_in_method_call(s: Span) -> IResult { alt(( map(array_manipulation_call, |x| { - BuiltInMethodCall::ArrayManipulationCall(x) + BuiltInMethodCall::ArrayManipulationCall(Box::new(x)) + }), + map(randomize_call, |x| { + BuiltInMethodCall::RandomizeCall(Box::new(x)) }), - map(randomize_call, |x| BuiltInMethodCall::RandomizeCall(x)), ))(s) } @@ -368,18 +370,20 @@ pub fn randomize_call(s: Span) -> IResult { pub fn variable_identifier_list_or_null(s: Span) -> IResult { alt(( map(variable_identifier_list, |x| { - VariableIdentifierListOrNull::VariableIdentifierList(x) + VariableIdentifierListOrNull::VariableIdentifierList(Box::new(x)) + }), + map(keyword("null"), |x| { + VariableIdentifierListOrNull::Null(Box::new(x)) }), - map(keyword("null"), |x| VariableIdentifierListOrNull::Null(x)), ))(s) } #[parser] pub fn method_call_root(s: Span) -> IResult { alt(( - map(primary, |x| MethodCallRoot::Primary(x)), + map(primary, |x| MethodCallRoot::Primary(Box::new(x))), map(implicit_class_handle, |x| { - MethodCallRoot::ImplicitClassHandle(x) + MethodCallRoot::ImplicitClassHandle(Box::new(x)) }), ))(s) } @@ -387,11 +391,13 @@ pub fn method_call_root(s: Span) -> IResult { #[parser] pub fn array_method_name(s: Span) -> IResult { alt(( - map(keyword("unique"), |x| ArrayMethodName::Unique(x)), - map(keyword("and"), |x| ArrayMethodName::And(x)), - map(keyword("or"), |x| ArrayMethodName::Or(x)), - map(keyword("xor"), |x| ArrayMethodName::Xor(x)), - map(method_identifier, |x| ArrayMethodName::MethodIdentifier(x)), + map(keyword("unique"), |x| ArrayMethodName::Unique(Box::new(x))), + map(keyword("and"), |x| ArrayMethodName::And(Box::new(x))), + map(keyword("or"), |x| ArrayMethodName::Or(Box::new(x))), + map(keyword("xor"), |x| ArrayMethodName::Xor(Box::new(x))), + map(method_identifier, |x| { + ArrayMethodName::MethodIdentifier(Box::new(x)) + }), ))(s) } diff --git a/src/parser/general/identifiers.rs b/src/parser/general/identifiers.rs index b6c192d..fbab891 100644 --- a/src/parser/general/identifiers.rs +++ b/src/parser/general/identifiers.rs @@ -201,8 +201,8 @@ pub struct HierarchicalVariableIdentifier { #[derive(Clone, Debug, Node)] pub enum Identifier { - SimpleIdentifier(SimpleIdentifier), - EscapedIdentifier(EscapedIdentifier), + SimpleIdentifier(Box), + EscapedIdentifier(Box), } #[derive(Clone, Debug, Node)] @@ -282,8 +282,8 @@ pub struct PackageIdentifier { #[derive(Clone, Debug, Node)] pub enum PackageScope { - Package(PackageScopePackage), - Unit(Unit), + Package(Box), + Unit(Box), } #[derive(Clone, Debug, Node)] @@ -351,8 +351,8 @@ pub struct PsOrHierarchicalArrayIdentifier { #[derive(Clone, Debug, Node)] pub enum PsOrHierarchicalNetIdentifier { - PackageScope(PsOrHierarchicalNetIdentifierPackageScope), - HierarchicalNetIdentifier(HierarchicalNetIdentifier), + PackageScope(Box), + HierarchicalNetIdentifier(Box), } #[derive(Clone, Debug, Node)] @@ -367,8 +367,8 @@ pub struct PsOrHierarchicalNetIdentifierHierarchical { #[derive(Clone, Debug, Node)] pub enum PsOrHierarchicalPropertyIdentifier { - PackageScope(PsOrHierarchicalPropertyIdentifierPackageScope), - HierarchicalPropertyIdentifier(HierarchicalPropertyIdentifier), + PackageScope(Box), + HierarchicalPropertyIdentifier(Box), } #[derive(Clone, Debug, Node)] @@ -383,8 +383,8 @@ pub struct PsOrHierarchicalPropertyIdentifierHierarchical { #[derive(Clone, Debug, Node)] pub enum PsOrHierarchicalSequenceIdentifier { - PackageScope(PsOrHierarchicalSequenceIdentifierPackageScope), - HierarchicalSequenceIdentifier(HierarchicalSequenceIdentifier), + PackageScope(Box), + HierarchicalSequenceIdentifier(Box), } #[derive(Clone, Debug, Node)] @@ -399,8 +399,8 @@ pub struct PsOrHierarchicalSequenceIdentifierHierarchical { #[derive(Clone, Debug, Node)] pub enum PsOrHierarchicalTfIdentifier { - PackageScope(PsOrHierarchicalTfIdentifierPackageScope), - HierarchicalTfIdentifier(HierarchicalTfIdentifier), + PackageScope(Box), + HierarchicalTfIdentifier(Box), } #[derive(Clone, Debug, Node)] @@ -415,8 +415,8 @@ pub struct PsOrHierarchicalTfIdentifierHierarchical { #[derive(Clone, Debug, Node)] pub enum PsParameterIdentifier { - Scope(PsParameterIdentifierScope), - Generate(PsParameterIdentifierGenerate), + Scope(Box), + Generate(Box), } #[derive(Clone, Debug, Node)] @@ -443,9 +443,9 @@ pub struct PsTypeIdentifier { #[derive(Clone, Debug, Node)] pub enum LocalOrPackageScopeOrClassScope { - Local(Local), - PackageScope(PackageScope), - ClassScope(ClassScope), + Local(Box), + PackageScope(Box), + ClassScope(Box), } #[derive(Clone, Debug, Node)] @@ -515,27 +515,27 @@ pub struct VariableIdentifier { #[derive(Clone, Debug, Node)] pub enum ImplicitClassHandleOrClassScopeOrPackageScope { - ImplicitClassHandle((ImplicitClassHandle, Symbol)), - ClassScope(ClassScope), - PackageScope(PackageScope), + ImplicitClassHandle(Box<(ImplicitClassHandle, Symbol)>), + ClassScope(Box), + PackageScope(Box), } #[derive(Clone, Debug, Node)] pub enum ImplicitClassHandleOrPackageScope { - ImplicitClassHandle((ImplicitClassHandle, Symbol)), - PackageScope(PackageScope), + ImplicitClassHandle(Box<(ImplicitClassHandle, Symbol)>), + PackageScope(Box), } #[derive(Clone, Debug, Node)] pub enum ImplicitClassHandleOrClassScope { - ImplicitClassHandle((ImplicitClassHandle, Symbol)), - ClassScope(ClassScope), + ImplicitClassHandle(Box<(ImplicitClassHandle, Symbol)>), + ClassScope(Box), } #[derive(Clone, Debug, Node)] pub enum PackageScopeOrClassScope { - PackageScope(PackageScope), - ClassScope(ClassScope), + PackageScope(Box), + ClassScope(Box), } // ----------------------------------------------------------------------------- @@ -790,8 +790,12 @@ pub fn hierarchical_variable_identifier(s: Span) -> IResult IResult { alt(( - map(escaped_identifier, |x| Identifier::EscapedIdentifier(x)), - map(simple_identifier, |x| Identifier::SimpleIdentifier(x)), + map(escaped_identifier, |x| { + Identifier::EscapedIdentifier(Box::new(x)) + }), + map(simple_identifier, |x| { + Identifier::SimpleIdentifier(Box::new(x)) + }), ))(s) } @@ -888,7 +892,10 @@ pub fn package_identifier(s: Span) -> IResult { #[packrat_parser] #[parser] pub fn package_scope(s: Span) -> IResult { - alt((package_scope_package, map(unit, |x| PackageScope::Unit(x))))(s) + alt(( + package_scope_package, + map(unit, |x| PackageScope::Unit(Box::new(x))), + ))(s) } #[parser] @@ -897,7 +904,7 @@ pub fn package_scope_package(s: Span) -> IResult { let (s, b) = symbol("::")(s)?; Ok(( s, - PackageScope::Package(PackageScopePackage { nodes: (a, b) }), + PackageScope::Package(Box::new(PackageScopePackage { nodes: (a, b) })), )) } @@ -980,7 +987,7 @@ pub fn ps_or_hierarchical_net_identifier(s: Span) -> IResult IResult IResult IResult IResult { alt(( map(pair(implicit_class_handle, symbol(".")), |x| { - ImplicitClassHandleOrClassScopeOrPackageScope::ImplicitClassHandle(x) + ImplicitClassHandleOrClassScopeOrPackageScope::ImplicitClassHandle(Box::new(x)) }), map(class_scope, |x| { - ImplicitClassHandleOrClassScopeOrPackageScope::ClassScope(x) + ImplicitClassHandleOrClassScopeOrPackageScope::ClassScope(Box::new(x)) }), map(package_scope, |x| { - ImplicitClassHandleOrClassScopeOrPackageScope::PackageScope(x) + ImplicitClassHandleOrClassScopeOrPackageScope::PackageScope(Box::new(x)) }), ))(s) } @@ -1236,10 +1243,10 @@ pub fn implicit_class_handle_or_package_scope( ) -> IResult { alt(( map(pair(implicit_class_handle, symbol(".")), |x| { - ImplicitClassHandleOrPackageScope::ImplicitClassHandle(x) + ImplicitClassHandleOrPackageScope::ImplicitClassHandle(Box::new(x)) }), map(package_scope, |x| { - ImplicitClassHandleOrPackageScope::PackageScope(x) + ImplicitClassHandleOrPackageScope::PackageScope(Box::new(x)) }), ))(s) } @@ -1250,10 +1257,10 @@ pub fn implicit_class_handle_or_class_scope( ) -> IResult { alt(( map(pair(implicit_class_handle, symbol(".")), |x| { - ImplicitClassHandleOrClassScope::ImplicitClassHandle(x) + ImplicitClassHandleOrClassScope::ImplicitClassHandle(Box::new(x)) }), map(class_scope, |x| { - ImplicitClassHandleOrClassScope::ClassScope(x) + ImplicitClassHandleOrClassScope::ClassScope(Box::new(x)) }), ))(s) } @@ -1261,8 +1268,12 @@ pub fn implicit_class_handle_or_class_scope( #[parser] pub fn package_scope_or_class_scope(s: Span) -> IResult { alt(( - map(package_scope, |x| PackageScopeOrClassScope::PackageScope(x)), - map(class_scope, |x| PackageScopeOrClassScope::ClassScope(x)), + map(package_scope, |x| { + PackageScopeOrClassScope::PackageScope(Box::new(x)) + }), + map(class_scope, |x| { + PackageScopeOrClassScope::ClassScope(Box::new(x)) + }), ))(s) } @@ -1271,12 +1282,14 @@ pub fn local_or_package_scope_or_class_scope( s: Span, ) -> IResult { alt(( - map(local, |x| LocalOrPackageScopeOrClassScope::Local(x)), + map(local, |x| { + LocalOrPackageScopeOrClassScope::Local(Box::new(x)) + }), map(package_scope, |x| { - LocalOrPackageScopeOrClassScope::PackageScope(x) + LocalOrPackageScopeOrClassScope::PackageScope(Box::new(x)) }), map(class_scope, |x| { - LocalOrPackageScopeOrClassScope::ClassScope(x) + LocalOrPackageScopeOrClassScope::ClassScope(Box::new(x)) }), ))(s) } diff --git a/src/parser/instantiations/checker_instantiation.rs b/src/parser/instantiations/checker_instantiation.rs index db9f80f..5a06a45 100644 --- a/src/parser/instantiations/checker_instantiation.rs +++ b/src/parser/instantiations/checker_instantiation.rs @@ -19,8 +19,8 @@ pub struct CheckerInstantiation { #[derive(Clone, Debug, Node)] pub enum ListOfCheckerPortConnections { - Ordered(ListOfCheckerPortConnectionsOrdered), - Named(ListOfCheckerPortConnectionsNamed), + Ordered(Box), + Named(Box), } #[derive(Clone, Debug, Node)] @@ -40,8 +40,8 @@ pub struct OrderedCheckerPortConnection { #[derive(Clone, Debug, Node)] pub enum NamedCheckerPortConnection { - Identifier(NamedCheckerPortConnectionIdentifier), - Asterisk(NamedCheckerPortConnectionAsterisk), + Identifier(Box), + Asterisk(Box), } #[derive(Clone, Debug, Node)] @@ -90,7 +90,9 @@ pub fn list_of_checker_port_connections_ordered( let (s, a) = list(symbol(","), ordered_checker_port_connection)(s)?; Ok(( s, - ListOfCheckerPortConnections::Ordered(ListOfCheckerPortConnectionsOrdered { nodes: (a,) }), + ListOfCheckerPortConnections::Ordered(Box::new(ListOfCheckerPortConnectionsOrdered { + nodes: (a,), + })), )) } @@ -101,7 +103,9 @@ pub fn list_of_checker_port_connections_named( let (s, a) = list(symbol(","), named_checker_port_connection)(s)?; Ok(( s, - ListOfCheckerPortConnections::Named(ListOfCheckerPortConnectionsNamed { nodes: (a,) }), + ListOfCheckerPortConnections::Named(Box::new(ListOfCheckerPortConnectionsNamed { + nodes: (a,), + })), )) } @@ -130,9 +134,9 @@ pub fn named_checker_port_connection_identifier( let (s, d) = opt(paren(opt(property_actual_arg)))(s)?; Ok(( s, - NamedCheckerPortConnection::Identifier(NamedCheckerPortConnectionIdentifier { + NamedCheckerPortConnection::Identifier(Box::new(NamedCheckerPortConnectionIdentifier { nodes: (a, b, c, d), - }), + })), )) } @@ -144,7 +148,9 @@ pub fn named_checker_port_connection_asterisk( let (s, b) = symbol(".*")(s)?; Ok(( s, - NamedCheckerPortConnection::Asterisk(NamedCheckerPortConnectionAsterisk { nodes: (a, b) }), + NamedCheckerPortConnection::Asterisk(Box::new(NamedCheckerPortConnectionAsterisk { + nodes: (a, b), + })), )) } diff --git a/src/parser/instantiations/generated_instantiation.rs b/src/parser/instantiations/generated_instantiation.rs index 4e0a92b..b1c4731 100644 --- a/src/parser/instantiations/generated_instantiation.rs +++ b/src/parser/instantiations/generated_instantiation.rs @@ -40,9 +40,9 @@ pub struct Genvar { #[derive(Clone, Debug, Node)] pub enum GenvarIteration { - Assignment(GenvarIterationAssignment), - Prefix(GenvarIterationPrefix), - Suffix(GenvarIterationSuffix), + Assignment(Box), + Prefix(Box), + Suffix(Box), } #[derive(Clone, Debug, Node)] @@ -62,8 +62,8 @@ pub struct GenvarIterationSuffix { #[derive(Clone, Debug, Node)] pub enum ConditionalGenerateConstruct { - If(IfGenerateConstruct), - Case(CaseGenerateConstruct), + If(Box), + Case(Box), } #[derive(Clone, Debug, Node)] @@ -88,8 +88,8 @@ pub struct CaseGenerateConstruct { #[derive(Clone, Debug, Node)] pub enum CaseGenerateItem { - Nondefault(CaseGenerateItemNondefault), - Default(CaseGenerateItemDefault), + Nondefault(Box), + Default(Box), } #[derive(Clone, Debug, Node)] @@ -104,8 +104,8 @@ pub struct CaseGenerateItemDefault { #[derive(Clone, Debug, Node)] pub enum GenerateBlock { - GenerateItem(GenerateItem), - Multiple(GenerateBlockMultiple), + GenerateItem(Box), + Multiple(Box), } #[derive(Clone, Debug, Node)] @@ -122,9 +122,9 @@ pub struct GenerateBlockMultiple { #[derive(Clone, Debug, Node)] pub enum GenerateItem { - ModuleOrGenerateItem(ModuleOrGenerateItem), - InterfaceOrGenerateItem(InterfaceOrGenerateItem), - CheckerOrGenerateItem(CheckerOrGenerateItem), + ModuleOrGenerateItem(Box), + InterfaceOrGenerateItem(Box), + CheckerOrGenerateItem(Box), } // ----------------------------------------------------------------------------- @@ -181,7 +181,7 @@ pub fn genvar_iteration_assignment(s: Span) -> IResult { let (s, c) = genvar_expression(s)?; Ok(( s, - GenvarIteration::Assignment(GenvarIterationAssignment { nodes: (a, b, c) }), + GenvarIteration::Assignment(Box::new(GenvarIterationAssignment { nodes: (a, b, c) })), )) } @@ -191,7 +191,7 @@ pub fn genvar_iteration_prefix(s: Span) -> IResult { let (s, b) = genvar_identifier(s)?; Ok(( s, - GenvarIteration::Prefix(GenvarIterationPrefix { nodes: (a, b) }), + GenvarIteration::Prefix(Box::new(GenvarIterationPrefix { nodes: (a, b) })), )) } @@ -201,7 +201,7 @@ pub fn genvar_iteration_suffix(s: Span) -> IResult { let (s, b) = inc_or_dec_operator(s)?; Ok(( s, - GenvarIteration::Suffix(GenvarIterationSuffix { nodes: (a, b) }), + GenvarIteration::Suffix(Box::new(GenvarIterationSuffix { nodes: (a, b) })), )) } @@ -209,10 +209,10 @@ pub fn genvar_iteration_suffix(s: Span) -> IResult { pub fn conditional_generate_construct(s: Span) -> IResult { alt(( map(if_generate_construct, |x| { - ConditionalGenerateConstruct::If(x) + ConditionalGenerateConstruct::If(Box::new(x)) }), map(case_generate_construct, |x| { - ConditionalGenerateConstruct::Case(x) + ConditionalGenerateConstruct::Case(Box::new(x)) }), ))(s) } @@ -257,7 +257,7 @@ pub fn case_generate_item_nondefault(s: Span) -> IResult let (s, c) = generate_block(s)?; Ok(( s, - CaseGenerateItem::Nondefault(CaseGenerateItemNondefault { nodes: (a, b, c) }), + CaseGenerateItem::Nondefault(Box::new(CaseGenerateItemNondefault { nodes: (a, b, c) })), )) } @@ -268,14 +268,14 @@ pub fn case_generate_item_default(s: Span) -> IResult { let (s, c) = generate_block(s)?; Ok(( s, - CaseGenerateItem::Default(CaseGenerateItemDefault { nodes: (a, b, c) }), + CaseGenerateItem::Default(Box::new(CaseGenerateItemDefault { nodes: (a, b, c) })), )) } #[parser] pub fn generate_block(s: Span) -> IResult { alt(( - map(generate_item, |x| GenerateBlock::GenerateItem(x)), + map(generate_item, |x| GenerateBlock::GenerateItem(Box::new(x))), generate_block_multiple, ))(s) } @@ -290,9 +290,9 @@ pub fn generate_block_multiple(s: Span) -> IResult { let (s, f) = opt(pair(symbol(":"), generate_block_identifier))(s)?; Ok(( s, - GenerateBlock::Multiple(GenerateBlockMultiple { + GenerateBlock::Multiple(Box::new(GenerateBlockMultiple { nodes: (a, b, c, d, e, f), - }), + })), )) } @@ -300,13 +300,13 @@ pub fn generate_block_multiple(s: Span) -> IResult { pub fn generate_item(s: Span) -> IResult { alt(( map(module_or_generate_item, |x| { - GenerateItem::ModuleOrGenerateItem(x) + GenerateItem::ModuleOrGenerateItem(Box::new(x)) }), map(interface_or_generate_item, |x| { - GenerateItem::InterfaceOrGenerateItem(x) + GenerateItem::InterfaceOrGenerateItem(Box::new(x)) }), map(checker_or_generate_item, |x| { - GenerateItem::CheckerOrGenerateItem(x) + GenerateItem::CheckerOrGenerateItem(Box::new(x)) }), ))(s) } diff --git a/src/parser/instantiations/module_instantiation.rs b/src/parser/instantiations/module_instantiation.rs index 73e3d3e..df884ea 100644 --- a/src/parser/instantiations/module_instantiation.rs +++ b/src/parser/instantiations/module_instantiation.rs @@ -24,8 +24,8 @@ pub struct ParameterValueAssignment { #[derive(Clone, Debug, Node)] pub enum ListOfParameterAssignments { - Ordered(ListOfParameterAssignmentsOrdered), - Named(ListOfParameterAssignmentsNamed), + Ordered(Box), + Named(Box), } #[derive(Clone, Debug, Node)] @@ -60,8 +60,8 @@ pub struct NameOfInstance { #[derive(Clone, Debug, Node)] pub enum ListOfPortConnections { - Ordered(ListOfPortConnectionsOrdered), - Named(ListOfPortConnectionsNamed), + Ordered(Box), + Named(Box), } #[derive(Clone, Debug, Node)] @@ -81,8 +81,8 @@ pub struct OrderedPortConnection { #[derive(Clone, Debug, Node)] pub enum NamedPortConnection { - Identifier(NamedPortConnectionIdentifier), - Asterisk(NamedPortConnectionAsterisk), + Identifier(Box), + Asterisk(Box), } #[derive(Clone, Debug, Node)] @@ -136,7 +136,9 @@ pub fn list_of_parameter_assignments_ordered(s: Span) -> IResult IResult IResult IResult IResult IResult), + Enable(Box), + Mos(Box), + NInput(Box), + NOutput(Box), + PassEn(Box), + Pass(Box), + Pulldown(Box), + Pullup(Box), } #[derive(Clone, Debug, Node)] @@ -214,9 +214,9 @@ pub fn gate_instantiation_cmos(s: Span) -> IResult { let (s, d) = symbol(";")(s)?; Ok(( s, - GateInstantiation::Cmos(GateInstantiationCmos { + GateInstantiation::Cmos(Box::new(GateInstantiationCmos { nodes: (a, b, c, d), - }), + })), )) } @@ -229,9 +229,9 @@ pub fn gate_instantiation_enable(s: Span) -> IResult { let (s, e) = symbol(";")(s)?; Ok(( s, - GateInstantiation::Enable(GateInstantiationEnable { + GateInstantiation::Enable(Box::new(GateInstantiationEnable { nodes: (a, b, c, d, e), - }), + })), )) } @@ -243,9 +243,9 @@ pub fn gate_instantiation_mos(s: Span) -> IResult { let (s, d) = symbol(";")(s)?; Ok(( s, - GateInstantiation::Mos(GateInstantiationMos { + GateInstantiation::Mos(Box::new(GateInstantiationMos { nodes: (a, b, c, d), - }), + })), )) } @@ -258,9 +258,9 @@ pub fn gate_instantiation_n_input(s: Span) -> IResult { let (s, e) = symbol(";")(s)?; Ok(( s, - GateInstantiation::NInput(GateInstantiationNInput { + GateInstantiation::NInput(Box::new(GateInstantiationNInput { nodes: (a, b, c, d, e), - }), + })), )) } @@ -273,9 +273,9 @@ pub fn gate_instantiation_n_output(s: Span) -> IResult let (s, e) = symbol(";")(s)?; Ok(( s, - GateInstantiation::NOutput(GateInstantiationNOutput { + GateInstantiation::NOutput(Box::new(GateInstantiationNOutput { nodes: (a, b, c, d, e), - }), + })), )) } @@ -287,9 +287,9 @@ pub fn gate_instantiation_pass_en(s: Span) -> IResult { let (s, d) = symbol(";")(s)?; Ok(( s, - GateInstantiation::PassEn(GateInstantiationPassEn { + GateInstantiation::PassEn(Box::new(GateInstantiationPassEn { nodes: (a, b, c, d), - }), + })), )) } @@ -300,7 +300,7 @@ pub fn gate_instantiation_pass(s: Span) -> IResult { let (s, c) = symbol(";")(s)?; Ok(( s, - GateInstantiation::Pass(GateInstantiationPass { nodes: (a, b, c) }), + GateInstantiation::Pass(Box::new(GateInstantiationPass { nodes: (a, b, c) })), )) } @@ -312,9 +312,9 @@ pub fn gate_instantiation_pulldown(s: Span) -> IResult let (s, d) = symbol(";")(s)?; Ok(( s, - GateInstantiation::Pulldown(GateInstantiationPulldown { + GateInstantiation::Pulldown(Box::new(GateInstantiationPulldown { nodes: (a, b, c, d), - }), + })), )) } @@ -326,9 +326,9 @@ pub fn gate_instantiation_pullup(s: Span) -> IResult { let (s, d) = symbol(";")(s)?; Ok(( s, - GateInstantiation::Pullup(GateInstantiationPullup { + GateInstantiation::Pullup(Box::new(GateInstantiationPullup { nodes: (a, b, c, d), - }), + })), )) } diff --git a/src/parser/primitive_instances/primitive_strengths.rs b/src/parser/primitive_instances/primitive_strengths.rs index 817004a..28a1b8b 100644 --- a/src/parser/primitive_instances/primitive_strengths.rs +++ b/src/parser/primitive_instances/primitive_strengths.rs @@ -7,9 +7,9 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum PulldownStrength { - Strength01(PulldownStrength01), - Strength10(PulldownStrength10), - Strength0(PulldownStrength0), + Strength01(Box), + Strength10(Box), + Strength0(Box), } #[derive(Clone, Debug, Node)] @@ -29,9 +29,9 @@ pub struct PulldownStrength0 { #[derive(Clone, Debug, Node)] pub enum PullupStrength { - Strength01(PullupStrength01), - Strength10(PullupStrength10), - Strength1(PullupStrength1), + Strength01(Box), + Strength10(Box), + Strength1(Box), } #[derive(Clone, Debug, Node)] @@ -61,7 +61,7 @@ pub fn pulldown_strength01(s: Span) -> IResult { let (s, a) = paren(triple(strength0, symbol(","), strength1))(s)?; Ok(( s, - PulldownStrength::Strength01(PulldownStrength01 { nodes: (a,) }), + PulldownStrength::Strength01(Box::new(PulldownStrength01 { nodes: (a,) })), )) } @@ -70,7 +70,7 @@ pub fn pulldown_strength10(s: Span) -> IResult { let (s, a) = paren(triple(strength1, symbol(","), strength0))(s)?; Ok(( s, - PulldownStrength::Strength10(PulldownStrength10 { nodes: (a,) }), + PulldownStrength::Strength10(Box::new(PulldownStrength10 { nodes: (a,) })), )) } @@ -79,7 +79,7 @@ pub fn pulldown_strength0(s: Span) -> IResult { let (s, a) = paren(strength0)(s)?; Ok(( s, - PulldownStrength::Strength0(PulldownStrength0 { nodes: (a,) }), + PulldownStrength::Strength0(Box::new(PulldownStrength0 { nodes: (a,) })), )) } @@ -93,7 +93,7 @@ pub fn pullup_strength01(s: Span) -> IResult { let (s, a) = paren(triple(strength0, symbol(","), strength1))(s)?; Ok(( s, - PullupStrength::Strength01(PullupStrength01 { nodes: (a,) }), + PullupStrength::Strength01(Box::new(PullupStrength01 { nodes: (a,) })), )) } @@ -102,7 +102,7 @@ pub fn pullup_strength10(s: Span) -> IResult { let (s, a) = paren(triple(strength1, symbol(","), strength0))(s)?; Ok(( s, - PullupStrength::Strength10(PullupStrength10 { nodes: (a,) }), + PullupStrength::Strength10(Box::new(PullupStrength10 { nodes: (a,) })), )) } @@ -111,7 +111,7 @@ pub fn pullup_strength1(s: Span) -> IResult { let (s, a) = paren(strength1)(s)?; Ok(( s, - PullupStrength::Strength1(PullupStrength1 { nodes: (a,) }), + PullupStrength::Strength1(Box::new(PullupStrength1 { nodes: (a,) })), )) } diff --git a/src/parser/source_text/checker_items.rs b/src/parser/source_text/checker_items.rs index 58e9810..02da5bd 100644 --- a/src/parser/source_text/checker_items.rs +++ b/src/parser/source_text/checker_items.rs @@ -27,33 +27,33 @@ pub struct CheckerPortItem { #[derive(Clone, Debug, Node)] pub enum CheckerPortDirection { - Input(Keyword), - Output(Keyword), + Input(Box), + Output(Box), } #[derive(Clone, Debug, Node)] pub enum CheckerOrGenerateItem { - CheckerOrGenerateItemDeclaration(CheckerOrGenerateItemDeclaration), - InitialConstruct(InitialConstruct), - AlwaysConstruct(AlwaysConstruct), - FinalConstruct(FinalConstruct), - AssertionItem(AssertionItem), - ContinuousAssign(ContinuousAssign), - CheckerGenerateItem(CheckerGenerateItem), + CheckerOrGenerateItemDeclaration(Box), + InitialConstruct(Box), + AlwaysConstruct(Box), + FinalConstruct(Box), + AssertionItem(Box), + ContinuousAssign(Box), + CheckerGenerateItem(Box), } #[derive(Clone, Debug, Node)] pub enum CheckerOrGenerateItemDeclaration { - Data(CheckerOrGenerateItemDeclarationData), - FunctionDeclaration(FunctionDeclaration), - CheckerDeclaration(CheckerDeclaration), - AssertionItemDeclaration(AssertionItemDeclaration), - CovergroupDeclaration(CovergroupDeclaration), - GenvarDeclaration(GenvarDeclaration), - ClockingDeclaration(ClockingDeclaration), - Clocking(CheckerOrGenerateItemDeclarationClocking), - Disable(CheckerOrGenerateItemDeclarationDisable), - Empty(Symbol), + Data(Box), + FunctionDeclaration(Box), + CheckerDeclaration(Box), + AssertionItemDeclaration(Box), + CovergroupDeclaration(Box), + GenvarDeclaration(Box), + ClockingDeclaration(Box), + Clocking(Box), + Disable(Box), + Empty(Box), } #[derive(Clone, Debug, Node)] @@ -80,8 +80,8 @@ pub struct CheckerOrGenerateItemDeclarationDisable { pub enum CheckerGenerateItem { LoopGenerateConstruct(Box), ConditionalGenerateConstruct(Box), - GenerateRegion(GenerateRegion), - ElaborationSystemTask(ElaborationSystemTask), + GenerateRegion(Box), + ElaborationSystemTask(Box), } // ----------------------------------------------------------------------------- @@ -111,8 +111,12 @@ pub fn checker_port_item(s: Span) -> IResult { #[parser] pub fn checker_port_direction(s: Span) -> IResult { alt(( - map(keyword("input"), |x| CheckerPortDirection::Input(x)), - map(keyword("output"), |x| CheckerPortDirection::Output(x)), + map(keyword("input"), |x| { + CheckerPortDirection::Input(Box::new(x)) + }), + map(keyword("output"), |x| { + CheckerPortDirection::Output(Box::new(x)) + }), ))(s) } @@ -120,23 +124,25 @@ pub fn checker_port_direction(s: Span) -> IResult { pub fn checker_or_generate_item(s: Span) -> IResult { alt(( map(checker_or_generate_item_declaration, |x| { - CheckerOrGenerateItem::CheckerOrGenerateItemDeclaration(x) + CheckerOrGenerateItem::CheckerOrGenerateItemDeclaration(Box::new(x)) }), map(initial_construct, |x| { - CheckerOrGenerateItem::InitialConstruct(x) + CheckerOrGenerateItem::InitialConstruct(Box::new(x)) }), map(always_construct, |x| { - CheckerOrGenerateItem::AlwaysConstruct(x) + CheckerOrGenerateItem::AlwaysConstruct(Box::new(x)) }), map(final_construct, |x| { - CheckerOrGenerateItem::FinalConstruct(x) + CheckerOrGenerateItem::FinalConstruct(Box::new(x)) + }), + map(assertion_item, |x| { + CheckerOrGenerateItem::AssertionItem(Box::new(x)) }), - map(assertion_item, |x| CheckerOrGenerateItem::AssertionItem(x)), map(continuous_assign, |x| { - CheckerOrGenerateItem::ContinuousAssign(x) + CheckerOrGenerateItem::ContinuousAssign(Box::new(x)) }), map(checker_generate_item, |x| { - CheckerOrGenerateItem::CheckerGenerateItem(x) + CheckerOrGenerateItem::CheckerGenerateItem(Box::new(x)) }), ))(s) } @@ -148,26 +154,28 @@ pub fn checker_or_generate_item_declaration( alt(( checker_or_generate_item_declaration_data, map(function_declaration, |x| { - CheckerOrGenerateItemDeclaration::FunctionDeclaration(x) + CheckerOrGenerateItemDeclaration::FunctionDeclaration(Box::new(x)) }), map(checker_declaration, |x| { - CheckerOrGenerateItemDeclaration::CheckerDeclaration(x) + CheckerOrGenerateItemDeclaration::CheckerDeclaration(Box::new(x)) }), map(assertion_item_declaration, |x| { - CheckerOrGenerateItemDeclaration::AssertionItemDeclaration(x) + CheckerOrGenerateItemDeclaration::AssertionItemDeclaration(Box::new(x)) }), map(covergroup_declaration, |x| { - CheckerOrGenerateItemDeclaration::CovergroupDeclaration(x) + CheckerOrGenerateItemDeclaration::CovergroupDeclaration(Box::new(x)) }), map(genvar_declaration, |x| { - CheckerOrGenerateItemDeclaration::GenvarDeclaration(x) + CheckerOrGenerateItemDeclaration::GenvarDeclaration(Box::new(x)) }), map(clocking_declaration, |x| { - CheckerOrGenerateItemDeclaration::ClockingDeclaration(x) + CheckerOrGenerateItemDeclaration::ClockingDeclaration(Box::new(x)) }), checker_or_generate_item_declaration_clocking, checker_or_generate_item_declaration_disable, - map(symbol(";"), |x| CheckerOrGenerateItemDeclaration::Empty(x)), + map(symbol(";"), |x| { + CheckerOrGenerateItemDeclaration::Empty(Box::new(x)) + }), ))(s) } @@ -179,9 +187,9 @@ pub fn checker_or_generate_item_declaration_data( let (s, b) = data_declaration(s)?; Ok(( s, - CheckerOrGenerateItemDeclaration::Data(CheckerOrGenerateItemDeclarationData { + CheckerOrGenerateItemDeclaration::Data(Box::new(CheckerOrGenerateItemDeclarationData { nodes: (a, b), - }), + })), )) } @@ -201,9 +209,11 @@ pub fn checker_or_generate_item_declaration_clocking( let (s, d) = symbol(";")(s)?; Ok(( s, - CheckerOrGenerateItemDeclaration::Clocking(CheckerOrGenerateItemDeclarationClocking { - nodes: (a, b, c, d), - }), + CheckerOrGenerateItemDeclaration::Clocking(Box::new( + CheckerOrGenerateItemDeclarationClocking { + nodes: (a, b, c, d), + }, + )), )) } @@ -218,9 +228,11 @@ pub fn checker_or_generate_item_declaration_disable( let (s, e) = symbol(";")(s)?; Ok(( s, - CheckerOrGenerateItemDeclaration::Disable(CheckerOrGenerateItemDeclarationDisable { - nodes: (a, b, c, d, e), - }), + CheckerOrGenerateItemDeclaration::Disable(Box::new( + CheckerOrGenerateItemDeclarationDisable { + nodes: (a, b, c, d, e), + }, + )), )) } @@ -233,9 +245,11 @@ pub fn checker_generate_item(s: Span) -> IResult { map(conditional_generate_construct, |x| { CheckerGenerateItem::ConditionalGenerateConstruct(Box::new(x)) }), - map(generate_region, |x| CheckerGenerateItem::GenerateRegion(x)), + map(generate_region, |x| { + CheckerGenerateItem::GenerateRegion(Box::new(x)) + }), map(elaboration_system_task, |x| { - CheckerGenerateItem::ElaborationSystemTask(x) + CheckerGenerateItem::ElaborationSystemTask(Box::new(x)) }), ))(s) } diff --git a/src/parser/source_text/class_items.rs b/src/parser/source_text/class_items.rs index 98ed64f..9f7435d 100644 --- a/src/parser/source_text/class_items.rs +++ b/src/parser/source_text/class_items.rs @@ -10,14 +10,14 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum ClassItem { - Property(ClassItemProperty), - Method(ClassItemMethod), - Constraint(ClassItemConstraint), - Declaration(ClassItemDeclaration), - Covergroup(ClassItemCovergroup), - LocalParameterDeclaration((LocalParameterDeclaration, Symbol)), - ParameterDeclaration((ParameterDeclaration, Symbol)), - Empty(Symbol), + Property(Box), + Method(Box), + Constraint(Box), + Declaration(Box), + Covergroup(Box), + LocalParameterDeclaration(Box<(LocalParameterDeclaration, Symbol)>), + ParameterDeclaration(Box<(ParameterDeclaration, Symbol)>), + Empty(Box), } #[derive(Clone, Debug, Node)] @@ -47,8 +47,8 @@ pub struct ClassItemCovergroup { #[derive(Clone, Debug, Node)] pub enum ClassProperty { - NonConst(ClassPropertyNonConst), - Const(ClassPropertyConst), + NonConst(Box), + Const(Box), } #[derive(Clone, Debug, Node)] @@ -70,12 +70,12 @@ pub struct ClassPropertyConst { #[derive(Clone, Debug, Node)] pub enum ClassMethod { - Task(ClassMethodTask), - Function(ClassMethodFunction), - PureVirtual(ClassMethodPureVirtual), - ExternMethod(ClassMethodExternMethod), - Constructor(ClassMethodConstructor), - ExternConstructor(ClassMethodExternConstructor), + Task(Box), + Function(Box), + PureVirtual(Box), + ExternMethod(Box), + Constructor(Box), + ExternConstructor(Box), } #[derive(Clone, Debug, Node)] @@ -121,40 +121,40 @@ pub struct ClassConstructorPrototype { #[derive(Clone, Debug, Node)] pub enum ClassConstraint { - ConstraintPrototype(ConstraintPrototype), - ConstraintDeclaration(ConstraintDeclaration), + ConstraintPrototype(Box), + ConstraintDeclaration(Box), } #[derive(Clone, Debug, Node)] pub enum ClassItemQualifier { - Static(Keyword), - Protected(Keyword), - Local(Keyword), + Static(Box), + Protected(Box), + Local(Box), } #[derive(Clone, Debug, Node)] pub enum PropertyQualifier { - RandomQualifier(RandomQualifier), - ClassItemQualifier(ClassItemQualifier), + RandomQualifier(Box), + ClassItemQualifier(Box), } #[derive(Clone, Debug, Node)] pub enum RandomQualifier { - Rand(Keyword), - Randc(Keyword), + Rand(Box), + Randc(Box), } #[derive(Clone, Debug, Node)] pub enum MethodQualifier { - Virtual(Keyword), - PureVirtual((Keyword, Keyword)), - ClassItemQualifier(ClassItemQualifier), + Virtual(Box), + PureVirtual(Box<(Keyword, Keyword)>), + ClassItemQualifier(Box), } #[derive(Clone, Debug, Node)] pub enum MethodPrototype { - TaskPrototype(TaskPrototype), - FunctionPrototype(FunctionPrototype), + TaskPrototype(Box), + FunctionPrototype(Box), } #[derive(Clone, Debug, Node)] @@ -195,12 +195,12 @@ pub fn class_item(s: Span) -> IResult { class_item_declaration, class_item_covergroup, map(pair(local_parameter_declaration, symbol(";")), |x| { - ClassItem::LocalParameterDeclaration(x) + ClassItem::LocalParameterDeclaration(Box::new(x)) }), map(pair(parameter_declaration, symbol(";")), |x| { - ClassItem::ParameterDeclaration(x) + ClassItem::ParameterDeclaration(Box::new(x)) }), - map(symbol(";"), |x| ClassItem::Empty(x)), + map(symbol(";"), |x| ClassItem::Empty(Box::new(x))), ))(s) } @@ -208,14 +208,20 @@ pub fn class_item(s: Span) -> IResult { pub fn class_item_property(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = class_property(s)?; - Ok((s, ClassItem::Property(ClassItemProperty { nodes: (a, b) }))) + Ok(( + s, + ClassItem::Property(Box::new(ClassItemProperty { nodes: (a, b) })), + )) } #[parser] pub fn class_item_method(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = class_method(s)?; - Ok((s, ClassItem::Method(ClassItemMethod { nodes: (a, b) }))) + Ok(( + s, + ClassItem::Method(Box::new(ClassItemMethod { nodes: (a, b) })), + )) } #[parser] @@ -224,7 +230,7 @@ pub fn class_item_constraint(s: Span) -> IResult { let (s, b) = class_constraint(s)?; Ok(( s, - ClassItem::Constraint(ClassItemConstraint { nodes: (a, b) }), + ClassItem::Constraint(Box::new(ClassItemConstraint { nodes: (a, b) })), )) } @@ -234,7 +240,7 @@ pub fn class_item_declaration(s: Span) -> IResult { let (s, b) = class_declaration(s)?; Ok(( s, - ClassItem::Declaration(ClassItemDeclaration { nodes: (a, b) }), + ClassItem::Declaration(Box::new(ClassItemDeclaration { nodes: (a, b) })), )) } @@ -244,7 +250,7 @@ pub fn class_item_covergroup(s: Span) -> IResult { let (s, b) = covergroup_declaration(s)?; Ok(( s, - ClassItem::Covergroup(ClassItemCovergroup { nodes: (a, b) }), + ClassItem::Covergroup(Box::new(ClassItemCovergroup { nodes: (a, b) })), )) } @@ -259,7 +265,7 @@ pub fn class_property_non_const(s: Span) -> IResult { let (s, b) = data_declaration(s)?; Ok(( s, - ClassProperty::NonConst(ClassPropertyNonConst { nodes: (a, b) }), + ClassProperty::NonConst(Box::new(ClassPropertyNonConst { nodes: (a, b) })), )) } @@ -273,9 +279,9 @@ pub fn class_property_const(s: Span) -> IResult { let (s, f) = symbol(";")(s)?; Ok(( s, - ClassProperty::Const(ClassPropertyConst { + ClassProperty::Const(Box::new(ClassPropertyConst { nodes: (a, b, c, d, e, f), - }), + })), )) } @@ -295,7 +301,10 @@ pub fn class_method(s: Span) -> IResult { pub fn class_method_task(s: Span) -> IResult { let (s, a) = many0(method_qualifier)(s)?; let (s, b) = task_declaration(s)?; - Ok((s, ClassMethod::Task(ClassMethodTask { nodes: (a, b) }))) + Ok(( + s, + ClassMethod::Task(Box::new(ClassMethodTask { nodes: (a, b) })), + )) } #[parser] @@ -304,7 +313,7 @@ pub fn class_method_function(s: Span) -> IResult { let (s, b) = function_declaration(s)?; Ok(( s, - ClassMethod::Function(ClassMethodFunction { nodes: (a, b) }), + ClassMethod::Function(Box::new(ClassMethodFunction { nodes: (a, b) })), )) } @@ -317,9 +326,9 @@ pub fn class_method_pure_virtual(s: Span) -> IResult { let (s, e) = symbol(";")(s)?; Ok(( s, - ClassMethod::PureVirtual(ClassMethodPureVirtual { + ClassMethod::PureVirtual(Box::new(ClassMethodPureVirtual { nodes: (a, b, c, d, e), - }), + })), )) } @@ -331,9 +340,9 @@ pub fn class_method_extern_method(s: Span) -> IResult { let (s, d) = symbol(";")(s)?; Ok(( s, - ClassMethod::ExternMethod(ClassMethodExternMethod { + ClassMethod::ExternMethod(Box::new(ClassMethodExternMethod { nodes: (a, b, c, d), - }), + })), )) } @@ -343,7 +352,7 @@ pub fn class_method_constructor(s: Span) -> IResult { let (s, b) = class_constructor_declaration(s)?; Ok(( s, - ClassMethod::Constructor(ClassMethodConstructor { nodes: (a, b) }), + ClassMethod::Constructor(Box::new(ClassMethodConstructor { nodes: (a, b) })), )) } @@ -354,7 +363,7 @@ pub fn class_method_extern_constructor(s: Span) -> IResult { let (s, c) = class_constructor_prototype(s)?; Ok(( s, - ClassMethod::ExternConstructor(ClassMethodExternConstructor { nodes: (a, b, c) }), + ClassMethod::ExternConstructor(Box::new(ClassMethodExternConstructor { nodes: (a, b, c) })), )) } @@ -376,10 +385,10 @@ pub fn class_constructor_prototype(s: Span) -> IResult IResult { alt(( map(constraint_prototype, |x| { - ClassConstraint::ConstraintPrototype(x) + ClassConstraint::ConstraintPrototype(Box::new(x)) }), map(constraint_declaration, |x| { - ClassConstraint::ConstraintDeclaration(x) + ClassConstraint::ConstraintDeclaration(Box::new(x)) }), ))(s) } @@ -387,18 +396,24 @@ pub fn class_constraint(s: Span) -> IResult { #[parser] pub fn class_item_qualifier(s: Span) -> IResult { alt(( - map(keyword("static"), |x| ClassItemQualifier::Static(x)), - map(keyword("protected"), |x| ClassItemQualifier::Protected(x)), - map(keyword("local"), |x| ClassItemQualifier::Local(x)), + map(keyword("static"), |x| { + ClassItemQualifier::Static(Box::new(x)) + }), + map(keyword("protected"), |x| { + ClassItemQualifier::Protected(Box::new(x)) + }), + map(keyword("local"), |x| ClassItemQualifier::Local(Box::new(x))), ))(s) } #[parser] pub fn property_qualifier(s: Span) -> IResult { alt(( - map(random_qualifier, |x| PropertyQualifier::RandomQualifier(x)), + map(random_qualifier, |x| { + PropertyQualifier::RandomQualifier(Box::new(x)) + }), map(class_item_qualifier, |x| { - PropertyQualifier::ClassItemQualifier(x) + PropertyQualifier::ClassItemQualifier(Box::new(x)) }), ))(s) } @@ -406,8 +421,8 @@ pub fn property_qualifier(s: Span) -> IResult { #[parser] pub fn random_qualifier(s: Span) -> IResult { alt(( - map(keyword("randc"), |x| RandomQualifier::Randc(x)), - map(keyword("rand"), |x| RandomQualifier::Rand(x)), + map(keyword("randc"), |x| RandomQualifier::Randc(Box::new(x))), + map(keyword("rand"), |x| RandomQualifier::Rand(Box::new(x))), ))(s) } @@ -415,11 +430,13 @@ pub fn random_qualifier(s: Span) -> IResult { pub fn method_qualifier(s: Span) -> IResult { alt(( map(pair(keyword("pure"), keyword("virtual")), |x| { - MethodQualifier::PureVirtual(x) + MethodQualifier::PureVirtual(Box::new(x)) + }), + map(keyword("virtual"), |x| { + MethodQualifier::Virtual(Box::new(x)) }), - map(keyword("virtual"), |x| MethodQualifier::Virtual(x)), map(class_item_qualifier, |x| { - MethodQualifier::ClassItemQualifier(x) + MethodQualifier::ClassItemQualifier(Box::new(x)) }), ))(s) } @@ -427,9 +444,11 @@ pub fn method_qualifier(s: Span) -> IResult { #[parser] pub fn method_prototype(s: Span) -> IResult { alt(( - map(task_prototype, |x| MethodPrototype::TaskPrototype(x)), + map(task_prototype, |x| { + MethodPrototype::TaskPrototype(Box::new(x)) + }), map(function_prototype, |x| { - MethodPrototype::FunctionPrototype(x) + MethodPrototype::FunctionPrototype(Box::new(x)) }), ))(s) } diff --git a/src/parser/source_text/configuration_source_text.rs b/src/parser/source_text/configuration_source_text.rs index 6a31e0d..24c3f9c 100644 --- a/src/parser/source_text/configuration_source_text.rs +++ b/src/parser/source_text/configuration_source_text.rs @@ -33,11 +33,11 @@ pub struct DesignStatement { #[derive(Clone, Debug, Node)] pub enum ConfigRuleStatement { - Default(ConfigRuleStatementDefault), - InstLib(ConfigRuleStatementInstLib), - InstUse(ConfigRuleStatementInstUse), - CellLib(ConfigRuleStatementCellLib), - CellUse(ConfigRuleStatementCellUse), + Default(Box), + InstLib(Box), + InstUse(Box), + CellLib(Box), + CellUse(Box), } #[derive(Clone, Debug, Node)] @@ -92,9 +92,9 @@ pub struct LiblistClause { #[derive(Clone, Debug, Node)] pub enum UseClause { - Cell(UseClauseCell), - Named(UseClauseNamed), - CellNamed(UseClauseCellNamed), + Cell(Box), + Named(Box), + CellNamed(Box), } #[derive(Clone, Debug, Node)] @@ -181,7 +181,7 @@ pub fn config_rule_statement_default(s: Span) -> IResult IResult IResult IResult IResult IResult { let (s, d) = opt(pair(symbol(":"), config))(s)?; Ok(( s, - UseClause::Cell(UseClauseCell { + UseClause::Cell(Box::new(UseClauseCell { nodes: (a, b, c, d), - }), + })), )) } @@ -288,7 +288,10 @@ pub fn use_clause_named(s: Span) -> IResult { let (s, a) = keyword("use")(s)?; let (s, b) = list(symbol(","), named_parameter_assignment)(s)?; let (s, c) = opt(pair(symbol(":"), config))(s)?; - Ok((s, UseClause::Named(UseClauseNamed { nodes: (a, b, c) }))) + Ok(( + s, + UseClause::Named(Box::new(UseClauseNamed { nodes: (a, b, c) })), + )) } #[parser] @@ -300,9 +303,9 @@ pub fn use_clause_cell_named(s: Span) -> IResult { let (s, e) = opt(pair(symbol(":"), config))(s)?; Ok(( s, - UseClause::CellNamed(UseClauseCellNamed { + UseClause::CellNamed(Box::new(UseClauseCellNamed { nodes: (a, b, c, d, e), - }), + })), )) } diff --git a/src/parser/source_text/constraints.rs b/src/parser/source_text/constraints.rs index 664fdc8..96c4c9f 100644 --- a/src/parser/source_text/constraints.rs +++ b/src/parser/source_text/constraints.rs @@ -30,8 +30,8 @@ pub struct ConstraintBlock { #[derive(Clone, Debug, Node)] pub enum ConstraintBlockItem { - Solve(ConstraintBlockItemSolve), - ConstraintExpression(ConstraintExpression), + Solve(Box), + ConstraintExpression(Box), } #[derive(Clone, Debug, Node)] @@ -55,12 +55,12 @@ pub struct ConstraintPrimary { #[derive(Clone, Debug, Node)] pub enum ConstraintExpression { - Expression(ConstraintExpressionExpression), - UniquenessConstraint((UniquenessConstraint, Symbol)), - Arrow(ConstraintExpressionArrow), - If(ConstraintExpressionIf), - Foreach(ConstraintExpressionForeach), - Disable(ConstraintExpressionDisable), + Expression(Box), + UniquenessConstraint(Box<(UniquenessConstraint, Symbol)>), + Arrow(Box), + If(Box), + Foreach(Box), + Disable(Box), } #[derive(Clone, Debug, Node)] @@ -110,7 +110,7 @@ pub struct UniquenessConstraint { #[derive(Clone, Debug, Node)] pub enum ConstraintSet { ConstraintExpression(Box), - Brace(ConstraintSetBrace), + Brace(Box), } #[derive(Clone, Debug, Node)] @@ -130,8 +130,8 @@ pub struct DistItem { #[derive(Clone, Debug, Node)] pub enum DistWeight { - Equal(DistWeightEqual), - Divide(DistWeightDivide), + Equal(Box), + Divide(Box), } #[derive(Clone, Debug, Node)] @@ -157,8 +157,8 @@ pub struct ConstraintPrototype { #[derive(Clone, Debug, Node)] pub enum ConstraintPrototypeQualifier { - Extern(Keyword), - Pure(Keyword), + Extern(Box), + Pure(Box), } #[derive(Clone, Debug, Node)] @@ -210,7 +210,7 @@ pub fn constraint_block_item(s: Span) -> IResult { alt(( constraint_block_item_solve, map(constraint_expression, |x| { - ConstraintBlockItem::ConstraintExpression(x) + ConstraintBlockItem::ConstraintExpression(Box::new(x)) }), ))(s) } @@ -224,9 +224,9 @@ pub fn constraint_block_item_solve(s: Span) -> IResult IResult { alt(( constraint_expression_expression, map(pair(uniqueness_constraint, symbol(";")), |x| { - ConstraintExpression::UniquenessConstraint(x) + ConstraintExpression::UniquenessConstraint(Box::new(x)) }), constraint_expression_arrow, constraint_expression_if, @@ -265,7 +265,9 @@ pub fn constraint_expression_expression(s: Span) -> IResult IResult IResult let (s, d) = opt(pair(keyword("else"), constraint_set))(s)?; Ok(( s, - ConstraintExpression::If(ConstraintExpressionIf { + ConstraintExpression::If(Box::new(ConstraintExpressionIf { nodes: (a, b, c, d), - }), + })), )) } @@ -310,7 +312,7 @@ pub fn constraint_expression_foreach(s: Span) -> IResult IResult IResult { #[parser] pub fn constraint_set_brace(s: Span) -> IResult { let (s, a) = brace(many0(constraint_expression))(s)?; - Ok((s, ConstraintSet::Brace(ConstraintSetBrace { nodes: (a,) }))) + Ok(( + s, + ConstraintSet::Brace(Box::new(ConstraintSetBrace { nodes: (a,) })), + )) } #[parser(MaybeRecursive)] @@ -373,14 +378,20 @@ pub fn dist_weight(s: Span) -> IResult { pub fn dist_weight_equal(s: Span) -> IResult { let (s, a) = symbol(":=")(s)?; let (s, b) = expression(s)?; - Ok((s, DistWeight::Equal(DistWeightEqual { nodes: (a, b) }))) + Ok(( + s, + DistWeight::Equal(Box::new(DistWeightEqual { nodes: (a, b) })), + )) } #[parser] pub fn dist_weight_divide(s: Span) -> IResult { let (s, a) = symbol(":/")(s)?; let (s, b) = expression(s)?; - Ok((s, DistWeight::Divide(DistWeightDivide { nodes: (a, b) }))) + Ok(( + s, + DistWeight::Divide(Box::new(DistWeightDivide { nodes: (a, b) })), + )) } #[parser] @@ -402,9 +413,11 @@ pub fn constraint_prototype(s: Span) -> IResult { pub fn constraint_prototype_qualifier(s: Span) -> IResult { alt(( map(keyword("extern"), |x| { - ConstraintPrototypeQualifier::Extern(x) + ConstraintPrototypeQualifier::Extern(Box::new(x)) + }), + map(keyword("pure"), |x| { + ConstraintPrototypeQualifier::Pure(Box::new(x)) }), - map(keyword("pure"), |x| ConstraintPrototypeQualifier::Pure(x)), ))(s) } diff --git a/src/parser/source_text/interface_items.rs b/src/parser/source_text/interface_items.rs index e01c47a..7ae1fa8 100644 --- a/src/parser/source_text/interface_items.rs +++ b/src/parser/source_text/interface_items.rs @@ -10,8 +10,8 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum InterfaceOrGenerateItem { - Module(InterfaceOrGenerateItemModule), - Extern(InterfaceOrGenerateItemExtern), + Module(Box), + Extern(Box), } #[derive(Clone, Debug, Node)] @@ -26,8 +26,8 @@ pub struct InterfaceOrGenerateItemExtern { #[derive(Clone, Debug, Node)] pub enum ExternTfDeclaration { - Method(ExternTfDeclarationMethod), - Task(ExternTfDeclarationTask), + Method(Box), + Task(Box), } #[derive(Clone, Debug, Node)] @@ -42,18 +42,18 @@ pub struct ExternTfDeclarationTask { #[derive(Clone, Debug, Node)] pub enum InterfaceItem { - PortDeclaration((PortDeclaration, Symbol)), - NonPortInterfaceItem(NonPortInterfaceItem), + PortDeclaration(Box<(PortDeclaration, Symbol)>), + NonPortInterfaceItem(Box), } #[derive(Clone, Debug, Node)] pub enum NonPortInterfaceItem { - GenerateRegion(GenerateRegion), - InterfaceOrGenerateItem(InterfaceOrGenerateItem), - ProgramDeclaration(ProgramDeclaration), - ModportDeclaration(ModportDeclaration), - InterfaceDeclaration(InterfaceDeclaration), - TimeunitsDeclaration(TimeunitsDeclaration), + GenerateRegion(Box), + InterfaceOrGenerateItem(Box), + ProgramDeclaration(Box), + ModportDeclaration(Box), + InterfaceDeclaration(Box), + TimeunitsDeclaration(Box), } // ----------------------------------------------------------------------------- @@ -72,7 +72,7 @@ pub fn interface_or_generate_item_module(s: Span) -> IResult IResult IResult IResult let (s, d) = symbol(";")(s)?; Ok(( s, - ExternTfDeclaration::Task(ExternTfDeclarationTask { + ExternTfDeclaration::Task(Box::new(ExternTfDeclarationTask { nodes: (a, b, c, d), - }), + })), )) } @@ -120,10 +120,10 @@ pub fn extern_tf_declaration_task(s: Span) -> IResult pub fn interface_item(s: Span) -> IResult { alt(( map(pair(port_declaration, symbol(";")), |x| { - InterfaceItem::PortDeclaration(x) + InterfaceItem::PortDeclaration(Box::new(x)) }), map(non_port_interface_item, |x| { - InterfaceItem::NonPortInterfaceItem(x) + InterfaceItem::NonPortInterfaceItem(Box::new(x)) }), ))(s) } @@ -131,21 +131,23 @@ pub fn interface_item(s: Span) -> IResult { #[parser] pub fn non_port_interface_item(s: Span) -> IResult { alt(( - map(generate_region, |x| NonPortInterfaceItem::GenerateRegion(x)), + map(generate_region, |x| { + NonPortInterfaceItem::GenerateRegion(Box::new(x)) + }), map(interface_or_generate_item, |x| { - NonPortInterfaceItem::InterfaceOrGenerateItem(x) + NonPortInterfaceItem::InterfaceOrGenerateItem(Box::new(x)) }), map(program_declaration, |x| { - NonPortInterfaceItem::ProgramDeclaration(x) + NonPortInterfaceItem::ProgramDeclaration(Box::new(x)) }), map(modport_declaration, |x| { - NonPortInterfaceItem::ModportDeclaration(x) + NonPortInterfaceItem::ModportDeclaration(Box::new(x)) }), map(interface_declaration, |x| { - NonPortInterfaceItem::InterfaceDeclaration(x) + NonPortInterfaceItem::InterfaceDeclaration(Box::new(x)) }), map(timeunits_declaration, |x| { - NonPortInterfaceItem::TimeunitsDeclaration(x) + NonPortInterfaceItem::TimeunitsDeclaration(Box::new(x)) }), ))(s) } diff --git a/src/parser/source_text/library_source_text.rs b/src/parser/source_text/library_source_text.rs index 4299cba..1a976c4 100644 --- a/src/parser/source_text/library_source_text.rs +++ b/src/parser/source_text/library_source_text.rs @@ -15,10 +15,10 @@ pub struct LibraryText { #[derive(Clone, Debug, Node)] pub enum LibraryDescription { - LibraryDeclaration(LibraryDeclaration), - IncludeStatement(IncludeStatement), - ConfigDeclaration(ConfigDeclaration), - Null(Symbol), + LibraryDeclaration(Box), + IncludeStatement(Box), + ConfigDeclaration(Box), + Null(Box), } #[derive(Clone, Debug, Node)] @@ -54,15 +54,15 @@ pub fn library_text(s: Span) -> IResult { pub fn library_description(s: Span) -> IResult { alt(( map(library_declaration, |x| { - LibraryDescription::LibraryDeclaration(x) + LibraryDescription::LibraryDeclaration(Box::new(x)) }), map(include_statement, |x| { - LibraryDescription::IncludeStatement(x) + LibraryDescription::IncludeStatement(Box::new(x)) }), map(config_declaration, |x| { - LibraryDescription::ConfigDeclaration(x) + LibraryDescription::ConfigDeclaration(Box::new(x)) }), - map(symbol(";"), |x| LibraryDescription::Null(x)), + map(symbol(";"), |x| LibraryDescription::Null(Box::new(x))), ))(s) } diff --git a/src/parser/source_text/module_items.rs b/src/parser/source_text/module_items.rs index d652734..8392d0b 100644 --- a/src/parser/source_text/module_items.rs +++ b/src/parser/source_text/module_items.rs @@ -10,10 +10,10 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum ElaborationSystemTask { - TaskFatal(ElaborationSystemTaskFatal), - TaskError(ElaborationSystemTaskError), - TaskWarning(ElaborationSystemTaskWarning), - TaskInfo(ElaborationSystemTaskInfo), + TaskFatal(Box), + TaskError(Box), + TaskWarning(Box), + TaskInfo(Box), } #[derive(Clone, Debug, Node)] @@ -42,40 +42,40 @@ pub struct ElaborationSystemTaskInfo { #[derive(Clone, Debug, Node)] pub enum FinishNumber { - Zero(Symbol), - One(Symbol), - Two(Symbol), + Zero(Box), + One(Box), + Two(Box), } #[derive(Clone, Debug, Node)] pub enum ModuleCommonItem { - ModuleOrGenerateItemDeclaration(ModuleOrGenerateItemDeclaration), - InterfaceInstantiation(InterfaceInstantiation), - ProgramInstantiation(ProgramInstantiation), - AssertionItem(AssertionItem), - BindDirective(BindDirective), - ContinuousAssign(ContinuousAssign), - NetAlias(NetAlias), - InitialConstruct(InitialConstruct), - FinalConstruct(FinalConstruct), - AlwaysConstruct(AlwaysConstruct), + ModuleOrGenerateItemDeclaration(Box), + InterfaceInstantiation(Box), + ProgramInstantiation(Box), + AssertionItem(Box), + BindDirective(Box), + ContinuousAssign(Box), + NetAlias(Box), + InitialConstruct(Box), + FinalConstruct(Box), + AlwaysConstruct(Box), LoopGenerateConstruct(Box), ConditionalGenerateConstruct(Box), - ElaborationSystemTask(ElaborationSystemTask), + ElaborationSystemTask(Box), } #[derive(Clone, Debug, Node)] pub enum ModuleItem { - PortDeclaration((PortDeclaration, Symbol)), - NonPortModuleItem(NonPortModuleItem), + PortDeclaration(Box<(PortDeclaration, Symbol)>), + NonPortModuleItem(Box), } #[derive(Clone, Debug, Node)] pub enum ModuleOrGenerateItem { - Parameter(ModuleOrGenerateItemParameter), - Gate(ModuleOrGenerateItemGate), - Udp(ModuleOrGenerateItemUdp), - Module(ModuleOrGenerateItemModule), + Parameter(Box), + Gate(Box), + Udp(Box), + Module(Box), ModuleItem(Box), } @@ -106,11 +106,11 @@ pub struct ModuleOrGenerateItemModuleItem { #[derive(Clone, Debug, Node)] pub enum ModuleOrGenerateItemDeclaration { - PackageOrGenerateItemDeclaration(PackageOrGenerateItemDeclaration), - GenvarDeclaration(GenvarDeclaration), - ClockingDeclaration(ClockingDeclaration), - Clocking(ModuleOrGenerateItemDeclarationClocking), - Disable(ModuleOrGenerateItemDeclarationDisable), + PackageOrGenerateItemDeclaration(Box), + GenvarDeclaration(Box), + ClockingDeclaration(Box), + Clocking(Box), + Disable(Box), } #[derive(Clone, Debug, Node)] @@ -125,14 +125,14 @@ pub struct ModuleOrGenerateItemDeclarationDisable { #[derive(Clone, Debug, Node)] pub enum NonPortModuleItem { - GenerateRegion(GenerateRegion), - ModuleOrGenerateItem(ModuleOrGenerateItem), - SpecifyBlock(SpecifyBlock), - Specparam(NonPortModuleItemSpecparam), - ProgramDeclaration(ProgramDeclaration), - ModuleDeclaration(ModuleDeclaration), - InterfaceDeclaration(InterfaceDeclaration), - TimeunitsDeclaration(TimeunitsDeclaration), + GenerateRegion(Box), + ModuleOrGenerateItem(Box), + SpecifyBlock(Box), + Specparam(Box), + ProgramDeclaration(Box), + ModuleDeclaration(Box), + InterfaceDeclaration(Box), + TimeunitsDeclaration(Box), } #[derive(Clone, Debug, Node)] @@ -147,8 +147,8 @@ pub struct ParameterOverride { #[derive(Clone, Debug, Node)] pub enum BindDirective { - Scope(BindDirectiveScope), - Instance(BindDirectiveInstance), + Scope(Box), + Instance(Box), } #[derive(Clone, Debug, Node)] @@ -169,8 +169,8 @@ pub struct BindDirectiveInstance { #[derive(Clone, Debug, Node)] pub enum BindTargetScope { - ModuleIdentifier(ModuleIdentifier), - InterfaceIdentifier(InterfaceIdentifier), + ModuleIdentifier(Box), + InterfaceIdentifier(Box), } #[derive(Clone, Debug, Node)] @@ -185,10 +185,10 @@ pub struct BindTargetInstanceList { #[derive(Clone, Debug, Node)] pub enum BindInstantiation { - ProgramInstantiation(ProgramInstantiation), - ModuleInstantiation(ModuleInstantiation), - InterfaceInstantiation(InterfaceInstantiation), - CheckerInstantiation(CheckerInstantiation), + ProgramInstantiation(Box), + ModuleInstantiation(Box), + InterfaceInstantiation(Box), + CheckerInstantiation(Box), } // ----------------------------------------------------------------------------- @@ -213,7 +213,7 @@ pub fn elaboration_system_task_fatal(s: Span) -> IResult IResult IResult IResult IResult { alt(( - map(symbol("0"), |x| FinishNumber::Zero(x)), - map(symbol("1"), |x| FinishNumber::One(x)), - map(symbol("2"), |x| FinishNumber::Two(x)), + map(symbol("0"), |x| FinishNumber::Zero(Box::new(x))), + map(symbol("1"), |x| FinishNumber::One(Box::new(x))), + map(symbol("2"), |x| FinishNumber::Two(Box::new(x))), ))(s) } @@ -263,21 +265,33 @@ pub fn finish_number(s: Span) -> IResult { pub fn module_common_item(s: Span) -> IResult { alt(( map(module_or_generate_item_declaration, |x| { - ModuleCommonItem::ModuleOrGenerateItemDeclaration(x) + ModuleCommonItem::ModuleOrGenerateItemDeclaration(Box::new(x)) }), map(interface_instantiation, |x| { - ModuleCommonItem::InterfaceInstantiation(x) + ModuleCommonItem::InterfaceInstantiation(Box::new(x)) }), map(program_instantiation, |x| { - ModuleCommonItem::ProgramInstantiation(x) + ModuleCommonItem::ProgramInstantiation(Box::new(x)) + }), + map(assertion_item, |x| { + ModuleCommonItem::AssertionItem(Box::new(x)) + }), + map(bind_directive, |x| { + ModuleCommonItem::BindDirective(Box::new(x)) + }), + map(continuous_assign, |x| { + ModuleCommonItem::ContinuousAssign(Box::new(x)) + }), + map(net_alias, |x| ModuleCommonItem::NetAlias(Box::new(x))), + map(initial_construct, |x| { + ModuleCommonItem::InitialConstruct(Box::new(x)) + }), + map(final_construct, |x| { + ModuleCommonItem::FinalConstruct(Box::new(x)) + }), + map(always_construct, |x| { + ModuleCommonItem::AlwaysConstruct(Box::new(x)) }), - map(assertion_item, |x| ModuleCommonItem::AssertionItem(x)), - map(bind_directive, |x| ModuleCommonItem::BindDirective(x)), - map(continuous_assign, |x| ModuleCommonItem::ContinuousAssign(x)), - map(net_alias, |x| ModuleCommonItem::NetAlias(x)), - map(initial_construct, |x| ModuleCommonItem::InitialConstruct(x)), - map(final_construct, |x| ModuleCommonItem::FinalConstruct(x)), - map(always_construct, |x| ModuleCommonItem::AlwaysConstruct(x)), map(loop_generate_construct, |x| { ModuleCommonItem::LoopGenerateConstruct(Box::new(x)) }), @@ -285,7 +299,7 @@ pub fn module_common_item(s: Span) -> IResult { ModuleCommonItem::ConditionalGenerateConstruct(Box::new(x)) }), map(elaboration_system_task, |x| { - ModuleCommonItem::ElaborationSystemTask(x) + ModuleCommonItem::ElaborationSystemTask(Box::new(x)) }), ))(s) } @@ -294,9 +308,11 @@ pub fn module_common_item(s: Span) -> IResult { pub fn module_item(s: Span) -> IResult { alt(( map(pair(port_declaration, symbol(";")), |x| { - ModuleItem::PortDeclaration(x) + ModuleItem::PortDeclaration(Box::new(x)) + }), + map(non_port_module_item, |x| { + ModuleItem::NonPortModuleItem(Box::new(x)) }), - map(non_port_module_item, |x| ModuleItem::NonPortModuleItem(x)), ))(s) } @@ -317,7 +333,7 @@ pub fn module_or_generate_item_parameter(s: Span) -> IResult IResult IResult IResult IResult { alt(( map(package_or_generate_item_declaration, |x| { - ModuleOrGenerateItemDeclaration::PackageOrGenerateItemDeclaration(x) + ModuleOrGenerateItemDeclaration::PackageOrGenerateItemDeclaration(Box::new(x)) }), map(genvar_declaration, |x| { - ModuleOrGenerateItemDeclaration::GenvarDeclaration(x) + ModuleOrGenerateItemDeclaration::GenvarDeclaration(Box::new(x)) }), map(clocking_declaration, |x| { - ModuleOrGenerateItemDeclaration::ClockingDeclaration(x) + ModuleOrGenerateItemDeclaration::ClockingDeclaration(Box::new(x)) }), module_or_generate_item_declaration_clocking, module_or_generate_item_declaration_disable, @@ -392,9 +408,11 @@ pub fn module_or_generate_item_declaration_clocking( let (s, d) = symbol(";")(s)?; Ok(( s, - ModuleOrGenerateItemDeclaration::Clocking(ModuleOrGenerateItemDeclarationClocking { - nodes: (a, b, c, d), - }), + ModuleOrGenerateItemDeclaration::Clocking(Box::new( + ModuleOrGenerateItemDeclarationClocking { + nodes: (a, b, c, d), + }, + )), )) } @@ -409,32 +427,38 @@ pub fn module_or_generate_item_declaration_disable( let (s, e) = symbol(";")(s)?; Ok(( s, - ModuleOrGenerateItemDeclaration::Disable(ModuleOrGenerateItemDeclarationDisable { - nodes: (a, b, c, d, e), - }), + ModuleOrGenerateItemDeclaration::Disable(Box::new( + ModuleOrGenerateItemDeclarationDisable { + nodes: (a, b, c, d, e), + }, + )), )) } #[parser] pub fn non_port_module_item(s: Span) -> IResult { alt(( - map(generate_region, |x| NonPortModuleItem::GenerateRegion(x)), - map(module_or_generate_item, |x| { - NonPortModuleItem::ModuleOrGenerateItem(x) + map(generate_region, |x| { + NonPortModuleItem::GenerateRegion(Box::new(x)) + }), + map(module_or_generate_item, |x| { + NonPortModuleItem::ModuleOrGenerateItem(Box::new(x)) + }), + map(specify_block, |x| { + NonPortModuleItem::SpecifyBlock(Box::new(x)) }), - map(specify_block, |x| NonPortModuleItem::SpecifyBlock(x)), non_port_module_item_specparam, map(program_declaration, |x| { - NonPortModuleItem::ProgramDeclaration(x) + NonPortModuleItem::ProgramDeclaration(Box::new(x)) }), map(module_declaration, |x| { - NonPortModuleItem::ModuleDeclaration(x) + NonPortModuleItem::ModuleDeclaration(Box::new(x)) }), map(interface_declaration, |x| { - NonPortModuleItem::InterfaceDeclaration(x) + NonPortModuleItem::InterfaceDeclaration(Box::new(x)) }), map(timeunits_declaration, |x| { - NonPortModuleItem::TimeunitsDeclaration(x) + NonPortModuleItem::TimeunitsDeclaration(Box::new(x)) }), ))(s) } @@ -445,7 +469,7 @@ pub fn non_port_module_item_specparam(s: Span) -> IResult IResult { let (s, e) = symbol(";")(s)?; Ok(( s, - BindDirective::Scope(BindDirectiveScope { + BindDirective::Scope(Box::new(BindDirectiveScope { nodes: (a, b, c, d, e), - }), + })), )) } @@ -485,18 +509,20 @@ pub fn bind_directive_instance(s: Span) -> IResult { let (s, d) = symbol(";")(s)?; Ok(( s, - BindDirective::Instance(BindDirectiveInstance { + BindDirective::Instance(Box::new(BindDirectiveInstance { nodes: (a, b, c, d), - }), + })), )) } #[parser] pub fn bind_target_scope(s: Span) -> IResult { alt(( - map(module_identifier, |x| BindTargetScope::ModuleIdentifier(x)), + map(module_identifier, |x| { + BindTargetScope::ModuleIdentifier(Box::new(x)) + }), map(interface_identifier, |x| { - BindTargetScope::InterfaceIdentifier(x) + BindTargetScope::InterfaceIdentifier(Box::new(x)) }), ))(s) } @@ -518,16 +544,16 @@ pub fn bind_target_instance_list(s: Span) -> IResult IResult { alt(( map(program_instantiation, |x| { - BindInstantiation::ProgramInstantiation(x) + BindInstantiation::ProgramInstantiation(Box::new(x)) }), map(module_instantiation, |x| { - BindInstantiation::ModuleInstantiation(x) + BindInstantiation::ModuleInstantiation(Box::new(x)) }), map(interface_instantiation, |x| { - BindInstantiation::InterfaceInstantiation(x) + BindInstantiation::InterfaceInstantiation(Box::new(x)) }), map(checker_instantiation, |x| { - BindInstantiation::CheckerInstantiation(x) + BindInstantiation::CheckerInstantiation(Box::new(x)) }), ))(s) } diff --git a/src/parser/source_text/module_parameters_and_ports.rs b/src/parser/source_text/module_parameters_and_ports.rs index 609203d..ba5d4e0 100644 --- a/src/parser/source_text/module_parameters_and_ports.rs +++ b/src/parser/source_text/module_parameters_and_ports.rs @@ -10,9 +10,9 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum ParameterPortList { - Assignment(ParameterPortListAssignment), - Declaration(ParameterPortListDeclaration), - Empty((Symbol, Symbol, Symbol)), + Assignment(Box), + Declaration(Box), + Empty(Box<(Symbol, Symbol, Symbol)>), } #[derive(Clone, Debug, Node)] @@ -33,10 +33,10 @@ pub struct ParameterPortListDeclaration { #[derive(Clone, Debug, Node)] pub enum ParameterPortDeclaration { - ParameterDeclaration(ParameterDeclaration), - LocalParameterDeclaration(LocalParameterDeclaration), - ParamList(ParameterPortDeclarationParamList), - TypeList(ParameterPortDeclarationTypeList), + ParameterDeclaration(Box), + LocalParameterDeclaration(Box), + ParamList(Box), + TypeList(Box), } #[derive(Clone, Debug, Node)] @@ -61,11 +61,11 @@ pub struct ListOfPortDeclarations { #[derive(Clone, Debug, Node)] pub enum PortDeclaration { - Inout(PortDeclarationInout), - Input(PortDeclarationInput), - Output(PortDeclarationOutput), - Ref(PortDeclarationRef), - Interface(PortDeclarationInterface), + Inout(Box), + Input(Box), + Output(Box), + Ref(Box), + Interface(Box), } #[derive(Clone, Debug, Node)] @@ -95,8 +95,8 @@ pub struct PortDeclarationInterface { #[derive(Clone, Debug, Node)] pub enum Port { - NonNamed(PortNonNamed), - Named(PortNamed), + NonNamed(Box), + Named(Box), } #[derive(Clone, Debug, Node)] @@ -111,8 +111,8 @@ pub struct PortNamed { #[derive(Clone, Debug, Node)] pub enum PortExpression { - PortReference(PortReference), - Brace(PortExpressionBrace), + PortReference(Box), + Brace(Box), } #[derive(Clone, Debug, Node)] @@ -127,10 +127,10 @@ pub struct PortReference { #[derive(Clone, Debug, Node)] pub enum PortDirection { - Input(Keyword), - Output(Keyword), - Inout(Keyword), - Ref(Keyword), + Input(Box), + Output(Box), + Inout(Box), + Ref(Box), } #[derive(Clone, Debug, Node)] @@ -145,8 +145,8 @@ pub struct VariablePortHeader { #[derive(Clone, Debug, Node)] pub enum InterfacePortHeader { - Identifier(InterfacePortHeaderIdentifier), - Interface(InterfacePortHeaderInterface), + Identifier(Box), + Interface(Box), } #[derive(Clone, Debug, Node)] @@ -161,14 +161,14 @@ pub struct InterfacePortHeaderInterface { #[derive(Clone, Debug, Node)] pub enum NetPortHeaderOrInterfacePortHeader { - NetPortHeader(NetPortHeader), - InterfacePortHeader(InterfacePortHeader), + NetPortHeader(Box), + InterfacePortHeader(Box), } #[derive(Clone, Debug, Node)] pub enum AnsiPortDeclaration { - Net(AnsiPortDeclarationNet), - Variable(AnsiPortDeclarationVariable), - Paren(AnsiPortDeclarationParen), + Net(Box), + Variable(Box), + Paren(Box), } #[derive(Clone, Debug, Node)] @@ -221,7 +221,7 @@ pub fn parameter_port_list_assignment(s: Span) -> IResult IResult IResult { let (s, a) = symbol("#")(s)?; let (s, b) = symbol("(")(s)?; let (s, c) = symbol(")")(s)?; - Ok((s, ParameterPortList::Empty((a, b, c)))) + Ok((s, ParameterPortList::Empty(Box::new((a, b, c))))) } #[parser] pub fn parameter_port_declaration(s: Span) -> IResult { alt(( map(parameter_declaration, |x| { - ParameterPortDeclaration::ParameterDeclaration(x) + ParameterPortDeclaration::ParameterDeclaration(Box::new(x)) }), map(local_parameter_declaration, |x| { - ParameterPortDeclaration::LocalParameterDeclaration(x) + ParameterPortDeclaration::LocalParameterDeclaration(Box::new(x)) }), parameter_port_declaration_param_list, parameter_port_declaration_type_list, @@ -263,7 +263,9 @@ pub fn parameter_port_declaration_param_list(s: Span) -> IResult IResult IResult { let (s, b) = inout_declaration(s)?; Ok(( s, - PortDeclaration::Inout(PortDeclarationInout { nodes: (a, b) }), + PortDeclaration::Inout(Box::new(PortDeclarationInout { nodes: (a, b) })), )) } @@ -319,7 +323,7 @@ pub fn port_declaration_input(s: Span) -> IResult { let (s, b) = input_declaration(s)?; Ok(( s, - PortDeclaration::Input(PortDeclarationInput { nodes: (a, b) }), + PortDeclaration::Input(Box::new(PortDeclarationInput { nodes: (a, b) })), )) } @@ -329,7 +333,7 @@ pub fn port_declaration_output(s: Span) -> IResult { let (s, b) = output_declaration(s)?; Ok(( s, - PortDeclaration::Output(PortDeclarationOutput { nodes: (a, b) }), + PortDeclaration::Output(Box::new(PortDeclarationOutput { nodes: (a, b) })), )) } @@ -339,7 +343,7 @@ pub fn port_declaration_ref(s: Span) -> IResult { let (s, b) = ref_declaration(s)?; Ok(( s, - PortDeclaration::Ref(PortDeclarationRef { nodes: (a, b) }), + PortDeclaration::Ref(Box::new(PortDeclarationRef { nodes: (a, b) })), )) } @@ -349,7 +353,7 @@ pub fn port_declaration_interface(s: Span) -> IResult { let (s, b) = interface_port_declaration(s)?; Ok(( s, - PortDeclaration::Interface(PortDeclarationInterface { nodes: (a, b) }), + PortDeclaration::Interface(Box::new(PortDeclarationInterface { nodes: (a, b) })), )) } @@ -361,7 +365,7 @@ pub fn port(s: Span) -> IResult { #[parser(MaybeRecursive)] pub fn port_non_named(s: Span) -> IResult { let (s, a) = opt(port_expression)(s)?; - Ok((s, Port::NonNamed(PortNonNamed { nodes: (a,) }))) + Ok((s, Port::NonNamed(Box::new(PortNonNamed { nodes: (a,) })))) } #[parser] @@ -369,13 +373,15 @@ pub fn port_named(s: Span) -> IResult { let (s, a) = symbol(".")(s)?; let (s, b) = port_identifier(s)?; let (s, c) = paren(opt(port_expression))(s)?; - Ok((s, Port::Named(PortNamed { nodes: (a, b, c) }))) + Ok((s, Port::Named(Box::new(PortNamed { nodes: (a, b, c) })))) } #[parser] pub fn port_expression(s: Span) -> IResult { alt(( - map(port_reference, |x| PortExpression::PortReference(x)), + map(port_reference, |x| { + PortExpression::PortReference(Box::new(x)) + }), port_expressio_named, ))(s) } @@ -385,7 +391,7 @@ pub fn port_expressio_named(s: Span) -> IResult { let (s, a) = brace(list(symbol(","), port_reference))(s)?; Ok(( s, - PortExpression::Brace(PortExpressionBrace { nodes: (a,) }), + PortExpression::Brace(Box::new(PortExpressionBrace { nodes: (a,) })), )) } @@ -399,10 +405,10 @@ pub fn port_reference(s: Span) -> IResult { #[parser] pub fn port_direction(s: Span) -> IResult { alt(( - map(keyword("input"), |x| PortDirection::Input(x)), - map(keyword("output"), |x| PortDirection::Output(x)), - map(keyword("inout"), |x| PortDirection::Inout(x)), - map(keyword("ref"), |x| PortDirection::Ref(x)), + map(keyword("input"), |x| PortDirection::Input(Box::new(x))), + map(keyword("output"), |x| PortDirection::Output(Box::new(x))), + map(keyword("inout"), |x| PortDirection::Inout(Box::new(x))), + map(keyword("ref"), |x| PortDirection::Ref(Box::new(x))), ))(s) } @@ -434,7 +440,7 @@ pub fn interface_port_header_identifier(s: Span) -> IResult IResult IResult let (s, d) = opt(pair(symbol("="), constant_expression))(s)?; Ok(( s, - AnsiPortDeclaration::Net(AnsiPortDeclarationNet { + AnsiPortDeclaration::Net(Box::new(AnsiPortDeclarationNet { nodes: (a, b, c, d), - }), + })), )) } @@ -477,10 +483,10 @@ pub fn net_port_header_or_interface_port_header( ) -> IResult { alt(( map(net_port_header, |x| { - NetPortHeaderOrInterfacePortHeader::NetPortHeader(x) + NetPortHeaderOrInterfacePortHeader::NetPortHeader(Box::new(x)) }), map(interface_port_header, |x| { - NetPortHeaderOrInterfacePortHeader::InterfacePortHeader(x) + NetPortHeaderOrInterfacePortHeader::InterfacePortHeader(Box::new(x)) }), ))(s) } @@ -493,9 +499,9 @@ pub fn ansi_port_declaration_port(s: Span) -> IResult let (s, d) = opt(pair(symbol("="), constant_expression))(s)?; Ok(( s, - AnsiPortDeclaration::Variable(AnsiPortDeclarationVariable { + AnsiPortDeclaration::Variable(Box::new(AnsiPortDeclarationVariable { nodes: (a, b, c, d), - }), + })), )) } @@ -507,8 +513,8 @@ pub fn ansi_port_declaration_paren(s: Span) -> IResult), + AnonymousProgram(Box), + PackageExportDeclaration(Box), + TimeunitsDeclaration(Box), } #[derive(Clone, Debug, Node)] pub enum PackageOrGenerateItemDeclaration { - NetDeclaration(NetDeclaration), - DataDeclaration(DataDeclaration), - TaskDeclaration(TaskDeclaration), - FunctionDeclaration(FunctionDeclaration), - CheckerDeclaration(CheckerDeclaration), - DpiImportExport(DpiImportExport), - ExternConstraintDeclaration(ExternConstraintDeclaration), - ClassDeclaration(ClassDeclaration), - ClassConstructorDeclaration(ClassConstructorDeclaration), - LocalParameterDeclaration((LocalParameterDeclaration, Symbol)), - ParameterDeclaration((ParameterDeclaration, Symbol)), - CovergroupDeclaration(CovergroupDeclaration), - AssertionItemDeclaration(AssertionItemDeclaration), - Empty(Symbol), + NetDeclaration(Box), + DataDeclaration(Box), + TaskDeclaration(Box), + FunctionDeclaration(Box), + CheckerDeclaration(Box), + DpiImportExport(Box), + ExternConstraintDeclaration(Box), + ClassDeclaration(Box), + ClassConstructorDeclaration(Box), + LocalParameterDeclaration(Box<(LocalParameterDeclaration, Symbol)>), + ParameterDeclaration(Box<(ParameterDeclaration, Symbol)>), + CovergroupDeclaration(Box), + AssertionItemDeclaration(Box), + Empty(Box), } #[derive(Clone, Debug, Node)] @@ -41,12 +41,12 @@ pub struct AnonymousProgram { #[derive(Clone, Debug, Node)] pub enum AnonymousProgramItem { - TaskDeclaration(TaskDeclaration), - FunctionDeclaration(FunctionDeclaration), - ClassDeclaration(ClassDeclaration), - CovergroupDeclaration(CovergroupDeclaration), - ClassConstructorDeclaration(ClassConstructorDeclaration), - Empty(Symbol), + TaskDeclaration(Box), + FunctionDeclaration(Box), + ClassDeclaration(Box), + CovergroupDeclaration(Box), + ClassConstructorDeclaration(Box), + Empty(Box), } // ----------------------------------------------------------------------------- @@ -55,14 +55,16 @@ pub enum AnonymousProgramItem { pub fn package_item(s: Span) -> IResult { alt(( map(package_or_generate_item_declaration, |x| { - PackageItem::PackageOrGenerateItemDeclaration(x) + PackageItem::PackageOrGenerateItemDeclaration(Box::new(x)) + }), + map(anonymous_program, |x| { + PackageItem::AnonymousProgram(Box::new(x)) }), - map(anonymous_program, |x| PackageItem::AnonymousProgram(x)), map(package_export_declaration, |x| { - PackageItem::PackageExportDeclaration(x) + PackageItem::PackageExportDeclaration(Box::new(x)) }), map(timeunits_declaration, |x| { - PackageItem::TimeunitsDeclaration(x) + PackageItem::TimeunitsDeclaration(Box::new(x)) }), ))(s) } @@ -73,45 +75,47 @@ pub fn package_or_generate_item_declaration( ) -> IResult { alt(( map(net_declaration, |x| { - PackageOrGenerateItemDeclaration::NetDeclaration(x) + PackageOrGenerateItemDeclaration::NetDeclaration(Box::new(x)) }), map(data_declaration, |x| { - PackageOrGenerateItemDeclaration::DataDeclaration(x) + PackageOrGenerateItemDeclaration::DataDeclaration(Box::new(x)) }), map(task_declaration, |x| { - PackageOrGenerateItemDeclaration::TaskDeclaration(x) + PackageOrGenerateItemDeclaration::TaskDeclaration(Box::new(x)) }), map(function_declaration, |x| { - PackageOrGenerateItemDeclaration::FunctionDeclaration(x) + PackageOrGenerateItemDeclaration::FunctionDeclaration(Box::new(x)) }), map(checker_declaration, |x| { - PackageOrGenerateItemDeclaration::CheckerDeclaration(x) + PackageOrGenerateItemDeclaration::CheckerDeclaration(Box::new(x)) }), map(dpi_import_export, |x| { - PackageOrGenerateItemDeclaration::DpiImportExport(x) + PackageOrGenerateItemDeclaration::DpiImportExport(Box::new(x)) }), map(extern_constraint_declaration, |x| { - PackageOrGenerateItemDeclaration::ExternConstraintDeclaration(x) + PackageOrGenerateItemDeclaration::ExternConstraintDeclaration(Box::new(x)) }), map(class_declaration, |x| { - PackageOrGenerateItemDeclaration::ClassDeclaration(x) + PackageOrGenerateItemDeclaration::ClassDeclaration(Box::new(x)) }), map(class_constructor_declaration, |x| { - PackageOrGenerateItemDeclaration::ClassConstructorDeclaration(x) + PackageOrGenerateItemDeclaration::ClassConstructorDeclaration(Box::new(x)) }), map(pair(local_parameter_declaration, symbol(";")), |x| { - PackageOrGenerateItemDeclaration::LocalParameterDeclaration(x) + PackageOrGenerateItemDeclaration::LocalParameterDeclaration(Box::new(x)) }), map(pair(parameter_declaration, symbol(";")), |x| { - PackageOrGenerateItemDeclaration::ParameterDeclaration(x) + PackageOrGenerateItemDeclaration::ParameterDeclaration(Box::new(x)) }), map(covergroup_declaration, |x| { - PackageOrGenerateItemDeclaration::CovergroupDeclaration(x) + PackageOrGenerateItemDeclaration::CovergroupDeclaration(Box::new(x)) }), map(assertion_item_declaration, |x| { - PackageOrGenerateItemDeclaration::AssertionItemDeclaration(x) + PackageOrGenerateItemDeclaration::AssertionItemDeclaration(Box::new(x)) + }), + map(symbol(";"), |x| { + PackageOrGenerateItemDeclaration::Empty(Box::new(x)) }), - map(symbol(";"), |x| PackageOrGenerateItemDeclaration::Empty(x)), ))(s) } @@ -133,20 +137,20 @@ pub fn anonymous_program(s: Span) -> IResult { pub fn anonymous_program_item(s: Span) -> IResult { alt(( map(task_declaration, |x| { - AnonymousProgramItem::TaskDeclaration(x) + AnonymousProgramItem::TaskDeclaration(Box::new(x)) }), map(function_declaration, |x| { - AnonymousProgramItem::FunctionDeclaration(x) + AnonymousProgramItem::FunctionDeclaration(Box::new(x)) }), map(class_declaration, |x| { - AnonymousProgramItem::ClassDeclaration(x) + AnonymousProgramItem::ClassDeclaration(Box::new(x)) }), map(covergroup_declaration, |x| { - AnonymousProgramItem::CovergroupDeclaration(x) + AnonymousProgramItem::CovergroupDeclaration(Box::new(x)) }), map(class_constructor_declaration, |x| { - AnonymousProgramItem::ClassConstructorDeclaration(x) + AnonymousProgramItem::ClassConstructorDeclaration(Box::new(x)) }), - map(symbol(";"), |x| AnonymousProgramItem::Empty(x)), + map(symbol(";"), |x| AnonymousProgramItem::Empty(Box::new(x))), ))(s) } diff --git a/src/parser/source_text/program_items.rs b/src/parser/source_text/program_items.rs index a1da535..b96f1a6 100644 --- a/src/parser/source_text/program_items.rs +++ b/src/parser/source_text/program_items.rs @@ -10,19 +10,19 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum ProgramItem { - PortDeclaration((PortDeclaration, Symbol)), - NonPortProgramItem(NonPortProgramItem), + PortDeclaration(Box<(PortDeclaration, Symbol)>), + NonPortProgramItem(Box), } #[derive(Clone, Debug, Node)] pub enum NonPortProgramItem { - Assign(NonPortProgramItemAssign), - Module(NonPortProgramItemModule), - Initial(NonPortProgramItemInitial), - Final(NonPortProgramItemFinal), - Assertion(NonPortProgramItemAssertion), - TimeunitsDeclaration(TimeunitsDeclaration), - ProgramGenerateItem(ProgramGenerateItem), + Assign(Box), + Module(Box), + Initial(Box), + Final(Box), + Assertion(Box), + TimeunitsDeclaration(Box), + ProgramGenerateItem(Box), } #[derive(Clone, Debug, Node)] @@ -52,10 +52,10 @@ pub struct NonPortProgramItemAssertion { #[derive(Clone, Debug, Node)] pub enum ProgramGenerateItem { - LoopGenerateConstruct(LoopGenerateConstruct), - ConditionalGenerateConstruct(ConditionalGenerateConstruct), - GenerateRegion(GenerateRegion), - ElaborationSystemTask(ElaborationSystemTask), + LoopGenerateConstruct(Box), + ConditionalGenerateConstruct(Box), + GenerateRegion(Box), + ElaborationSystemTask(Box), } // ----------------------------------------------------------------------------- @@ -64,10 +64,10 @@ pub enum ProgramGenerateItem { pub fn program_item(s: Span) -> IResult { alt(( map(pair(port_declaration, symbol(";")), |x| { - ProgramItem::PortDeclaration(x) + ProgramItem::PortDeclaration(Box::new(x)) }), map(non_port_program_item, |x| { - ProgramItem::NonPortProgramItem(x) + ProgramItem::NonPortProgramItem(Box::new(x)) }), ))(s) } @@ -81,10 +81,10 @@ pub fn non_port_program_item(s: Span) -> IResult { non_port_program_item_final, non_port_program_item_assertion, map(timeunits_declaration, |x| { - NonPortProgramItem::TimeunitsDeclaration(x) + NonPortProgramItem::TimeunitsDeclaration(Box::new(x)) }), map(program_generate_item, |x| { - NonPortProgramItem::ProgramGenerateItem(x) + NonPortProgramItem::ProgramGenerateItem(Box::new(x)) }), ))(s) } @@ -95,7 +95,7 @@ pub fn non_port_program_item_assign(s: Span) -> IResult IResult IResult IResult let (s, b) = final_construct(s)?; Ok(( s, - NonPortProgramItem::Final(NonPortProgramItemFinal { nodes: (a, b) }), + NonPortProgramItem::Final(Box::new(NonPortProgramItemFinal { nodes: (a, b) })), )) } @@ -135,7 +135,7 @@ pub fn non_port_program_item_assertion(s: Span) -> IResult IResult IResult { alt(( map(loop_generate_construct, |x| { - ProgramGenerateItem::LoopGenerateConstruct(x) + ProgramGenerateItem::LoopGenerateConstruct(Box::new(x)) }), map(conditional_generate_construct, |x| { - ProgramGenerateItem::ConditionalGenerateConstruct(x) + ProgramGenerateItem::ConditionalGenerateConstruct(Box::new(x)) + }), + map(generate_region, |x| { + ProgramGenerateItem::GenerateRegion(Box::new(x)) }), - map(generate_region, |x| ProgramGenerateItem::GenerateRegion(x)), map(elaboration_system_task, |x| { - ProgramGenerateItem::ElaborationSystemTask(x) + ProgramGenerateItem::ElaborationSystemTask(Box::new(x)) }), ))(s) } diff --git a/src/parser/source_text/system_verilog_source_text.rs b/src/parser/source_text/system_verilog_source_text.rs index c9ec38d..00fe169 100644 --- a/src/parser/source_text/system_verilog_source_text.rs +++ b/src/parser/source_text/system_verilog_source_text.rs @@ -15,14 +15,14 @@ pub struct SourceText { #[derive(Clone, Debug, Node)] pub enum Description { - ModuleDeclaration(ModuleDeclaration), - UdpDeclaration(UdpDeclaration), - InterfaceDeclaration(InterfaceDeclaration), - ProgramDeclaration(ProgramDeclaration), - PackageDeclaration(PackageDeclaration), - PackageItem(DescriptionPackageItem), - BindDirective(DescriptionBindDirective), - ConfigDeclaration(ConfigDeclaration), + ModuleDeclaration(Box), + UdpDeclaration(Box), + InterfaceDeclaration(Box), + ProgramDeclaration(Box), + PackageDeclaration(Box), + PackageItem(Box), + BindDirective(Box), + ConfigDeclaration(Box), } #[derive(Clone, Debug, Node)] @@ -65,11 +65,11 @@ pub struct ModuleAnsiHeader { #[derive(Clone, Debug, Node)] pub enum ModuleDeclaration { - Nonansi(ModuleDeclarationNonansi), - Ansi(ModuleDeclarationAnsi), - Wildcard(ModuleDeclarationWildcard), - ExternNonansi(ModuleDeclarationExternNonansi), - ExternAnsi(ModuleDeclarationExternAnsi), + Nonansi(Box), + Ansi(Box), + Wildcard(Box), + ExternNonansi(Box), + ExternAnsi(Box), } #[derive(Clone, Debug, Node)] @@ -122,17 +122,17 @@ pub struct ModuleDeclarationExternAnsi { #[derive(Clone, Debug, Node)] pub enum ModuleKeyword { - Module(Keyword), - Macromodule(Keyword), + Module(Box), + Macromodule(Box), } #[derive(Clone, Debug, Node)] pub enum InterfaceDeclaration { - Nonansi(InterfaceDeclarationNonansi), - Ansi(InterfaceDeclarationAnsi), - Wildcard(InterfaceDeclarationWildcard), - ExternNonansi(InterfaceDeclarationExternNonansi), - ExternAnsi(InterfaceDeclarationExternAnsi), + Nonansi(Box), + Ansi(Box), + Wildcard(Box), + ExternNonansi(Box), + ExternAnsi(Box), } #[derive(Clone, Debug, Node)] @@ -213,11 +213,11 @@ pub struct InterfaceAnsiHeader { #[derive(Clone, Debug, Node)] pub enum ProgramDeclaration { - Nonansi(ProgramDeclarationNonansi), - Ansi(ProgramDeclarationAnsi), - Wildcard(ProgramDeclarationWildcard), - ExternNonansi(ProgramDeclarationExternNonansi), - ExternAnsi(ProgramDeclarationExternAnsi), + Nonansi(Box), + Ansi(Box), + Wildcard(Box), + ExternNonansi(Box), + ExternAnsi(Box), } #[derive(Clone, Debug, Node)] @@ -352,11 +352,11 @@ pub struct InterfaceClassDeclaration { #[derive(Clone, Debug, Node)] pub enum InterfaceClassItem { - TypeDeclaration(TypeDeclaration), - Method(InterfaceClassItemMethod), - LocalParameterDeclaration((LocalParameterDeclaration, Symbol)), - ParameterDeclaration((ParameterDeclaration, Symbol)), - Null(Symbol), + TypeDeclaration(Box), + Method(Box), + LocalParameterDeclaration(Box<(LocalParameterDeclaration, Symbol)>), + ParameterDeclaration(Box<(ParameterDeclaration, Symbol)>), + Null(Box), } #[derive(Clone, Debug, Node)] @@ -386,10 +386,10 @@ pub struct PackageDeclaration { #[derive(Clone, Debug, Node)] pub enum TimeunitsDeclaration { - Timeunit(TimeunitsDeclarationTimeunit), - Timeprecision(TimeunitsDeclarationTimeprecision), - TimeunitTimeprecision(TimeunitsDeclarationTimeunitTimeprecision), - TimeprecisionTimeunit(TimeunitsDeclarationTimeprecisionTimeunit), + Timeunit(Box), + Timeprecision(Box), + TimeunitTimeprecision(Box), + TimeprecisionTimeunit(Box), } #[derive(Clone, Debug, Node)] @@ -424,16 +424,26 @@ pub fn source_text(s: Span) -> IResult { #[parser] pub fn description(s: Span) -> IResult { alt(( - map(module_declaration, |x| Description::ModuleDeclaration(x)), - map(udp_declaration, |x| Description::UdpDeclaration(x)), - map(interface_declaration, |x| { - Description::InterfaceDeclaration(x) + map(module_declaration, |x| { + Description::ModuleDeclaration(Box::new(x)) + }), + map(udp_declaration, |x| { + Description::UdpDeclaration(Box::new(x)) + }), + map(interface_declaration, |x| { + Description::InterfaceDeclaration(Box::new(x)) + }), + map(program_declaration, |x| { + Description::ProgramDeclaration(Box::new(x)) + }), + map(package_declaration, |x| { + Description::PackageDeclaration(Box::new(x)) }), - map(program_declaration, |x| Description::ProgramDeclaration(x)), - map(package_declaration, |x| Description::PackageDeclaration(x)), description_package_item, description_bind_directive, - map(config_declaration, |x| Description::ConfigDeclaration(x)), + map(config_declaration, |x| { + Description::ConfigDeclaration(Box::new(x)) + }), ))(s) } @@ -443,7 +453,7 @@ pub fn description_package_item(s: Span) -> IResult { let (s, b) = package_item(s)?; Ok(( s, - Description::PackageItem(DescriptionPackageItem { nodes: (a, b) }), + Description::PackageItem(Box::new(DescriptionPackageItem { nodes: (a, b) })), )) } @@ -453,7 +463,7 @@ pub fn description_bind_directive(s: Span) -> IResult { let (s, b) = bind_directive(s)?; Ok(( s, - Description::BindDirective(DescriptionBindDirective { nodes: (a, b) }), + Description::BindDirective(Box::new(DescriptionBindDirective { nodes: (a, b) })), )) } @@ -513,9 +523,9 @@ pub fn module_declaration_nonansi(s: Span) -> IResult { let (s, e) = opt(pair(symbol(":"), module_identifier))(s)?; Ok(( s, - ModuleDeclaration::Nonansi(ModuleDeclarationNonansi { + ModuleDeclaration::Nonansi(Box::new(ModuleDeclarationNonansi { nodes: (a, b, c, d, e), - }), + })), )) } @@ -528,9 +538,9 @@ pub fn module_declaration_ansi(s: Span) -> IResult { let (s, e) = opt(pair(symbol(":"), module_identifier))(s)?; Ok(( s, - ModuleDeclaration::Ansi(ModuleDeclarationAnsi { + ModuleDeclaration::Ansi(Box::new(ModuleDeclarationAnsi { nodes: (a, b, c, d, e), - }), + })), )) } @@ -548,9 +558,9 @@ pub fn module_declaration_wildcard(s: Span) -> IResult let (s, j) = opt(pair(symbol(":"), module_identifier))(s)?; Ok(( s, - ModuleDeclaration::Wildcard(ModuleDeclarationWildcard { + ModuleDeclaration::Wildcard(Box::new(ModuleDeclarationWildcard { nodes: (a, b, c, d, e, f, g, h, i, j), - }), + })), )) } @@ -560,7 +570,9 @@ pub fn module_declaration_extern_nonansi(s: Span) -> IResult IResult IResult { alt(( - map(keyword("module"), |x| ModuleKeyword::Module(x)), - map(keyword("macromodule"), |x| ModuleKeyword::Macromodule(x)), + map(keyword("module"), |x| ModuleKeyword::Module(Box::new(x))), + map(keyword("macromodule"), |x| { + ModuleKeyword::Macromodule(Box::new(x)) + }), ))(s) } @@ -602,9 +616,9 @@ pub fn interface_declaration_nonansi(s: Span) -> IResult IResult IResult IResult IResult IResult let (s, e) = opt(pair(symbol(":"), program_identifier))(s)?; Ok(( s, - ProgramDeclaration::Nonansi(ProgramDeclarationNonansi { + ProgramDeclaration::Nonansi(Box::new(ProgramDeclarationNonansi { nodes: (a, b, c, d, e), - }), + })), )) } @@ -734,9 +752,9 @@ pub fn program_declaration_ansi(s: Span) -> IResult { let (s, e) = opt(pair(symbol(":"), program_identifier))(s)?; Ok(( s, - ProgramDeclaration::Ansi(ProgramDeclarationAnsi { + ProgramDeclaration::Ansi(Box::new(ProgramDeclarationAnsi { nodes: (a, b, c, d, e), - }), + })), )) } @@ -753,9 +771,9 @@ pub fn program_declaration_wildcard(s: Span) -> IResult IResult IResult IResult IResult { alt(( - map(type_declaration, |x| InterfaceClassItem::TypeDeclaration(x)), + map(type_declaration, |x| { + InterfaceClassItem::TypeDeclaration(Box::new(x)) + }), interface_class_item_method, map(pair(local_parameter_declaration, symbol(";")), |x| { - InterfaceClassItem::LocalParameterDeclaration(x) + InterfaceClassItem::LocalParameterDeclaration(Box::new(x)) }), map(pair(parameter_declaration, symbol(";")), |x| { - InterfaceClassItem::ParameterDeclaration(x) + InterfaceClassItem::ParameterDeclaration(Box::new(x)) }), - map(symbol(";"), |x| InterfaceClassItem::Null(x)), + map(symbol(";"), |x| InterfaceClassItem::Null(Box::new(x))), ))(s) } @@ -910,7 +932,7 @@ pub fn interface_class_item_method(s: Span) -> IResult let (s, b) = interface_class_method(s)?; Ok(( s, - InterfaceClassItem::Method(InterfaceClassItemMethod { nodes: (a, b) }), + InterfaceClassItem::Method(Box::new(InterfaceClassItemMethod { nodes: (a, b) })), )) } @@ -965,9 +987,9 @@ pub fn timeunits_declaration_timeunit(s: Span) -> IResult IResult), + PulsestyleDeclaration(Box), + ShowcancelledDeclaration(Box), + PathDeclaration(Box), + SystemTimingCheck(Box), } #[derive(Clone, Debug, Node)] @@ -45,16 +45,20 @@ pub fn specify_block(s: Span) -> IResult { pub fn specify_item(s: Span) -> IResult { alt(( map(specparam_declaration, |x| { - SpecifyItem::SpecparamDeclaration(x) + SpecifyItem::SpecparamDeclaration(Box::new(x)) }), map(pulsestyle_declaration, |x| { - SpecifyItem::PulsestyleDeclaration(x) + SpecifyItem::PulsestyleDeclaration(Box::new(x)) }), map(showcancelled_declaration, |x| { - SpecifyItem::ShowcancelledDeclaration(x) + SpecifyItem::ShowcancelledDeclaration(Box::new(x)) + }), + map(path_declaration, |x| { + SpecifyItem::PathDeclaration(Box::new(x)) + }), + map(system_timing_check, |x| { + SpecifyItem::SystemTimingCheck(Box::new(x)) }), - map(path_declaration, |x| SpecifyItem::PathDeclaration(x)), - map(system_timing_check, |x| SpecifyItem::SystemTimingCheck(x)), ))(s) } diff --git a/src/parser/specify_section/specify_block_terminals.rs b/src/parser/specify_section/specify_block_terminals.rs index f527e5c..f858d1b 100644 --- a/src/parser/specify_section/specify_block_terminals.rs +++ b/src/parser/specify_section/specify_block_terminals.rs @@ -18,9 +18,9 @@ pub struct SpecifyOutputTerminalDescriptor { #[derive(Clone, Debug, Node)] pub enum InputIdentifier { - InputPortIdentifier(InputPortIdentifier), - InoutPortIdentifier(InoutPortIdentifier), - Interface(InputIdentifierInterface), + InputPortIdentifier(Box), + InoutPortIdentifier(Box), + Interface(Box), } #[derive(Clone, Debug, Node)] @@ -30,9 +30,9 @@ pub struct InputIdentifierInterface { #[derive(Clone, Debug, Node)] pub enum OutputIdentifier { - OutputPortIdentifier(OutputPortIdentifier), - InoutPortIdentifier(InoutPortIdentifier), - Interface(OutputIdentifierInterface), + OutputPortIdentifier(Box), + InoutPortIdentifier(Box), + Interface(Box), } #[derive(Clone, Debug, Node)] @@ -62,10 +62,10 @@ pub fn specify_output_terminal_descriptor( pub fn input_identifier(s: Span) -> IResult { alt(( map(input_port_identifier, |x| { - InputIdentifier::InputPortIdentifier(x) + InputIdentifier::InputPortIdentifier(Box::new(x)) }), map(inout_port_identifier, |x| { - InputIdentifier::InoutPortIdentifier(x) + InputIdentifier::InoutPortIdentifier(Box::new(x)) }), input_identifier_interface, ))(s) @@ -78,7 +78,7 @@ pub fn input_identifier_interface(s: Span) -> IResult { let (s, c) = port_identifier(s)?; Ok(( s, - InputIdentifier::Interface(InputIdentifierInterface { nodes: (a, b, c) }), + InputIdentifier::Interface(Box::new(InputIdentifierInterface { nodes: (a, b, c) })), )) } @@ -86,10 +86,10 @@ pub fn input_identifier_interface(s: Span) -> IResult { pub fn output_identifier(s: Span) -> IResult { alt(( map(output_port_identifier, |x| { - OutputIdentifier::OutputPortIdentifier(x) + OutputIdentifier::OutputPortIdentifier(Box::new(x)) }), map(inout_port_identifier, |x| { - OutputIdentifier::InoutPortIdentifier(x) + OutputIdentifier::InoutPortIdentifier(Box::new(x)) }), output_identifier_interface, ))(s) @@ -102,6 +102,6 @@ pub fn output_identifier_interface(s: Span) -> IResult { let (s, c) = port_identifier(s)?; Ok(( s, - OutputIdentifier::Interface(OutputIdentifierInterface { nodes: (a, b, c) }), + OutputIdentifier::Interface(Box::new(OutputIdentifierInterface { nodes: (a, b, c) })), )) } diff --git a/src/parser/specify_section/specify_path_declarations.rs b/src/parser/specify_section/specify_path_declarations.rs index dbd8c4e..c1af8f5 100644 --- a/src/parser/specify_section/specify_path_declarations.rs +++ b/src/parser/specify_section/specify_path_declarations.rs @@ -9,15 +9,15 @@ use nom::IResult; #[derive(Clone, Debug, Node)] pub enum PathDeclaration { - SimplePathDeclaration((SimplePathDeclaration, Symbol)), - EdgeSensitivePathDeclaration((EdgeSensitivePathDeclaration, Symbol)), - StateDependentPathDeclaration((StateDependentPathDeclaration, Symbol)), + SimplePathDeclaration(Box<(SimplePathDeclaration, Symbol)>), + EdgeSensitivePathDeclaration(Box<(EdgeSensitivePathDeclaration, Symbol)>), + StateDependentPathDeclaration(Box<(StateDependentPathDeclaration, Symbol)>), } #[derive(Clone, Debug, Node)] pub enum SimplePathDeclaration { - Parallel(SimplePathDeclarationParallel), - Full(SimplePathDeclarationFull), + Parallel(Box), + Full(Box), } #[derive(Clone, Debug, Node)] @@ -70,13 +70,13 @@ pub struct ListOfPathOutputs { pub fn path_declaration(s: Span) -> IResult { alt(( map(pair(simple_path_declaration, symbol(";")), |x| { - PathDeclaration::SimplePathDeclaration(x) + PathDeclaration::SimplePathDeclaration(Box::new(x)) }), map(pair(edge_sensitive_path_declaration, symbol(";")), |x| { - PathDeclaration::EdgeSensitivePathDeclaration(x) + PathDeclaration::EdgeSensitivePathDeclaration(Box::new(x)) }), map(pair(state_dependent_path_declaration, symbol(";")), |x| { - PathDeclaration::StateDependentPathDeclaration(x) + PathDeclaration::StateDependentPathDeclaration(Box::new(x)) }), ))(s) } @@ -96,7 +96,9 @@ pub fn simple_path_declaration_parallel(s: Span) -> IResult IResult), + Paren(Box), } #[derive(Clone, Debug, Node)] @@ -34,8 +34,8 @@ pub struct PathDelayExpression { #[derive(Clone, Debug, Node)] pub enum EdgeSensitivePathDeclaration { - Parallel(EdgeSensitivePathDeclarationParallel), - Full(EdgeSensitivePathDeclarationFull), + Parallel(Box), + Full(Box), } #[derive(Clone, Debug, Node)] @@ -91,16 +91,16 @@ pub struct DataSourceExpression { #[derive(Clone, Debug, Node)] pub enum EdgeIdentifier { - Posedge(Keyword), - Negedge(Keyword), - Edge(Keyword), + Posedge(Box), + Negedge(Box), + Edge(Box), } #[derive(Clone, Debug, Node)] pub enum StateDependentPathDeclaration { - IfSimple(StateDependentPathDeclarationIfSimple), - IfEdgeSensitive(StateDependentPathDeclarationIfEdgeSensitive), - IfNone(StateDependentPathDeclarationIfNone), + IfSimple(Box), + IfEdgeSensitive(Box), + IfNone(Box), } #[derive(Clone, Debug, Node)] @@ -133,7 +133,7 @@ pub struct PolarityOperator { pub fn path_delay_value(s: Span) -> IResult { alt(( map(list_of_path_delay_expressions, |x| { - PathDelayValue::ListOfPathDelayExpressions(x) + PathDelayValue::ListOfPathDelayExpressions(Box::new(x)) }), path_delay_value_paren, ))(s) @@ -144,7 +144,7 @@ pub fn path_delay_value_paren(s: Span) -> IResult { let (s, a) = paren(list_of_path_delay_expressions)(s)?; Ok(( s, - PathDelayValue::Paren(PathDelayValueParen { nodes: (a,) }), + PathDelayValue::Paren(Box::new(PathDelayValueParen { nodes: (a,) })), )) } @@ -183,9 +183,9 @@ pub fn edge_sensitive_path_declaration_parallel( let (s, c) = path_delay_value(s)?; Ok(( s, - EdgeSensitivePathDeclaration::Parallel(EdgeSensitivePathDeclarationParallel { + EdgeSensitivePathDeclaration::Parallel(Box::new(EdgeSensitivePathDeclarationParallel { nodes: (a, b, c), - }), + })), )) } @@ -198,7 +198,9 @@ pub fn edge_sensitive_path_declaration_full( let (s, c) = path_delay_value(s)?; Ok(( s, - EdgeSensitivePathDeclaration::Full(EdgeSensitivePathDeclarationFull { nodes: (a, b, c) }), + EdgeSensitivePathDeclaration::Full(Box::new(EdgeSensitivePathDeclarationFull { + nodes: (a, b, c), + })), )) } @@ -249,9 +251,9 @@ pub fn data_source_expression(s: Span) -> IResult { #[parser] pub fn edge_identifier(s: Span) -> IResult { alt(( - map(keyword("posedge"), |x| EdgeIdentifier::Posedge(x)), - map(keyword("negedge"), |x| EdgeIdentifier::Negedge(x)), - map(keyword("edge"), |x| EdgeIdentifier::Edge(x)), + map(keyword("posedge"), |x| EdgeIdentifier::Posedge(Box::new(x))), + map(keyword("negedge"), |x| EdgeIdentifier::Negedge(Box::new(x))), + map(keyword("edge"), |x| EdgeIdentifier::Edge(Box::new(x))), ))(s) } @@ -273,9 +275,9 @@ pub fn state_dependent_path_declaration_if_simple( let (s, c) = simple_path_declaration(s)?; Ok(( s, - StateDependentPathDeclaration::IfSimple(StateDependentPathDeclarationIfSimple { + StateDependentPathDeclaration::IfSimple(Box::new(StateDependentPathDeclarationIfSimple { nodes: (a, b, c), - }), + })), )) } @@ -288,9 +290,9 @@ pub fn state_dependent_path_declaration_if_edge_sensitive( let (s, c) = edge_sensitive_path_declaration(s)?; Ok(( s, - StateDependentPathDeclaration::IfEdgeSensitive( + StateDependentPathDeclaration::IfEdgeSensitive(Box::new( StateDependentPathDeclarationIfEdgeSensitive { nodes: (a, b, c) }, - ), + )), )) } @@ -302,9 +304,9 @@ pub fn state_dependent_path_declaration_if_none( let (s, b) = simple_path_declaration(s)?; Ok(( s, - StateDependentPathDeclaration::IfNone(StateDependentPathDeclarationIfNone { + StateDependentPathDeclaration::IfNone(Box::new(StateDependentPathDeclarationIfNone { nodes: (a, b), - }), + })), )) } diff --git a/src/parser/specify_section/system_timing_check_command_arguments.rs b/src/parser/specify_section/system_timing_check_command_arguments.rs index 9684ba7..b9d9ac1 100644 --- a/src/parser/specify_section/system_timing_check_command_arguments.rs +++ b/src/parser/specify_section/system_timing_check_command_arguments.rs @@ -23,8 +23,8 @@ pub struct DataEvent { #[derive(Clone, Debug, Node)] pub enum DelayedData { - TerminalIdentifier(TerminalIdentifier), - WithMintypmax(DelayedDataWithMintypmax), + TerminalIdentifier(Box), + WithMintypmax(Box), } #[derive(Clone, Debug, Node)] @@ -34,8 +34,8 @@ pub struct DelayedDataWithMintypmax { #[derive(Clone, Debug, Node)] pub enum DelayedReference { - TerminalIdentifier(TerminalIdentifier), - WithMintypmax(DelayedReferenceWithMintypmax), + TerminalIdentifier(Box), + WithMintypmax(Box), } #[derive(Clone, Debug, Node)] @@ -111,7 +111,9 @@ pub fn data_event(s: Span) -> IResult { #[parser] pub fn delayed_data(s: Span) -> IResult { alt(( - map(terminal_identifier, |x| DelayedData::TerminalIdentifier(x)), + map(terminal_identifier, |x| { + DelayedData::TerminalIdentifier(Box::new(x)) + }), delayed_data_with_mintypmax, ))(s) } @@ -122,7 +124,7 @@ pub fn delayed_data_with_mintypmax(s: Span) -> IResult { let (s, b) = bracket(constant_mintypmax_expression)(s)?; Ok(( s, - DelayedData::WithMintypmax(DelayedDataWithMintypmax { nodes: (a, b) }), + DelayedData::WithMintypmax(Box::new(DelayedDataWithMintypmax { nodes: (a, b) })), )) } @@ -130,7 +132,7 @@ pub fn delayed_data_with_mintypmax(s: Span) -> IResult { pub fn delayed_reference(s: Span) -> IResult { alt(( map(terminal_identifier, |x| { - DelayedReference::TerminalIdentifier(x) + DelayedReference::TerminalIdentifier(Box::new(x)) }), delayed_reference_with_mintypmax, ))(s) @@ -142,7 +144,7 @@ pub fn delayed_reference_with_mintypmax(s: Span) -> IResult), + HoldTimingCheck(Box), + SetupholdTimingCheck(Box), + RecoveryTimingCheck(Box), + RemovalTimingCheck(Box), + RecremTimingCheck(Box), + SkewTimingCheck(Box), + TimeskewTimingCheck(Box), + FullskewTimingCheck(Box), + PeriodTimingCheck(Box), + WidthTimingCheck(Box), + NochargeTimingCheck(Box), } #[derive(Clone, Debug, Node)] @@ -275,36 +275,40 @@ pub struct NochargeTimingCheck { pub fn system_timing_check(s: Span) -> IResult { alt(( map(setup_timing_check, |x| { - SystemTimingCheck::SetupTimingCheck(x) + SystemTimingCheck::SetupTimingCheck(Box::new(x)) + }), + map(hold_timing_check, |x| { + SystemTimingCheck::HoldTimingCheck(Box::new(x)) }), - map(hold_timing_check, |x| SystemTimingCheck::HoldTimingCheck(x)), map(setuphold_timing_check, |x| { - SystemTimingCheck::SetupholdTimingCheck(x) + SystemTimingCheck::SetupholdTimingCheck(Box::new(x)) }), map(recovery_timing_check, |x| { - SystemTimingCheck::RecoveryTimingCheck(x) + SystemTimingCheck::RecoveryTimingCheck(Box::new(x)) }), map(removal_timing_check, |x| { - SystemTimingCheck::RemovalTimingCheck(x) + SystemTimingCheck::RemovalTimingCheck(Box::new(x)) }), map(recrem_timing_check, |x| { - SystemTimingCheck::RecremTimingCheck(x) + SystemTimingCheck::RecremTimingCheck(Box::new(x)) + }), + map(skew_timing_check, |x| { + SystemTimingCheck::SkewTimingCheck(Box::new(x)) }), - map(skew_timing_check, |x| SystemTimingCheck::SkewTimingCheck(x)), map(timeskew_timing_check, |x| { - SystemTimingCheck::TimeskewTimingCheck(x) + SystemTimingCheck::TimeskewTimingCheck(Box::new(x)) }), map(fullskew_timing_check, |x| { - SystemTimingCheck::FullskewTimingCheck(x) + SystemTimingCheck::FullskewTimingCheck(Box::new(x)) }), map(period_timing_check, |x| { - SystemTimingCheck::PeriodTimingCheck(x) + SystemTimingCheck::PeriodTimingCheck(Box::new(x)) }), map(width_timing_check, |x| { - SystemTimingCheck::WidthTimingCheck(x) + SystemTimingCheck::WidthTimingCheck(Box::new(x)) }), map(nocharge_timing_check, |x| { - SystemTimingCheck::NochargeTimingCheck(x) + SystemTimingCheck::NochargeTimingCheck(Box::new(x)) }), ))(s) } diff --git a/src/parser/specify_section/system_timing_check_event_definitions.rs b/src/parser/specify_section/system_timing_check_event_definitions.rs index 83c9db9..99db472 100644 --- a/src/parser/specify_section/system_timing_check_event_definitions.rs +++ b/src/parser/specify_section/system_timing_check_event_definitions.rs @@ -27,16 +27,16 @@ pub struct ControlledTimingCheckEvent { #[derive(Clone, Debug, Node)] pub enum TimingCheckEventControl { - Posedge(Keyword), - Negedge(Keyword), - Edge(Keyword), - EdgeControlSpecifier(EdgeControlSpecifier), + Posedge(Box), + Negedge(Box), + Edge(Box), + EdgeControlSpecifier(Box), } #[derive(Clone, Debug, Node)] pub enum SpecifyTerminalDescriptor { - SpecifyInputTerminalDescriptor(SpecifyInputTerminalDescriptor), - SpecifyOutputTerminalDescriptor(SpecifyOutputTerminalDescriptor), + SpecifyInputTerminalDescriptor(Box), + SpecifyOutputTerminalDescriptor(Box), } #[derive(Clone, Debug, Node)] @@ -51,8 +51,8 @@ pub struct EdgeDescriptor { #[derive(Clone, Debug, Node)] pub enum TimingCheckCondition { - ScalarTimingCheckCondition(ScalarTimingCheckCondition), - Paren(TimingCheckConditionParen), + ScalarTimingCheckCondition(Box), + Paren(Box), } #[derive(Clone, Debug, Node)] @@ -62,9 +62,9 @@ pub struct TimingCheckConditionParen { #[derive(Clone, Debug, Node)] pub enum ScalarTimingCheckCondition { - Expression(Expression), - Unary(ScalarTimingCheckConditionUnary), - Binary(ScalarTimingCheckConditionBinary), + Expression(Box), + Unary(Box), + Binary(Box), } #[derive(Clone, Debug, Node)] @@ -103,11 +103,17 @@ pub fn controlled_timing_check_event(s: Span) -> IResult IResult { alt(( - map(keyword("posedge"), |x| TimingCheckEventControl::Posedge(x)), - map(keyword("negedge"), |x| TimingCheckEventControl::Negedge(x)), - map(keyword("edge"), |x| TimingCheckEventControl::Edge(x)), + map(keyword("posedge"), |x| { + TimingCheckEventControl::Posedge(Box::new(x)) + }), + map(keyword("negedge"), |x| { + TimingCheckEventControl::Negedge(Box::new(x)) + }), + map(keyword("edge"), |x| { + TimingCheckEventControl::Edge(Box::new(x)) + }), map(edge_control_specifier, |x| { - TimingCheckEventControl::EdgeControlSpecifier(x) + TimingCheckEventControl::EdgeControlSpecifier(Box::new(x)) }), ))(s) } @@ -116,10 +122,10 @@ pub fn timing_check_event_control(s: Span) -> IResult IResult { alt(( map(specify_input_terminal_descriptor, |x| { - SpecifyTerminalDescriptor::SpecifyInputTerminalDescriptor(x) + SpecifyTerminalDescriptor::SpecifyInputTerminalDescriptor(Box::new(x)) }), map(specify_output_terminal_descriptor, |x| { - SpecifyTerminalDescriptor::SpecifyOutputTerminalDescriptor(x) + SpecifyTerminalDescriptor::SpecifyOutputTerminalDescriptor(Box::new(x)) }), ))(s) } @@ -159,7 +165,7 @@ pub fn edge_descriptor(s: Span) -> IResult { pub fn timing_check_condition(s: Span) -> IResult { alt(( map(scalar_timing_check_condition, |x| { - TimingCheckCondition::ScalarTimingCheckCondition(x) + TimingCheckCondition::ScalarTimingCheckCondition(Box::new(x)) }), timing_check_condition_paren, ))(s) @@ -170,14 +176,16 @@ pub fn timing_check_condition_paren(s: Span) -> IResult IResult { alt(( - map(expression, |x| ScalarTimingCheckCondition::Expression(x)), + map(expression, |x| { + ScalarTimingCheckCondition::Expression(Box::new(x)) + }), scalar_timing_check_condition_unary, scalar_timing_check_condition_binary, ))(s) @@ -189,7 +197,9 @@ pub fn scalar_timing_check_condition_unary(s: Span) -> IResult IResult), + SequentialBody(Box), } #[derive(Clone, Debug, Node)] @@ -64,8 +64,8 @@ pub struct SequentialEntry { #[derive(Clone, Debug, Node)] pub enum SeqInputList { - LevelInputList(LevelInputList), - EdgeInputList(EdgeInputList), + LevelInputList(Box), + EdgeInputList(Box), } #[derive(Clone, Debug, Node)] @@ -80,8 +80,8 @@ pub struct EdgeInputList { #[derive(Clone, Debug, Node)] pub enum EdgeIndicator { - Paren(EdgeIndicatorParen), - EdgeSymbol(EdgeSymbol), + Paren(Box), + EdgeSymbol(Box), } #[derive(Clone, Debug, Node)] @@ -96,8 +96,8 @@ pub struct CurrentState { #[derive(Clone, Debug, Node)] pub enum NextState { - OutputSymbol(OutputSymbol), - Minus(Symbol), + OutputSymbol(Box), + Minus(Box), } #[derive(Clone, Debug, Node)] @@ -120,8 +120,10 @@ pub struct EdgeSymbol { #[parser] pub fn udp_body(s: Span) -> IResult { alt(( - map(combinational_body, |x| UdpBody::CombinationalBody(x)), - map(sequential_body, |x| UdpBody::SequentialBody(x)), + map(combinational_body, |x| { + UdpBody::CombinationalBody(Box::new(x)) + }), + map(sequential_body, |x| UdpBody::SequentialBody(Box::new(x))), ))(s) } @@ -218,8 +220,12 @@ pub fn sequential_entry(s: Span) -> IResult { #[parser] pub fn seq_input_list(s: Span) -> IResult { alt(( - map(level_input_list, |x| SeqInputList::LevelInputList(x)), - map(edge_input_list, |x| SeqInputList::EdgeInputList(x)), + map(level_input_list, |x| { + SeqInputList::LevelInputList(Box::new(x)) + }), + map(edge_input_list, |x| { + SeqInputList::EdgeInputList(Box::new(x)) + }), ))(s) } @@ -242,14 +248,17 @@ pub fn edge_input_list(s: Span) -> IResult { pub fn edge_indicator(s: Span) -> IResult { alt(( edge_indicator_paren, - map(edge_symbol, |x| EdgeIndicator::EdgeSymbol(x)), + map(edge_symbol, |x| EdgeIndicator::EdgeSymbol(Box::new(x))), ))(s) } #[parser] pub fn edge_indicator_paren(s: Span) -> IResult { let (s, a) = paren(pair(level_symbol, level_symbol))(s)?; - Ok((s, EdgeIndicator::Paren(EdgeIndicatorParen { nodes: (a,) }))) + Ok(( + s, + EdgeIndicator::Paren(Box::new(EdgeIndicatorParen { nodes: (a,) })), + )) } #[parser] @@ -261,8 +270,8 @@ pub fn current_state(s: Span) -> IResult { #[parser] pub fn next_state(s: Span) -> IResult { alt(( - map(output_symbol, |x| NextState::OutputSymbol(x)), - map(symbol("-"), |x| NextState::Minus(x)), + map(output_symbol, |x| NextState::OutputSymbol(Box::new(x))), + map(symbol("-"), |x| NextState::Minus(Box::new(x))), ))(s) } diff --git a/src/parser/udp_declaration_and_instantiation/udp_declaration.rs b/src/parser/udp_declaration_and_instantiation/udp_declaration.rs index bb2483d..e4e109a 100644 --- a/src/parser/udp_declaration_and_instantiation/udp_declaration.rs +++ b/src/parser/udp_declaration_and_instantiation/udp_declaration.rs @@ -32,11 +32,11 @@ pub struct UdpAnsiDeclaration { #[derive(Clone, Debug, Node)] pub enum UdpDeclaration { - Nonansi(UdpDeclarationNonansi), - Ansi(UdpDeclarationAnsi), - ExternNonansi(UdpDeclarationExternNonansi), - ExternAnsi(UdpDeclarationExternAnsi), - Wildcard(UdpDeclarationWildcard), + Nonansi(Box), + Ansi(Box), + ExternNonansi(Box), + ExternAnsi(Box), + Wildcard(Box), } #[derive(Clone, Debug, Node)] @@ -139,9 +139,9 @@ pub fn udp_declaration_nonansi(s: Span) -> IResult { let (s, f) = opt(pair(symbol(":"), udp_identifier))(s)?; Ok(( s, - UdpDeclaration::Nonansi(UdpDeclarationNonansi { + UdpDeclaration::Nonansi(Box::new(UdpDeclarationNonansi { nodes: (a, b, c, d, e, f), - }), + })), )) } @@ -153,9 +153,9 @@ pub fn udp_declaration_ansi(s: Span) -> IResult { let (s, d) = opt(pair(symbol(":"), udp_identifier))(s)?; Ok(( s, - UdpDeclaration::Ansi(UdpDeclarationAnsi { + UdpDeclaration::Ansi(Box::new(UdpDeclarationAnsi { nodes: (a, b, c, d), - }), + })), )) } @@ -165,7 +165,7 @@ pub fn udp_declaration_extern_nonansi(s: Span) -> IResult let (s, b) = udp_nonansi_declaration(s)?; Ok(( s, - UdpDeclaration::ExternNonansi(UdpDeclarationExternNonansi { nodes: (a, b) }), + UdpDeclaration::ExternNonansi(Box::new(UdpDeclarationExternNonansi { nodes: (a, b) })), )) } @@ -175,7 +175,7 @@ pub fn udp_declaration_extern_ansi(s: Span) -> IResult { let (s, b) = udp_ansi_declaration(s)?; Ok(( s, - UdpDeclaration::ExternAnsi(UdpDeclarationExternAnsi { nodes: (a, b) }), + UdpDeclaration::ExternAnsi(Box::new(UdpDeclarationExternAnsi { nodes: (a, b) })), )) } @@ -192,8 +192,8 @@ pub fn udp_declaration_wildcard(s: Span) -> IResult { let (s, i) = opt(pair(symbol(":"), udp_identifier))(s)?; Ok(( s, - UdpDeclaration::Wildcard(UdpDeclarationWildcard { + UdpDeclaration::Wildcard(Box::new(UdpDeclarationWildcard { nodes: (a, b, c, d, e, f, g, h, i), - }), + })), )) } diff --git a/src/parser/udp_declaration_and_instantiation/udp_ports.rs b/src/parser/udp_declaration_and_instantiation/udp_ports.rs index 35ffa4a..0f7f4ba 100644 --- a/src/parser/udp_declaration_and_instantiation/udp_ports.rs +++ b/src/parser/udp_declaration_and_instantiation/udp_ports.rs @@ -28,15 +28,15 @@ pub struct UdpDeclarationPortList { #[derive(Clone, Debug, Node)] pub enum UdpPortDeclaration { - UdpOutputDeclaration((UdpOutputDeclaration, Symbol)), - UdpInputDeclaration((UdpInputDeclaration, Symbol)), - UdpRegDeclaration((UdpRegDeclaration, Symbol)), + UdpOutputDeclaration(Box<(UdpOutputDeclaration, Symbol)>), + UdpInputDeclaration(Box<(UdpInputDeclaration, Symbol)>), + UdpRegDeclaration(Box<(UdpRegDeclaration, Symbol)>), } #[derive(Clone, Debug, Node)] pub enum UdpOutputDeclaration { - Nonreg(UdpOutputDeclarationNonreg), - Reg(UdpOutputDeclarationReg), + Nonreg(Box), + Reg(Box), } #[derive(Clone, Debug, Node)] @@ -87,13 +87,13 @@ pub fn udp_declaration_port_list(s: Span) -> IResult IResult { alt(( map(pair(udp_output_declaration, symbol(";")), |x| { - UdpPortDeclaration::UdpOutputDeclaration(x) + UdpPortDeclaration::UdpOutputDeclaration(Box::new(x)) }), map(pair(udp_input_declaration, symbol(";")), |x| { - UdpPortDeclaration::UdpInputDeclaration(x) + UdpPortDeclaration::UdpInputDeclaration(Box::new(x)) }), map(pair(udp_reg_declaration, symbol(";")), |x| { - UdpPortDeclaration::UdpRegDeclaration(x) + UdpPortDeclaration::UdpRegDeclaration(Box::new(x)) }), ))(s) } @@ -110,7 +110,7 @@ pub fn udp_output_declaration_nonreg(s: Span) -> IResult IResult), + Comment(Box), } #[derive(Clone, Debug)] @@ -473,8 +473,8 @@ where #[parser] pub fn white_space(s: Span) -> IResult { alt(( - map(multispace1, |x: Span| WhiteSpace::Space(x.into())), - map(comment, |x| WhiteSpace::Comment(x)), + map(multispace1, |x: Span| WhiteSpace::Space(Box::new(x.into()))), + map(comment, |x| WhiteSpace::Comment(Box::new(x))), ))(s) }