From 0c58a10f362374e82d790ba76839be012c3dec6d Mon Sep 17 00:00:00 2001 From: dalance Date: Tue, 6 Aug 2019 00:37:12 +0900 Subject: [PATCH] Add test --- README.md | 16 +- .../assertion_statements.rs | 13 + .../behavioral_statements/case_statements.rs | 18 + .../behavioral_statements/clocking_block.rs | 31 + .../conditional_statements.rs | 5 + ...ous_assignment_and_net_alias_statements.rs | 7 + .../looping_statements.rs | 14 + .../parallel_and_sequential_blocks.rs | 5 + .../src/behavioral_statements/patterns.rs | 19 +- .../procedural_blocks_and_assignments.rs | 19 + .../src/behavioral_statements/randsequence.rs | 17 + .../src/behavioral_statements/statements.rs | 8 + .../subroutine_call_statements.rs | 2 + .../timing_control_statements.rs | 34 + .../declarations/assertion_declarations.rs | 99 + .../declarations/block_item_declarations.rs | 5 + .../declarations/covergroup_declarations.rs | 68 + .../declarations/declaration_assignments.rs | 20 + .../src/declarations/declaration_lists.rs | 13 + .../src/declarations/declaration_ranges.rs | 11 + sv-parser-parser/src/declarations/delays.rs | 7 + .../src/declarations/function_declarations.rs | 17 + .../declarations/interface_declarations.rs | 14 + .../src/declarations/let_declarations.rs | 11 + .../module_parameter_declarations.rs | 9 + .../declarations/net_and_variable_types.rs | 40 + .../src/declarations/port_declarations.rs | 9 + .../src/declarations/strengths.rs | 13 + .../src/declarations/task_declarations.rs | 12 + .../src/declarations/type_declarations.rs | 28 + .../src/expressions/concatenations.rs | 16 + .../expressions/expression_leftside_values.rs | 11 +- .../src/expressions/expressions.rs | 37 +- sv-parser-parser/src/expressions/numbers.rs | 28 +- sv-parser-parser/src/expressions/operators.rs | 6 +- sv-parser-parser/src/expressions/primaries.rs | 35 +- sv-parser-parser/src/expressions/strings.rs | 1 + .../src/expressions/subroutine_calls.rs | 22 +- sv-parser-parser/src/general/attributes.rs | 2 + sv-parser-parser/src/general/comments.rs | 3 + sv-parser-parser/src/general/identifiers.rs | 37 +- .../instantiations/checker_instantiation.rs | 8 + .../instantiations/generated_instantiation.rs | 16 + .../instantiations/interface_instantiation.rs | 1 + .../instantiations/module_instantiation.rs | 16 + .../instantiations/program_instantiation.rs | 1 + sv-parser-parser/src/lib.rs | 20 +- .../primitive_gate_and_switch_types.rs | 7 + .../primitive_instantiation_and_instances.rs | 18 + .../primitive_strengths.rs | 8 + .../primitive_terminals.rs | 6 + .../src/source_text/checker_items.rs | 10 + .../src/source_text/class_items.rs | 25 + .../source_text/configuration_source_text.rs | 18 + .../src/source_text/constraints.rs | 26 + .../src/source_text/interface_items.rs | 8 + .../src/source_text/library_source_text.rs | 6 + .../src/source_text/module_items.rs | 27 + .../module_parameters_and_ports.rs | 32 + .../src/source_text/package_items.rs | 4 + .../src/source_text/program_items.rs | 8 + .../source_text/system_verilog_source_text.rs | 42 + .../specify_block_declaration.rs | 4 + .../specify_block_terminals.rs | 6 + .../specify_path_declarations.rs | 8 + .../specify_section/specify_path_delays.rs | 17 + .../system_timing_check_command_arguments.rs | 16 + .../system_timing_check_commands.rs | 13 + .../system_timing_check_event_definitions.rs | 12 + sv-parser-parser/src/tests.rs | 5692 ++++++++++++++++- .../udp_body.rs | 17 + .../udp_declaration.rs | 8 + .../udp_instantiation.rs | 2 + .../udp_ports.rs | 8 + sv-parser-parser/src/utils.rs | 1 + 75 files changed, 6843 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 60bbdf9..a53904b 100644 --- a/README.md +++ b/README.md @@ -81,16 +81,16 @@ A parser library for System Verilog. | Clause | Exist | Pass | Clause | Exist | Pass | Clause | Exist | Pass | Clause | Exist | Pass | | ------ | ----- | ---- | ------ | ----- | ---- | ------ | ----- | ---- | ------ | ----- | ---- | -| 3 | x | x | 13 | | | 23 | | | 33 | | | -| 4 | x | x | 14 | | | 24 | | | 34 | | | -| 5 | x | x | 15 | | | 25 | | | 35 | | | -| 6 | x | | 16 | | | 26 | | | 36 | | | +| 3 | x | x | 13 | x | | 23 | | | 33 | | | +| 4 | x | x | 14 | x | | 24 | | | 34 | | | +| 5 | x | x | 15 | x | | 25 | | | 35 | | | +| 6 | x | | 16 | x | | 26 | | | 36 | | | | 7 | x | | 17 | | | 27 | | | 37 | | | | 8 | x | | 18 | | | 28 | | | 38 | | | -| 9 | | | 19 | | | 29 | | | 39 | | | -| 10 | | | 20 | | | 30 | | | 40 | | | -| 11 | | | 21 | | | 31 | | | | | | -| 12 | | | 22 | | | 32 | | | | | | +| 9 | x | | 19 | | | 29 | | | 39 | | | +| 10 | x | | 20 | | | 30 | | | 40 | | | +| 11 | x | | 21 | | | 31 | | | | | | +| 12 | x | | 22 | | | 32 | | | | | | ## Missing entry of specification diff --git a/sv-parser-parser/src/behavioral_statements/assertion_statements.rs b/sv-parser-parser/src/behavioral_statements/assertion_statements.rs index f8e19b5..3609a37 100644 --- a/sv-parser-parser/src/behavioral_statements/assertion_statements.rs +++ b/sv-parser-parser/src/behavioral_statements/assertion_statements.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn assertion_item(s: Span) -> IResult { alt(( map(concurrent_assertion_item, |x| { @@ -15,6 +16,7 @@ pub(crate) fn assertion_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn deferred_immediate_assertion_item( s: Span, ) -> IResult { @@ -24,6 +26,7 @@ pub(crate) fn deferred_immediate_assertion_item( } #[tracable_parser] +#[packrat_parser] pub(crate) fn procedural_assertion_statement( s: Span, ) -> IResult { @@ -41,6 +44,7 @@ pub(crate) fn procedural_assertion_statement( } #[tracable_parser] +#[packrat_parser] pub(crate) fn immediate_assertion_statement(s: Span) -> IResult { alt(( map(simple_immediate_assertion_statement, |x| { @@ -53,6 +57,7 @@ pub(crate) fn immediate_assertion_statement(s: Span) -> IResult IResult { @@ -70,6 +75,7 @@ pub(crate) fn simple_immediate_assertion_statement( } #[tracable_parser] +#[packrat_parser] pub(crate) fn simple_immediate_assert_statement( s: Span, ) -> IResult { @@ -80,6 +86,7 @@ pub(crate) fn simple_immediate_assert_statement( } #[tracable_parser] +#[packrat_parser] pub(crate) fn simple_immediate_assume_statement( s: Span, ) -> IResult { @@ -90,6 +97,7 @@ pub(crate) fn simple_immediate_assume_statement( } #[tracable_parser] +#[packrat_parser] pub(crate) fn simple_immediate_cover_statement( s: Span, ) -> IResult { @@ -100,6 +108,7 @@ pub(crate) fn simple_immediate_cover_statement( } #[tracable_parser] +#[packrat_parser] pub(crate) fn deferred_immediate_assertion_statement( s: Span, ) -> IResult { @@ -117,6 +126,7 @@ pub(crate) fn deferred_immediate_assertion_statement( } #[tracable_parser] +#[packrat_parser] pub(crate) fn deferred_immediate_assert_statement( s: Span, ) -> IResult { @@ -133,6 +143,7 @@ pub(crate) fn deferred_immediate_assert_statement( } #[tracable_parser] +#[packrat_parser] pub(crate) fn deferred_immediate_assume_statement( s: Span, ) -> IResult { @@ -149,6 +160,7 @@ pub(crate) fn deferred_immediate_assume_statement( } #[tracable_parser] +#[packrat_parser] pub(crate) fn deferred_immediate_cover_statement( s: Span, ) -> IResult { @@ -165,6 +177,7 @@ pub(crate) fn deferred_immediate_cover_statement( } #[tracable_parser] +#[packrat_parser] pub(crate) fn assert_timing(s: Span) -> IResult { alt(( map(symbol("#0"), |x| AssertTiming::Zero(Box::new(x))), diff --git a/sv-parser-parser/src/behavioral_statements/case_statements.rs b/sv-parser-parser/src/behavioral_statements/case_statements.rs index 84e0708..13e2ef2 100644 --- a/sv-parser-parser/src/behavioral_statements/case_statements.rs +++ b/sv-parser-parser/src/behavioral_statements/case_statements.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn case_statement(s: Span) -> IResult { alt(( case_statement_normal, @@ -12,6 +13,7 @@ pub(crate) fn case_statement(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn case_statement_normal(s: Span) -> IResult { let (s, a) = opt(unique_priority)(s)?; let (s, b) = case_keyword(s)?; @@ -28,6 +30,7 @@ pub(crate) fn case_statement_normal(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn case_statement_matches(s: Span) -> IResult { let (s, a) = opt(unique_priority)(s)?; let (s, b) = case_keyword(s)?; @@ -45,6 +48,7 @@ pub(crate) fn case_statement_matches(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn case_statement_inside(s: Span) -> IResult { let (s, a) = opt(unique_priority)(s)?; let (s, b) = keyword("case")(s)?; @@ -62,6 +66,7 @@ pub(crate) fn case_statement_inside(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn case_keyword(s: Span) -> IResult { alt(( map(keyword("casez"), |x| CaseKeyword::Casez(Box::new(x))), @@ -71,12 +76,14 @@ pub(crate) fn case_keyword(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn case_expression(s: Span) -> IResult { let (s, a) = expression(s)?; Ok((s, CaseExpression { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn case_item(s: Span) -> IResult { alt(( case_item_nondefault, @@ -86,6 +93,7 @@ pub(crate) fn case_item(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn case_item_nondefault(s: Span) -> IResult { let (s, a) = list(symbol(","), case_item_expression)(s)?; let (s, b) = symbol(":")(s)?; @@ -97,6 +105,7 @@ pub(crate) fn case_item_nondefault(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn case_item_default(s: Span) -> IResult { let (s, a) = keyword("default")(s)?; let (s, b) = opt(symbol(":"))(s)?; @@ -105,6 +114,7 @@ pub(crate) fn case_item_default(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn case_pattern_item(s: Span) -> IResult { alt(( case_pattern_item_nondefault, @@ -114,6 +124,7 @@ pub(crate) fn case_pattern_item(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn case_pattern_item_nondefault(s: Span) -> IResult { let (s, a) = pattern(s)?; let (s, b) = opt(pair(symbol("&&&"), expression))(s)?; @@ -128,6 +139,7 @@ pub(crate) fn case_pattern_item_nondefault(s: Span) -> IResult IResult { alt(( case_inside_item_nondefault, @@ -137,6 +149,7 @@ pub(crate) fn case_inside_item(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn case_inside_item_nondefault(s: Span) -> IResult { let (s, a) = open_range_list(s)?; let (s, b) = symbol(":")(s)?; @@ -148,12 +161,14 @@ pub(crate) fn case_inside_item_nondefault(s: Span) -> IResult IResult { let (s, a) = expression(s)?; Ok((s, CaseItemExpression { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn randcase_statement(s: Span) -> IResult { let (s, a) = keyword("randcase")(s)?; let (s, b) = randcase_item(s)?; @@ -169,6 +184,7 @@ pub(crate) fn randcase_statement(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn randcase_item(s: Span) -> IResult { let (s, a) = expression(s)?; let (s, b) = symbol(":")(s)?; @@ -178,12 +194,14 @@ pub(crate) fn randcase_item(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn open_range_list(s: Span) -> IResult { let (s, a) = list(symbol(","), open_value_range)(s)?; Ok((s, OpenRangeList { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn open_value_range(s: Span) -> IResult { let (s, a) = value_range(s)?; Ok((s, OpenValueRange { nodes: (a,) })) diff --git a/sv-parser-parser/src/behavioral_statements/clocking_block.rs b/sv-parser-parser/src/behavioral_statements/clocking_block.rs index 598449c..dc51a9d 100644 --- a/sv-parser-parser/src/behavioral_statements/clocking_block.rs +++ b/sv-parser-parser/src/behavioral_statements/clocking_block.rs @@ -3,11 +3,13 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_declaration(s: Span) -> IResult { alt((clocking_declaration_local, clocking_declaration_global))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_declaration_local(s: Span) -> IResult { let (s, a) = opt(default)(s)?; let (s, b) = keyword("clocking")(s)?; @@ -26,12 +28,14 @@ pub(crate) fn clocking_declaration_local(s: Span) -> IResult IResult { let (s, a) = keyword("default")(s)?; Ok((s, Default { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_declaration_global(s: Span) -> IResult { let (s, a) = keyword("global")(s)?; let (s, b) = keyword("clocking")(s)?; @@ -49,11 +53,13 @@ pub(crate) fn clocking_declaration_global(s: Span) -> IResult IResult { alt((clocking_event_identifier, clocking_event_expression))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_event_identifier(s: Span) -> IResult { let (s, a) = symbol("@")(s)?; let (s, b) = identifier(s)?; @@ -64,6 +70,7 @@ pub(crate) fn clocking_event_identifier(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_event_expression(s: Span) -> IResult { let (s, a) = symbol("@")(s)?; let (s, b) = paren(event_expression)(s)?; @@ -74,6 +81,7 @@ pub(crate) fn clocking_event_expression(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_item(s: Span) -> IResult { alt(( clocking_item_default, @@ -83,6 +91,7 @@ pub(crate) fn clocking_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_item_default(s: Span) -> IResult { let (s, a) = keyword("default")(s)?; let (s, b) = default_skew(s)?; @@ -94,6 +103,7 @@ pub(crate) fn clocking_item_default(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_item_direction(s: Span) -> IResult { let (s, a) = clocking_direction(s)?; let (s, b) = list_of_clocking_decl_assign(s)?; @@ -105,6 +115,7 @@ pub(crate) fn clocking_item_direction(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_item_assertion(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = assertion_item_declaration(s)?; @@ -115,6 +126,7 @@ pub(crate) fn clocking_item_assertion(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn default_skew(s: Span) -> IResult { alt(( default_skew_input, @@ -124,6 +136,7 @@ pub(crate) fn default_skew(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn default_skew_input(s: Span) -> IResult { let (s, a) = keyword("input")(s)?; let (s, b) = clocking_skew(s)?; @@ -134,6 +147,7 @@ pub(crate) fn default_skew_input(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn default_skew_output(s: Span) -> IResult { let (s, a) = keyword("output")(s)?; let (s, b) = clocking_skew(s)?; @@ -144,6 +158,7 @@ pub(crate) fn default_skew_output(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn default_skew_input_output(s: Span) -> IResult { let (s, a) = keyword("input")(s)?; let (s, b) = clocking_skew(s)?; @@ -158,6 +173,7 @@ pub(crate) fn default_skew_input_output(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_direction(s: Span) -> IResult { alt(( clocking_direction_input, @@ -168,6 +184,7 @@ pub(crate) fn clocking_direction(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_direction_input(s: Span) -> IResult { let (s, a) = keyword("input")(s)?; let (s, b) = opt(clocking_skew)(s)?; @@ -178,6 +195,7 @@ pub(crate) fn clocking_direction_input(s: Span) -> IResult IResult { let (s, a) = keyword("output")(s)?; let (s, b) = opt(clocking_skew)(s)?; @@ -188,6 +206,7 @@ pub(crate) fn clocking_direction_output(s: Span) -> IResult IResult { let (s, a) = keyword("input")(s)?; let (s, b) = opt(clocking_skew)(s)?; @@ -202,18 +221,21 @@ pub(crate) fn clocking_direction_input_output(s: Span) -> IResult IResult { let (s, a) = keyword("inout")(s)?; Ok((s, ClockingDirection::Inout(Box::new(a)))) } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_clocking_decl_assign(s: Span) -> IResult { let (s, a) = list(symbol(","), clocking_decl_assign)(s)?; Ok((s, ListOfClockingDeclAssign { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_decl_assign(s: Span) -> IResult { let (s, a) = signal_identifier(s)?; let (s, b) = opt(pair(symbol("="), expression))(s)?; @@ -221,6 +243,7 @@ pub(crate) fn clocking_decl_assign(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_skew(s: Span) -> IResult { alt(( clocking_skew_edge, @@ -229,6 +252,7 @@ pub(crate) fn clocking_skew(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_skew_edge(s: Span) -> IResult { let (s, a) = edge_identifier(s)?; let (s, b) = opt(delay_control)(s)?; @@ -239,6 +263,7 @@ pub(crate) fn clocking_skew_edge(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn clocking_drive(s: Span) -> IResult { let (s, a) = clockvar_expression(s)?; let (s, b) = symbol("<=")(s)?; @@ -253,6 +278,7 @@ pub(crate) fn clocking_drive(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn cycle_delay(s: Span) -> IResult { alt(( cycle_delay_integral, @@ -262,6 +288,7 @@ pub(crate) fn cycle_delay(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn cycle_delay_integral(s: Span) -> IResult { let (s, a) = symbol("##")(s)?; let (s, b) = integral_number(s)?; @@ -272,6 +299,7 @@ pub(crate) fn cycle_delay_integral(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn cycle_delay_identifier(s: Span) -> IResult { let (s, a) = symbol("##")(s)?; let (s, b) = identifier(s)?; @@ -282,6 +310,7 @@ pub(crate) fn cycle_delay_identifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn cycle_delay_expression(s: Span) -> IResult { let (s, a) = symbol("##")(s)?; let (s, b) = paren(expression)(s)?; @@ -292,12 +321,14 @@ pub(crate) fn cycle_delay_expression(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn clockvar(s: Span) -> IResult { let (s, a) = hierarchical_identifier(s)?; Ok((s, Clockvar { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn clockvar_expression(s: Span) -> IResult { let (s, a) = clockvar(s)?; let (s, b) = select(s)?; diff --git a/sv-parser-parser/src/behavioral_statements/conditional_statements.rs b/sv-parser-parser/src/behavioral_statements/conditional_statements.rs index ba693fa..ff3ed14 100644 --- a/sv-parser-parser/src/behavioral_statements/conditional_statements.rs +++ b/sv-parser-parser/src/behavioral_statements/conditional_statements.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn conditional_statement(s: Span) -> IResult { let (s, a) = opt(unique_priority)(s)?; let (s, b) = keyword("if")(s)?; @@ -25,6 +26,7 @@ pub(crate) fn conditional_statement(s: Span) -> IResult IResult { alt(( map(keyword("unique0"), |x| UniquePriority::Unique0(Box::new(x))), @@ -37,12 +39,14 @@ pub(crate) fn unique_priority(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn cond_predicate(s: Span) -> IResult { let (s, a) = list(symbol("&&&"), expression_or_cond_pattern)(s)?; Ok((s, CondPredicate { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn expression_or_cond_pattern(s: Span) -> IResult { alt(( map(expression, |x| { @@ -56,6 +60,7 @@ pub(crate) fn expression_or_cond_pattern(s: Span) -> IResult IResult { let (s, a) = expression(s)?; let (s, b) = keyword("matches")(s)?; diff --git a/sv-parser-parser/src/behavioral_statements/continuous_assignment_and_net_alias_statements.rs b/sv-parser-parser/src/behavioral_statements/continuous_assignment_and_net_alias_statements.rs index e218524..2444aaa 100644 --- a/sv-parser-parser/src/behavioral_statements/continuous_assignment_and_net_alias_statements.rs +++ b/sv-parser-parser/src/behavioral_statements/continuous_assignment_and_net_alias_statements.rs @@ -3,11 +3,13 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn continuous_assign(s: Span) -> IResult { alt((continuous_assign_net, continuous_assign_variable))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn continuous_assign_net(s: Span) -> IResult { let (s, a) = keyword("assign")(s)?; let (s, b) = opt(drive_strength)(s)?; @@ -24,6 +26,7 @@ pub(crate) fn continuous_assign_net(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn continuous_assign_variable(s: Span) -> IResult { let (s, a) = keyword("assign")(s)?; let (s, b) = opt(delay_control)(s)?; @@ -40,6 +43,7 @@ pub(crate) fn continuous_assign_variable(s: Span) -> IResult IResult { let (s, a) = list(symbol(","), net_assignment)(s)?; Ok((s, ListOfNetAssignments { nodes: (a,) })) @@ -47,12 +51,14 @@ pub(crate) fn list_of_net_assignments(s: Span) -> IResult IResult { let (s, a) = list(symbol(","), variable_assignment)(s)?; Ok((s, ListOfVariableAssignments { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_alias(s: Span) -> IResult { let (s, a) = keyword("alias")(s)?; let (s, b) = net_lvalue(s)?; @@ -70,6 +76,7 @@ pub(crate) fn net_alias(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn net_assignment(s: Span) -> IResult { let (s, a) = net_lvalue(s)?; let (s, b) = symbol("=")(s)?; diff --git a/sv-parser-parser/src/behavioral_statements/looping_statements.rs b/sv-parser-parser/src/behavioral_statements/looping_statements.rs index c2e7e91..c4906e2 100644 --- a/sv-parser-parser/src/behavioral_statements/looping_statements.rs +++ b/sv-parser-parser/src/behavioral_statements/looping_statements.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn loop_statement(s: Span) -> IResult { alt(( loop_statement_forever, @@ -15,6 +16,7 @@ pub(crate) fn loop_statement(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn loop_statement_forever(s: Span) -> IResult { let (s, a) = keyword("forever")(s)?; let (s, b) = statement_or_null(s)?; @@ -25,6 +27,7 @@ pub(crate) fn loop_statement_forever(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn loop_statement_repeat(s: Span) -> IResult { let (s, a) = keyword("repeat")(s)?; let (s, b) = paren(expression)(s)?; @@ -36,6 +39,7 @@ pub(crate) fn loop_statement_repeat(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn loop_statement_while(s: Span) -> IResult { let (s, a) = keyword("while")(s)?; let (s, b) = paren(expression)(s)?; @@ -47,6 +51,7 @@ pub(crate) fn loop_statement_while(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn loop_statement_for(s: Span) -> IResult { let (s, a) = keyword("for")(s)?; let (s, b) = paren(tuple(( @@ -64,6 +69,7 @@ pub(crate) fn loop_statement_for(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn loop_statement_do_while(s: Span) -> IResult { let (s, a) = keyword("do")(s)?; let (s, b) = statement_or_null(s)?; @@ -79,6 +85,7 @@ pub(crate) fn loop_statement_do_while(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn loop_statement_foreach(s: Span) -> IResult { let (s, a) = keyword("foreach")(s)?; let (s, b) = paren(pair( @@ -93,6 +100,7 @@ pub(crate) fn loop_statement_foreach(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn for_initialization(s: Span) -> IResult { alt(( map(list_of_variable_assignments, |x| { @@ -104,6 +112,7 @@ pub(crate) fn for_initialization(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn for_initialization_declaration(s: Span) -> IResult { let (s, a) = list(symbol(","), for_variable_declaration)(s)?; Ok(( @@ -113,6 +122,7 @@ pub(crate) fn for_initialization_declaration(s: Span) -> IResult IResult { let (s, a) = opt(var)(s)?; let (s, b) = data_type(s)?; @@ -124,6 +134,7 @@ pub(crate) fn for_variable_declaration(s: Span) -> IResult IResult { let (s, a) = keyword("var")(s)?; Ok((s, Var { nodes: (a,) })) @@ -131,12 +142,14 @@ pub(crate) fn var(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn for_step(s: Span) -> IResult { let (s, a) = list(symbol(","), for_step_assignment)(s)?; Ok((s, ForStep { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn for_step_assignment(s: Span) -> IResult { alt(( map(operator_assignment, |x| { @@ -152,6 +165,7 @@ pub(crate) fn for_step_assignment(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn loop_variables(s: Span) -> IResult { let (s, a) = list(symbol(","), opt(index_variable_identifier))(s)?; Ok((s, LoopVariables { nodes: (a,) })) diff --git a/sv-parser-parser/src/behavioral_statements/parallel_and_sequential_blocks.rs b/sv-parser-parser/src/behavioral_statements/parallel_and_sequential_blocks.rs index 5ef6ba9..b398fe4 100644 --- a/sv-parser-parser/src/behavioral_statements/parallel_and_sequential_blocks.rs +++ b/sv-parser-parser/src/behavioral_statements/parallel_and_sequential_blocks.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn action_block(s: Span) -> IResult { alt(( map(statement_or_null, |x| { @@ -13,6 +14,7 @@ pub(crate) fn action_block(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn action_block_else(s: Span) -> IResult { let (s, a) = opt(statement)(s)?; let (s, b) = keyword("else")(s)?; @@ -24,6 +26,7 @@ pub(crate) fn action_block_else(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn seq_block(s: Span) -> IResult { let (s, a) = keyword("begin")(s)?; let (s, b) = opt(pair(symbol(":"), block_identifier))(s)?; @@ -40,6 +43,7 @@ pub(crate) fn seq_block(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn par_block(s: Span) -> IResult { let (s, a) = keyword("fork")(s)?; let (s, b) = opt(pair(symbol(":"), block_identifier))(s)?; @@ -56,6 +60,7 @@ pub(crate) fn par_block(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn join_keyword(s: Span) -> IResult { alt(( map(keyword("join_any"), |x| JoinKeyword::JoinAny(Box::new(x))), diff --git a/sv-parser-parser/src/behavioral_statements/patterns.rs b/sv-parser-parser/src/behavioral_statements/patterns.rs index 374ba05..c367a8f 100644 --- a/sv-parser-parser/src/behavioral_statements/patterns.rs +++ b/sv-parser-parser/src/behavioral_statements/patterns.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn pattern(s: Span) -> IResult { alt(( pattern_variable, @@ -17,6 +18,7 @@ pub(crate) fn pattern(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn pattern_variable(s: Span) -> IResult { let (s, a) = symbol(".")(s)?; let (s, b) = variable_identifier(s)?; @@ -27,6 +29,7 @@ pub(crate) fn pattern_variable(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn pattern_tagged(s: Span) -> IResult { let (s, a) = keyword("tagged")(s)?; let (s, b) = member_identifier(s)?; @@ -38,12 +41,14 @@ pub(crate) fn pattern_tagged(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn pattern_list(s: Span) -> IResult { let (s, a) = apostrophe_brace(list(symbol(","), pattern))(s)?; Ok((s, Pattern::List(Box::new(PatternList { nodes: (a,) })))) } #[tracable_parser] +#[packrat_parser] pub(crate) fn pattern_identifier_list(s: Span) -> IResult { let (s, a) = apostrophe_brace(list( symbol(","), @@ -56,6 +61,7 @@ pub(crate) fn pattern_identifier_list(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn assignment_pattern(s: Span) -> IResult { alt(( assignment_pattern_list, @@ -66,6 +72,7 @@ pub(crate) fn assignment_pattern(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn assignment_pattern_list(s: Span) -> IResult { let (s, a) = apostrophe_brace(list(symbol(","), expression))(s)?; Ok(( @@ -75,6 +82,7 @@ pub(crate) fn assignment_pattern_list(s: Span) -> IResult IResult { let (s, a) = apostrophe_brace(list( symbol(","), @@ -87,6 +95,7 @@ pub(crate) fn assignment_pattern_structure(s: Span) -> IResult IResult { let (s, a) = apostrophe_brace(list( symbol(","), @@ -99,6 +108,7 @@ pub(crate) fn assignment_pattern_array(s: Span) -> IResult IResult { let (s, a) = apostrophe_brace(pair( constant_expression, @@ -111,6 +121,7 @@ pub(crate) fn assignment_pattern_repeat(s: Span) -> IResult IResult { alt(( map(member_identifier, |x| { @@ -123,6 +134,7 @@ pub(crate) fn structure_pattern_key(s: Span) -> IResult IResult { alt(( map(constant_expression, |x| { @@ -135,6 +147,7 @@ pub(crate) fn array_pattern_key(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn assignment_pattern_key(s: Span) -> IResult { alt(( map(simple_type, |x| { @@ -146,8 +159,8 @@ pub(crate) fn assignment_pattern_key(s: Span) -> IResult IResult { let (s, a) = opt(assignment_pattern_expression_type)(s)?; let (s, b) = assignment_pattern(s)?; @@ -155,6 +168,7 @@ pub(crate) fn assignment_pattern_expression(s: Span) -> IResult IResult { @@ -175,6 +189,7 @@ pub(crate) fn assignment_pattern_expression_type( } #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_assignment_pattern_expression( s: Span, ) -> IResult { @@ -183,12 +198,14 @@ pub(crate) fn constant_assignment_pattern_expression( } #[tracable_parser] +#[packrat_parser] pub(crate) fn assignment_pattern_net_lvalue(s: Span) -> IResult { let (s, a) = apostrophe_brace(list(symbol(","), net_lvalue))(s)?; Ok((s, AssignmentPatternNetLvalue { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn assignment_pattern_variable_lvalue( s: Span, ) -> IResult { diff --git a/sv-parser-parser/src/behavioral_statements/procedural_blocks_and_assignments.rs b/sv-parser-parser/src/behavioral_statements/procedural_blocks_and_assignments.rs index 8b9ed2d..1e0f766 100644 --- a/sv-parser-parser/src/behavioral_statements/procedural_blocks_and_assignments.rs +++ b/sv-parser-parser/src/behavioral_statements/procedural_blocks_and_assignments.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn initial_construct(s: Span) -> IResult { let (s, a) = keyword("initial")(s)?; let (s, b) = statement_or_null(s)?; @@ -10,6 +11,7 @@ pub(crate) fn initial_construct(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn always_construct(s: Span) -> IResult { let (s, a) = always_keyword(s)?; let (s, b) = statement(s)?; @@ -17,6 +19,7 @@ pub(crate) fn always_construct(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn always_keyword(s: Span) -> IResult { alt(( map(keyword("always_comb"), |x| { @@ -33,6 +36,7 @@ pub(crate) fn always_keyword(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn final_construct(s: Span) -> IResult { let (s, a) = keyword("final")(s)?; let (s, b) = function_statement(s)?; @@ -40,6 +44,7 @@ pub(crate) fn final_construct(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn blocking_assignment(s: Span) -> IResult { alt(( blocking_assignment_variable, @@ -53,6 +58,7 @@ pub(crate) fn blocking_assignment(s: Span) -> IResult #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn blocking_assignment_variable(s: Span) -> IResult { let (s, a) = variable_lvalue(s)?; let (s, b) = symbol("=")(s)?; @@ -68,6 +74,7 @@ pub(crate) fn blocking_assignment_variable(s: Span) -> IResult IResult { let (s, a) = nonrange_variable_lvalue(s)?; let (s, b) = symbol("=")(s)?; @@ -81,6 +88,7 @@ pub(crate) fn blocking_assignment_nonrange_variable(s: Span) -> IResult IResult { @@ -101,6 +109,7 @@ pub(crate) fn blocking_assignment_hierarchical_variable( #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn operator_assignment(s: Span) -> IResult { let (s, a) = variable_lvalue(s)?; let (s, b) = assignment_operator(s)?; @@ -109,6 +118,7 @@ pub(crate) fn operator_assignment(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn assignment_operator(s: Span) -> IResult { alt(( map(symbol("="), |x| AssignmentOperator { nodes: (x,) }), @@ -129,6 +139,7 @@ pub(crate) fn assignment_operator(s: Span) -> IResult #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn nonblocking_assignment(s: Span) -> IResult { let (s, a) = variable_lvalue(s)?; let (s, b) = symbol("<=")(s)?; @@ -143,6 +154,7 @@ pub(crate) fn nonblocking_assignment(s: Span) -> IResult IResult { @@ -157,6 +169,7 @@ pub(crate) fn procedural_continuous_assignment( } #[tracable_parser] +#[packrat_parser] pub(crate) fn procedural_continuous_assignment_assign( s: Span, ) -> IResult { @@ -171,6 +184,7 @@ pub(crate) fn procedural_continuous_assignment_assign( } #[tracable_parser] +#[packrat_parser] pub(crate) fn procedural_continuous_assignment_deassign( s: Span, ) -> IResult { @@ -185,6 +199,7 @@ pub(crate) fn procedural_continuous_assignment_deassign( } #[tracable_parser] +#[packrat_parser] pub(crate) fn procedural_continuous_assignment_force_variable( s: Span, ) -> IResult { @@ -199,6 +214,7 @@ pub(crate) fn procedural_continuous_assignment_force_variable( } #[tracable_parser] +#[packrat_parser] pub(crate) fn procedural_continuous_assignment_force_net( s: Span, ) -> IResult { @@ -213,6 +229,7 @@ pub(crate) fn procedural_continuous_assignment_force_net( } #[tracable_parser] +#[packrat_parser] pub(crate) fn procedural_continuous_assignment_release_variable( s: Span, ) -> IResult { @@ -227,6 +244,7 @@ pub(crate) fn procedural_continuous_assignment_release_variable( } #[tracable_parser] +#[packrat_parser] pub(crate) fn procedural_continuous_assignment_release_net( s: Span, ) -> IResult { @@ -242,6 +260,7 @@ pub(crate) fn procedural_continuous_assignment_release_net( #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn variable_assignment(s: Span) -> IResult { let (s, a) = variable_lvalue(s)?; let (s, b) = symbol("=")(s)?; diff --git a/sv-parser-parser/src/behavioral_statements/randsequence.rs b/sv-parser-parser/src/behavioral_statements/randsequence.rs index b7ebcdb..1bc79f8 100644 --- a/sv-parser-parser/src/behavioral_statements/randsequence.rs +++ b/sv-parser-parser/src/behavioral_statements/randsequence.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn randsequence_statement(s: Span) -> IResult { let (s, a) = keyword("randsequence")(s)?; let (s, b) = paren(opt(production_identifier))(s)?; @@ -18,6 +19,7 @@ pub(crate) fn randsequence_statement(s: Span) -> IResult IResult { let (s, a) = opt(data_type_or_void)(s)?; let (s, b) = production_identifier(s)?; @@ -34,6 +36,7 @@ pub(crate) fn production(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn rs_rule(s: Span) -> IResult { let (s, a) = rs_production_list(s)?; let (s, b) = opt(triple( @@ -45,11 +48,13 @@ pub(crate) fn rs_rule(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn rs_production_list(s: Span) -> IResult { alt((rs_production_list_prod, rs_production_list_join))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn rs_production_list_prod(s: Span) -> IResult { let (s, a) = rs_prod(s)?; let (s, b) = many0(rs_prod)(s)?; @@ -60,6 +65,7 @@ pub(crate) fn rs_production_list_prod(s: Span) -> IResult IResult { let (s, a) = keyword("rand")(s)?; let (s, b) = keyword("join")(s)?; @@ -76,6 +82,7 @@ pub(crate) fn rs_production_list_join(s: Span) -> IResult IResult { alt(( map(integral_number, |x| { @@ -89,6 +96,7 @@ pub(crate) fn weight_specification(s: Span) -> IResult IResult { let (s, a) = paren(expression)(s)?; Ok(( @@ -98,12 +106,14 @@ pub(crate) fn weight_specification_expression(s: Span) -> IResult IResult { let (s, a) = brace(pair(many0(data_declaration), many0(statement_or_null)))(s)?; Ok((s, RsCodeBlock { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn rs_prod(s: Span) -> IResult { alt(( map(production_item, |x| RsProd::ProductionItem(Box::new(x))), @@ -115,6 +125,7 @@ pub(crate) fn rs_prod(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn production_item(s: Span) -> IResult { let (s, a) = production_identifier(s)?; let (s, b) = opt(paren(list_of_arguments))(s)?; @@ -122,6 +133,7 @@ pub(crate) fn production_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn rs_if_else(s: Span) -> IResult { let (s, a) = keyword("if")(s)?; let (s, b) = paren(expression)(s)?; @@ -136,6 +148,7 @@ pub(crate) fn rs_if_else(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn rs_repeat(s: Span) -> IResult { let (s, a) = keyword("repeat")(s)?; let (s, b) = paren(expression)(s)?; @@ -144,6 +157,7 @@ pub(crate) fn rs_repeat(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn rs_case(s: Span) -> IResult { let (s, a) = keyword("case")(s)?; let (s, b) = paren(case_expression)(s)?; @@ -159,12 +173,14 @@ pub(crate) fn rs_case(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn rs_case_item(s: Span) -> IResult { alt((rs_case_item_nondefault, rs_case_item_default))(s) } #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn rs_case_item_nondefault(s: Span) -> IResult { let (s, a) = list(symbol(","), case_item_expression)(s)?; let (s, b) = symbol(":")(s)?; @@ -179,6 +195,7 @@ pub(crate) fn rs_case_item_nondefault(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn rs_case_item_default(s: Span) -> IResult { let (s, a) = keyword("default")(s)?; let (s, b) = opt(symbol(":"))(s)?; diff --git a/sv-parser-parser/src/behavioral_statements/statements.rs b/sv-parser-parser/src/behavioral_statements/statements.rs index 34e188d..c417bad 100644 --- a/sv-parser-parser/src/behavioral_statements/statements.rs +++ b/sv-parser-parser/src/behavioral_statements/statements.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn statement_or_null(s: Span) -> IResult { alt(( map(statement, |x| StatementOrNull::Statement(Box::new(x))), @@ -11,6 +12,7 @@ pub(crate) fn statement_or_null(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn statement_or_null_attribute(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = symbol(";")(s)?; @@ -22,6 +24,7 @@ pub(crate) fn statement_or_null_attribute(s: Span) -> IResult IResult { let (s, a) = opt(pair(block_identifier, symbol(":")))(s)?; let (s, b) = many0(attribute_instance)(s)?; @@ -30,6 +33,7 @@ pub(crate) fn statement(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn statement_item(s: Span) -> IResult { alt(( map(pair(blocking_assignment, symbol(";")), |x| { @@ -90,12 +94,14 @@ pub(crate) fn statement_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn function_statement(s: Span) -> IResult { let (s, a) = statement(s)?; Ok((s, FunctionStatement { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn function_statement_or_null(s: Span) -> IResult { alt(( map(function_statement, |x| { @@ -106,6 +112,7 @@ pub(crate) fn function_statement_or_null(s: Span) -> IResult IResult { @@ -120,6 +127,7 @@ pub(crate) fn function_statement_or_null_attribute( } #[tracable_parser] +#[packrat_parser] pub(crate) fn variable_identifier_list(s: Span) -> IResult { let (s, a) = list(symbol(","), variable_identifier)(s)?; Ok((s, VariableIdentifierList { nodes: (a,) })) diff --git a/sv-parser-parser/src/behavioral_statements/subroutine_call_statements.rs b/sv-parser-parser/src/behavioral_statements/subroutine_call_statements.rs index 0f13bfb..880f538 100644 --- a/sv-parser-parser/src/behavioral_statements/subroutine_call_statements.rs +++ b/sv-parser-parser/src/behavioral_statements/subroutine_call_statements.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn subroutine_call_statement(s: Span) -> IResult { alt(( map(pair(subroutine_call, symbol(";")), |x| { @@ -13,6 +14,7 @@ pub(crate) fn subroutine_call_statement(s: Span) -> IResult IResult { diff --git a/sv-parser-parser/src/behavioral_statements/timing_control_statements.rs b/sv-parser-parser/src/behavioral_statements/timing_control_statements.rs index 4a5ac35..ce9bdcd 100644 --- a/sv-parser-parser/src/behavioral_statements/timing_control_statements.rs +++ b/sv-parser-parser/src/behavioral_statements/timing_control_statements.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn procedural_timing_control_statement( s: Span, ) -> IResult { @@ -12,6 +13,7 @@ pub(crate) fn procedural_timing_control_statement( } #[tracable_parser] +#[packrat_parser] pub(crate) fn delay_or_event_control(s: Span) -> IResult { alt(( map(delay_control, |x| DelayOrEventControl::Delay(Box::new(x))), @@ -21,6 +23,7 @@ pub(crate) fn delay_or_event_control(s: Span) -> IResult IResult { let (s, a) = keyword("repeat")(s)?; let (s, b) = paren(expression)(s)?; @@ -32,11 +35,13 @@ pub(crate) fn delay_or_event_control_repeat(s: Span) -> IResult IResult { alt((delay_control_delay, delay_control_mintypmax))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn delay_control_delay(s: Span) -> IResult { let (s, a) = symbol("#")(s)?; let (s, b) = delay_value(s)?; @@ -47,6 +52,7 @@ pub(crate) fn delay_control_delay(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn delay_control_mintypmax(s: Span) -> IResult { let (s, a) = symbol("#")(s)?; let (s, b) = paren(mintypmax_expression)(s)?; @@ -57,6 +63,7 @@ pub(crate) fn delay_control_mintypmax(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn event_control(s: Span) -> IResult { alt(( event_control_event_identifier, @@ -68,6 +75,7 @@ pub(crate) fn event_control(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn event_control_event_identifier(s: Span) -> IResult { let (s, a) = symbol("@")(s)?; let (s, b) = hierarchical_event_identifier(s)?; @@ -78,6 +86,7 @@ pub(crate) fn event_control_event_identifier(s: Span) -> IResult IResult { let (s, a) = symbol("@")(s)?; let (s, b) = paren(event_expression)(s)?; @@ -88,6 +97,7 @@ pub(crate) fn event_control_event_expression(s: Span) -> IResult IResult { let (s, a) = symbol("@*")(s)?; Ok(( @@ -97,6 +107,7 @@ pub(crate) fn event_control_asterisk(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn event_control_paren_asterisk(s: Span) -> IResult { let (s, a) = symbol("@")(s)?; let (s, b) = paren(symbol("*"))(s)?; @@ -107,6 +118,7 @@ pub(crate) fn event_control_paren_asterisk(s: Span) -> IResult IResult { let (s, a) = symbol("@")(s)?; let (s, b) = ps_or_hierarchical_sequence_identifier(s)?; @@ -119,6 +131,7 @@ pub(crate) fn event_control_sequence_identifier(s: Span) -> IResult IResult { alt(( event_expression_or, @@ -131,6 +144,7 @@ pub(crate) fn event_expression(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn event_expression_expression(s: Span) -> IResult { let (s, a) = opt(edge_identifier)(s)?; let (s, b) = expression(s)?; @@ -142,6 +156,7 @@ pub(crate) fn event_expression_expression(s: Span) -> IResult IResult { let (s, a) = sequence_instance(s)?; let (s, b) = opt(pair(keyword("iff"), expression))(s)?; @@ -153,6 +168,7 @@ pub(crate) fn event_expression_sequence(s: Span) -> IResult IResult { let (s, a) = event_expression(s)?; let (s, b) = keyword("or")(s)?; @@ -165,6 +181,7 @@ pub(crate) fn event_expression_or(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn event_expression_comma(s: Span) -> IResult { let (s, a) = event_expression(s)?; let (s, b) = symbol(",")(s)?; @@ -176,6 +193,7 @@ pub(crate) fn event_expression_comma(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn event_expression_paren(s: Span) -> IResult { let (s, a) = paren(event_expression)(s)?; Ok(( @@ -185,6 +203,7 @@ pub(crate) fn event_expression_paren(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn procedural_timing_control(s: Span) -> IResult { alt(( map(delay_control, |x| { @@ -200,6 +219,7 @@ pub(crate) fn procedural_timing_control(s: Span) -> IResult IResult { alt(( jump_statement_return, @@ -209,6 +229,7 @@ pub(crate) fn jump_statement(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn jump_statement_return(s: Span) -> IResult { let (s, a) = keyword("return")(s)?; let (s, b) = opt(expression)(s)?; @@ -220,6 +241,7 @@ pub(crate) fn jump_statement_return(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn jump_statement_break(s: Span) -> IResult { let (s, a) = keyword("break")(s)?; let (s, b) = symbol(";")(s)?; @@ -230,6 +252,7 @@ pub(crate) fn jump_statement_break(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn jump_statement_continue(s: Span) -> IResult { let (s, a) = keyword("continue")(s)?; let (s, b) = symbol(";")(s)?; @@ -240,6 +263,7 @@ pub(crate) fn jump_statement_continue(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn wait_statement(s: Span) -> IResult { alt(( wait_statement_wait, @@ -249,6 +273,7 @@ pub(crate) fn wait_statement(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn wait_statement_wait(s: Span) -> IResult { let (s, a) = keyword("wait")(s)?; let (s, b) = paren(expression)(s)?; @@ -260,6 +285,7 @@ pub(crate) fn wait_statement_wait(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn wait_statement_fork(s: Span) -> IResult { let (s, a) = keyword("wait")(s)?; let (s, b) = keyword("fork")(s)?; @@ -271,6 +297,7 @@ pub(crate) fn wait_statement_fork(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn wait_statement_order(s: Span) -> IResult { let (s, a) = keyword("wait_order")(s)?; let (s, b) = paren(list(symbol(","), hierarchical_identifier))(s)?; @@ -282,11 +309,13 @@ pub(crate) fn wait_statement_order(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn event_trigger(s: Span) -> IResult { alt((event_trigger_named, event_trigger_nonblocking))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn event_trigger_named(s: Span) -> IResult { let (s, a) = symbol("->")(s)?; let (s, b) = hierarchical_event_identifier(s)?; @@ -298,6 +327,7 @@ pub(crate) fn event_trigger_named(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn event_trigger_nonblocking(s: Span) -> IResult { let (s, a) = symbol("->>")(s)?; let (s, b) = opt(delay_or_event_control)(s)?; @@ -312,6 +342,7 @@ pub(crate) fn event_trigger_nonblocking(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn disable_statement(s: Span) -> IResult { alt(( disable_statement_task, @@ -321,6 +352,7 @@ pub(crate) fn disable_statement(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn disable_statement_task(s: Span) -> IResult { let (s, a) = keyword("disable")(s)?; let (s, b) = hierarchical_task_identifier(s)?; @@ -332,6 +364,7 @@ pub(crate) fn disable_statement_task(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn disable_statement_block(s: Span) -> IResult { let (s, a) = keyword("disable")(s)?; let (s, b) = hierarchical_block_identifier(s)?; @@ -343,6 +376,7 @@ pub(crate) fn disable_statement_block(s: Span) -> IResult IResult { let (s, a) = keyword("disable")(s)?; let (s, b) = keyword("fork")(s)?; diff --git a/sv-parser-parser/src/declarations/assertion_declarations.rs b/sv-parser-parser/src/declarations/assertion_declarations.rs index 1f29432..cec4be3 100644 --- a/sv-parser-parser/src/declarations/assertion_declarations.rs +++ b/sv-parser-parser/src/declarations/assertion_declarations.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn concurrent_assertion_item(s: Span) -> IResult { alt(( concurrent_assertion_item_statement, @@ -13,6 +14,7 @@ pub(crate) fn concurrent_assertion_item(s: Span) -> IResult IResult { @@ -27,6 +29,7 @@ pub(crate) fn concurrent_assertion_item_statement( } #[tracable_parser] +#[packrat_parser] pub(crate) fn concurrent_assertion_statement( s: Span, ) -> IResult { @@ -50,6 +53,7 @@ pub(crate) fn concurrent_assertion_statement( } #[tracable_parser] +#[packrat_parser] pub(crate) fn assert_property_statement(s: Span) -> IResult { let (s, a) = keyword("assert")(s)?; let (s, b) = keyword("property")(s)?; @@ -64,6 +68,7 @@ pub(crate) fn assert_property_statement(s: Span) -> IResult IResult { let (s, a) = keyword("assume")(s)?; let (s, b) = keyword("property")(s)?; @@ -78,6 +83,7 @@ pub(crate) fn assume_property_statement(s: Span) -> IResult IResult { let (s, a) = keyword("cover")(s)?; let (s, b) = keyword("property")(s)?; @@ -92,6 +98,7 @@ pub(crate) fn cover_property_statement(s: Span) -> IResult IResult { let (s, a) = keyword("expect")(s)?; let (s, b) = paren(property_spec)(s)?; @@ -100,6 +107,7 @@ pub(crate) fn expect_property_statement(s: Span) -> IResult IResult { let (s, a) = keyword("cover")(s)?; let (s, b) = keyword("sequence")(s)?; @@ -122,6 +130,7 @@ pub(crate) fn cover_sequence_statement(s: Span) -> IResult IResult { let (s, a) = keyword("restrict")(s)?; let (s, b) = keyword("property")(s)?; @@ -136,6 +145,7 @@ pub(crate) fn restrict_property_statement(s: Span) -> IResult IResult { let (s, a) = ps_or_hierarchical_property_identifier(s)?; let (s, b) = opt(paren(opt(property_list_of_arguments)))(s)?; @@ -143,6 +153,7 @@ pub(crate) fn property_instance(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_list_of_arguments(s: Span) -> IResult { alt(( property_list_of_arguments_named, @@ -152,6 +163,7 @@ pub(crate) fn property_list_of_arguments(s: Span) -> IResult IResult { @@ -171,6 +183,7 @@ pub(crate) fn property_list_of_arguments_ordered( } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_list_of_arguments_named(s: Span) -> IResult { let (s, a) = list( symbol(","), @@ -183,6 +196,7 @@ pub(crate) fn property_list_of_arguments_named(s: Span) -> IResult IResult { alt(( map(property_expr, |x| { @@ -195,6 +209,7 @@ pub(crate) fn property_actual_arg(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn assertion_item_declaration(s: Span) -> IResult { alt(( map(property_declaration, |x| { @@ -210,6 +225,7 @@ pub(crate) fn assertion_item_declaration(s: Span) -> IResult IResult { let (s, a) = keyword("property")(s)?; let (s, b) = property_identifier(s)?; @@ -229,12 +245,14 @@ pub(crate) fn property_declaration(s: Span) -> IResult IResult { let (s, a) = list(symbol(","), property_port_item)(s)?; Ok((s, PropertyPortList { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_port_item(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = opt(pair(local, opt(property_lvar_port_direction)))(s)?; @@ -251,12 +269,14 @@ pub(crate) fn property_port_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_lvar_port_direction(s: Span) -> IResult { let (s, a) = keyword("input")(s)?; Ok((s, PropertyLvarPortDirection::Input(Box::new(a)))) } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_formal_type(s: Span) -> IResult { alt(( map(sequence_formal_type, |x| { @@ -270,6 +290,7 @@ pub(crate) fn property_formal_type(s: Span) -> IResult #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn property_spec(s: Span) -> IResult { let (s, a) = opt(clocking_event)(s)?; let (s, b) = opt(triple( @@ -282,6 +303,7 @@ pub(crate) fn property_spec(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr(s: Span) -> IResult { alt(( alt(( @@ -325,6 +347,7 @@ pub(crate) fn property_expr(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_strong(s: Span) -> IResult { let (s, a) = keyword("strong")(s)?; let (s, b) = paren(sequence_expr)(s)?; @@ -335,6 +358,7 @@ pub(crate) fn property_expr_strong(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_weak(s: Span) -> IResult { let (s, a) = keyword("weak")(s)?; let (s, b) = paren(sequence_expr)(s)?; @@ -345,6 +369,7 @@ pub(crate) fn property_expr_weak(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_paren(s: Span) -> IResult { let (s, a) = paren(sequence_expr)(s)?; Ok(( @@ -354,6 +379,7 @@ pub(crate) fn property_expr_paren(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_not(s: Span) -> IResult { let (s, a) = keyword("not")(s)?; let (s, b) = property_expr(s)?; @@ -365,6 +391,7 @@ pub(crate) fn property_expr_not(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_or(s: Span) -> IResult { let (s, a) = property_expr(s)?; let (s, b) = keyword("or")(s)?; @@ -377,6 +404,7 @@ pub(crate) fn property_expr_or(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_and(s: Span) -> IResult { let (s, a) = property_expr(s)?; let (s, b) = keyword("and")(s)?; @@ -389,6 +417,7 @@ pub(crate) fn property_expr_and(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_implication_overlapped(s: Span) -> IResult { let (s, a) = sequence_expr(s)?; let (s, b) = symbol("|->")(s)?; @@ -403,6 +432,7 @@ pub(crate) fn property_expr_implication_overlapped(s: Span) -> IResult IResult { let (s, a) = sequence_expr(s)?; let (s, b) = symbol("|=>")(s)?; @@ -416,6 +446,7 @@ pub(crate) fn property_expr_implication_nonoverlapped(s: Span) -> IResult IResult { let (s, a) = keyword("if")(s)?; let (s, b) = paren(expression_or_dist)(s)?; @@ -430,6 +461,7 @@ pub(crate) fn property_expr_if(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_case(s: Span) -> IResult { let (s, a) = keyword("case")(s)?; let (s, b) = paren(expression_or_dist)(s)?; @@ -446,6 +478,7 @@ pub(crate) fn property_expr_case(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_followed_by_overlapped(s: Span) -> IResult { let (s, a) = sequence_expr(s)?; let (s, b) = symbol("#-#")(s)?; @@ -460,6 +493,7 @@ pub(crate) fn property_expr_followed_by_overlapped(s: Span) -> IResult IResult { let (s, a) = sequence_expr(s)?; let (s, b) = symbol("#=#")(s)?; @@ -473,6 +507,7 @@ pub(crate) fn property_expr_followed_by_nonoverlapped(s: Span) -> IResult IResult { let (s, a) = keyword("nexttime")(s)?; let (s, b) = opt(bracket(constant_expression))(s)?; @@ -484,6 +519,7 @@ pub(crate) fn property_expr_nexttime(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_s_nexttime(s: Span) -> IResult { let (s, a) = keyword("s_nexttime")(s)?; let (s, b) = opt(bracket(constant_expression))(s)?; @@ -495,6 +531,7 @@ pub(crate) fn property_expr_s_nexttime(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_always(s: Span) -> IResult { let (s, a) = keyword("always")(s)?; let (s, b) = opt(bracket(cycle_delay_const_range_expression))(s)?; @@ -506,6 +543,7 @@ pub(crate) fn property_expr_always(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_s_always(s: Span) -> IResult { let (s, a) = keyword("s_always")(s)?; let (s, b) = bracket(cycle_delay_const_range_expression)(s)?; @@ -517,6 +555,7 @@ pub(crate) fn property_expr_s_always(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_eventually(s: Span) -> IResult { let (s, a) = keyword("eventually")(s)?; let (s, b) = bracket(constant_range)(s)?; @@ -528,6 +567,7 @@ pub(crate) fn property_expr_eventually(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_s_eventually(s: Span) -> IResult { let (s, a) = keyword("s_eventually")(s)?; let (s, b) = opt(bracket(cycle_delay_const_range_expression))(s)?; @@ -540,6 +580,7 @@ pub(crate) fn property_expr_s_eventually(s: Span) -> IResult #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_until(s: Span) -> IResult { let (s, a) = property_expr(s)?; let (s, b) = keyword("until")(s)?; @@ -552,6 +593,7 @@ pub(crate) fn property_expr_until(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_s_until(s: Span) -> IResult { let (s, a) = property_expr(s)?; let (s, b) = keyword("s_until")(s)?; @@ -564,6 +606,7 @@ pub(crate) fn property_expr_s_until(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_until_with(s: Span) -> IResult { let (s, a) = property_expr(s)?; let (s, b) = keyword("until_with")(s)?; @@ -576,6 +619,7 @@ pub(crate) fn property_expr_until_with(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_s_until_with(s: Span) -> IResult { let (s, a) = property_expr(s)?; let (s, b) = keyword("s_until_with")(s)?; @@ -588,6 +632,7 @@ pub(crate) fn property_expr_s_until_with(s: Span) -> IResult #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_implies(s: Span) -> IResult { let (s, a) = property_expr(s)?; let (s, b) = keyword("implies")(s)?; @@ -600,6 +645,7 @@ pub(crate) fn property_expr_implies(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_iff(s: Span) -> IResult { let (s, a) = property_expr(s)?; let (s, b) = keyword("iff")(s)?; @@ -611,6 +657,7 @@ pub(crate) fn property_expr_iff(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_accept_on(s: Span) -> IResult { let (s, a) = keyword("accept_on")(s)?; let (s, b) = paren(expression_or_dist)(s)?; @@ -622,6 +669,7 @@ pub(crate) fn property_expr_accept_on(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_reject_on(s: Span) -> IResult { let (s, a) = keyword("reject_on")(s)?; let (s, b) = paren(expression_or_dist)(s)?; @@ -633,6 +681,7 @@ pub(crate) fn property_expr_reject_on(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_expr_sync_accept_on(s: Span) -> IResult { let (s, a) = keyword("sync_accept_on")(s)?; let (s, b) = paren(expression_or_dist)(s)?; @@ -644,6 +693,7 @@ pub(crate) fn property_expr_sync_accept_on(s: Span) -> IResult IResult { let (s, a) = keyword("sync_reject_on")(s)?; let (s, b) = paren(expression_or_dist)(s)?; @@ -655,6 +705,7 @@ pub(crate) fn property_expr_sync_reject_on(s: Span) -> IResult IResult { let (s, a) = clocking_event(s)?; let (s, b) = property_expr(s)?; @@ -665,12 +716,14 @@ pub(crate) fn property_expr_clocking_event(s: Span) -> IResult IResult { alt((property_case_item_nondefault, property_case_item_default))(s) } #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn property_case_item_nondefault(s: Span) -> IResult { let (s, a) = list(symbol(","), expression_or_dist)(s)?; let (s, b) = symbol(":")(s)?; @@ -685,6 +738,7 @@ pub(crate) fn property_case_item_nondefault(s: Span) -> IResult IResult { let (s, a) = keyword("default")(s)?; let (s, b) = opt(symbol(":"))(s)?; @@ -699,6 +753,7 @@ pub(crate) fn property_case_item_default(s: Span) -> IResult IResult { let (s, a) = keyword("sequence")(s)?; let (s, b) = sequence_identifier(s)?; @@ -718,12 +773,14 @@ pub(crate) fn sequence_declaration(s: Span) -> IResult IResult { let (s, a) = list(symbol(","), sequence_port_item)(s)?; Ok((s, SequencePortList { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_port_item(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = opt(pair(local, opt(sequence_lvar_port_direction)))(s)?; @@ -740,6 +797,7 @@ pub(crate) fn sequence_port_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_lvar_port_direction(s: Span) -> IResult { alt(( map(keyword("input"), |x| { @@ -755,6 +813,7 @@ pub(crate) fn sequence_lvar_port_direction(s: Span) -> IResult IResult { alt(( map(data_type_or_implicit_sequence_formal_type, |x| { @@ -770,6 +829,7 @@ pub(crate) fn sequence_formal_type(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_or_implicit_sequence_formal_type( s: Span, ) -> IResult { @@ -785,6 +845,7 @@ pub(crate) fn data_type_or_implicit_sequence_formal_type( } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_expr(s: Span) -> IResult { alt(( sequence_expr_cycle_delay_expr, @@ -803,6 +864,7 @@ pub(crate) fn sequence_expr(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_expr_cycle_delay_expr(s: Span) -> IResult { let (s, a) = cycle_delay_range(s)?; let (s, b) = sequence_expr(s)?; @@ -815,6 +877,7 @@ pub(crate) fn sequence_expr_cycle_delay_expr(s: Span) -> IResult IResult { let (s, a) = sequence_expr(s)?; let (s, b) = cycle_delay_range(s)?; @@ -830,6 +893,7 @@ pub(crate) fn sequence_expr_expr_cycle_delay_expr(s: Span) -> IResult IResult { let (s, a) = expression_or_dist(s)?; let (s, b) = opt(boolean_abbrev)(s)?; @@ -840,6 +904,7 @@ pub(crate) fn sequence_expr_expression(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_expr_instance(s: Span) -> IResult { let (s, a) = sequence_instance(s)?; let (s, b) = opt(sequence_abbrev)(s)?; @@ -850,6 +915,7 @@ pub(crate) fn sequence_expr_instance(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_expr_paren(s: Span) -> IResult { let (s, a) = paren(pair( sequence_expr, @@ -864,6 +930,7 @@ pub(crate) fn sequence_expr_paren(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_expr_and(s: Span) -> IResult { let (s, a) = sequence_expr(s)?; let (s, b) = keyword("and")(s)?; @@ -876,6 +943,7 @@ pub(crate) fn sequence_expr_and(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_expr_intersect(s: Span) -> IResult { let (s, a) = sequence_expr(s)?; let (s, b) = keyword("intersect")(s)?; @@ -888,6 +956,7 @@ pub(crate) fn sequence_expr_intersect(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_expr_or(s: Span) -> IResult { let (s, a) = sequence_expr(s)?; let (s, b) = keyword("or")(s)?; @@ -899,6 +968,7 @@ pub(crate) fn sequence_expr_or(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_expr_first_match(s: Span) -> IResult { let (s, a) = keyword("first_match")(s)?; let (s, b) = paren(pair( @@ -913,6 +983,7 @@ pub(crate) fn sequence_expr_first_match(s: Span) -> IResult #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_expr_throughout(s: Span) -> IResult { let (s, a) = expression_or_dist(s)?; let (s, b) = keyword("throughout")(s)?; @@ -925,6 +996,7 @@ pub(crate) fn sequence_expr_throughout(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_expr_within(s: Span) -> IResult { let (s, a) = sequence_expr(s)?; let (s, b) = keyword("within")(s)?; @@ -936,6 +1008,7 @@ pub(crate) fn sequence_expr_within(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_expr_clocking_event(s: Span) -> IResult { let (s, a) = clocking_event(s)?; let (s, b) = sequence_expr(s)?; @@ -946,6 +1019,7 @@ pub(crate) fn sequence_expr_clocking_event(s: Span) -> IResult IResult { alt(( cycle_delay_range_primary, @@ -956,6 +1030,7 @@ pub(crate) fn cycle_delay_range(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn cycle_delay_range_primary(s: Span) -> IResult { let (s, a) = symbol("##")(s)?; let (s, b) = constant_primary(s)?; @@ -966,6 +1041,7 @@ pub(crate) fn cycle_delay_range_primary(s: Span) -> IResult IResult { let (s, a) = symbol("##")(s)?; let (s, b) = bracket(cycle_delay_const_range_expression)(s)?; @@ -976,6 +1052,7 @@ pub(crate) fn cycle_delay_range_expression(s: Span) -> IResult IResult { let (s, a) = symbol("##")(s)?; let (s, b) = bracket(symbol("*"))(s)?; @@ -986,6 +1063,7 @@ pub(crate) fn cycle_delay_range_asterisk(s: Span) -> IResult IResult { let (s, a) = symbol("##")(s)?; let (s, b) = bracket(symbol("+"))(s)?; @@ -996,6 +1074,7 @@ pub(crate) fn cycle_delay_range_plus(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_method_call(s: Span) -> IResult { let (s, a) = sequence_instance(s)?; let (s, b) = symbol(".")(s)?; @@ -1004,6 +1083,7 @@ pub(crate) fn sequence_method_call(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_match_item(s: Span) -> IResult { alt(( map(operator_assignment, |x| { @@ -1019,6 +1099,7 @@ pub(crate) fn sequence_match_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_instance(s: Span) -> IResult { let (s, a) = ps_or_hierarchical_sequence_identifier(s)?; let (s, b) = opt(paren(opt(sequence_list_of_arguments)))(s)?; @@ -1026,6 +1107,7 @@ pub(crate) fn sequence_instance(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_list_of_arguments(s: Span) -> IResult { alt(( sequence_list_of_arguments_named, @@ -1035,6 +1117,7 @@ pub(crate) fn sequence_list_of_arguments(s: Span) -> IResult IResult { @@ -1054,6 +1137,7 @@ pub(crate) fn sequence_list_of_arguments_ordered( } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_list_of_arguments_named(s: Span) -> IResult { let (s, a) = list( symbol(","), @@ -1066,6 +1150,7 @@ pub(crate) fn sequence_list_of_arguments_named(s: Span) -> IResult IResult { alt(( map(event_expression, |x| { @@ -1078,6 +1163,7 @@ pub(crate) fn sequence_actual_arg(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn boolean_abbrev(s: Span) -> IResult { alt(( map(consecutive_repetition, |x| { @@ -1093,12 +1179,14 @@ pub(crate) fn boolean_abbrev(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequence_abbrev(s: Span) -> IResult { let (s, a) = consecutive_repetition(s)?; Ok((s, SequenceAbbrev { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn consecutive_repetition(s: Span) -> IResult { alt(( consecutive_repetition_expression, @@ -1108,6 +1196,7 @@ pub(crate) fn consecutive_repetition(s: Span) -> IResult IResult { let (s, a) = bracket(pair(symbol("*"), const_or_range_expression))(s)?; Ok(( @@ -1119,6 +1208,7 @@ pub(crate) fn consecutive_repetition_expression(s: Span) -> IResult IResult { let (s, a) = bracket(symbol("*"))(s)?; Ok(( @@ -1128,6 +1218,7 @@ pub(crate) fn consecutive_repetition_asterisk(s: Span) -> IResult IResult { let (s, a) = bracket(symbol("+"))(s)?; Ok(( @@ -1137,18 +1228,21 @@ pub(crate) fn consecutive_repetition_plus(s: Span) -> IResult IResult { let (s, a) = bracket(pair(symbol("="), const_or_range_expression))(s)?; Ok((s, NonConsecutiveRepetition { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn goto_repetition(s: Span) -> IResult { let (s, a) = bracket(pair(symbol("->"), const_or_range_expression))(s)?; Ok((s, GotoRepetition { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn const_or_range_expression(s: Span) -> IResult { alt(( map(cycle_delay_const_range_expression, |x| { @@ -1161,6 +1255,7 @@ pub(crate) fn const_or_range_expression(s: Span) -> IResult IResult { @@ -1172,6 +1267,7 @@ pub(crate) fn cycle_delay_const_range_expression( #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn cycle_delay_const_range_expression_binary( s: Span, ) -> IResult { @@ -1188,6 +1284,7 @@ pub(crate) fn cycle_delay_const_range_expression_binary( #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn cycle_delay_const_range_expression_dollar( s: Span, ) -> IResult { @@ -1204,6 +1301,7 @@ pub(crate) fn cycle_delay_const_range_expression_dollar( #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn expression_or_dist(s: Span) -> IResult { let (s, a) = expression(s)?; let (s, b) = opt(pair(keyword("dist"), brace(dist_list)))(s)?; @@ -1211,6 +1309,7 @@ pub(crate) fn expression_or_dist(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn assertion_variable_declaration( s: Span, ) -> IResult { diff --git a/sv-parser-parser/src/declarations/block_item_declarations.rs b/sv-parser-parser/src/declarations/block_item_declarations.rs index 80a51f8..abd88b6 100644 --- a/sv-parser-parser/src/declarations/block_item_declarations.rs +++ b/sv-parser-parser/src/declarations/block_item_declarations.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn block_item_declaration(s: Span) -> IResult { alt(( block_item_declaration_data, @@ -14,6 +15,7 @@ pub(crate) fn block_item_declaration(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = data_declaration(s)?; @@ -24,6 +26,7 @@ pub(crate) fn block_item_declaration_data(s: Span) -> IResult IResult { @@ -39,6 +42,7 @@ pub(crate) fn block_item_declaration_local_parameter( } #[tracable_parser] +#[packrat_parser] pub(crate) fn block_item_declaration_parameter(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = parameter_declaration(s)?; @@ -52,6 +56,7 @@ pub(crate) fn block_item_declaration_parameter(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = let_declaration(s)?; diff --git a/sv-parser-parser/src/declarations/covergroup_declarations.rs b/sv-parser-parser/src/declarations/covergroup_declarations.rs index 06a8b33..a0a2c0d 100644 --- a/sv-parser-parser/src/declarations/covergroup_declarations.rs +++ b/sv-parser-parser/src/declarations/covergroup_declarations.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn covergroup_declaration(s: Span) -> IResult { let (s, a) = keyword("covergroup")(s)?; let (s, b) = covergroup_identifier(s)?; @@ -21,11 +22,13 @@ pub(crate) fn covergroup_declaration(s: Span) -> IResult IResult { alt((coverage_spec_or_option_spec, coverage_spec_or_option_option))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn coverage_spec_or_option_spec(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = coverage_spec(s)?; @@ -36,6 +39,7 @@ pub(crate) fn coverage_spec_or_option_spec(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = coverage_option(s)?; @@ -47,11 +51,13 @@ pub(crate) fn coverage_spec_or_option_option(s: Span) -> IResult IResult { alt((coverage_option_option, coverage_option_type_option))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn coverage_option_option(s: Span) -> IResult { let (s, a) = keyword("option")(s)?; let (s, b) = symbol(".")(s)?; @@ -67,6 +73,7 @@ pub(crate) fn coverage_option_option(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn coverage_option_type_option(s: Span) -> IResult { let (s, a) = keyword("type_option")(s)?; let (s, b) = symbol(".")(s)?; @@ -82,6 +89,7 @@ pub(crate) fn coverage_option_type_option(s: Span) -> IResult IResult { alt(( map(cover_point, |x| CoverageSpec::CoverPoint(Box::new(x))), @@ -90,6 +98,7 @@ pub(crate) fn coverage_spec(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn coverage_event(s: Span) -> IResult { alt(( map(clocking_event, |x| { @@ -101,6 +110,7 @@ pub(crate) fn coverage_event(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn coverage_event_sample(s: Span) -> IResult { let (s, a) = keyword("with")(s)?; let (s, b) = keyword("function")(s)?; @@ -115,6 +125,7 @@ pub(crate) fn coverage_event_sample(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn coverage_event_at(s: Span) -> IResult { let (s, a) = symbol("@@")(s)?; let (s, b) = paren(block_event_expression)(s)?; @@ -125,6 +136,7 @@ pub(crate) fn coverage_event_at(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn block_event_expression(s: Span) -> IResult { alt(( block_event_expression_or, @@ -135,6 +147,7 @@ pub(crate) fn block_event_expression(s: Span) -> IResult IResult { let (s, a) = block_event_expression(s)?; let (s, b) = keyword("or")(s)?; @@ -146,6 +159,7 @@ pub(crate) fn block_event_expression_or(s: Span) -> IResult IResult { let (s, a) = keyword("begin")(s)?; let (s, b) = hierarchical_btf_identifier(s)?; @@ -156,6 +170,7 @@ pub(crate) fn block_event_expression_begin(s: Span) -> IResult IResult { let (s, a) = keyword("end")(s)?; let (s, b) = hierarchical_btf_identifier(s)?; @@ -166,6 +181,7 @@ pub(crate) fn block_event_expression_end(s: Span) -> IResult IResult { alt(( map(hierarchical_tf_identifier, |x| { @@ -179,6 +195,7 @@ pub(crate) fn hierarchical_btf_identifier(s: Span) -> IResult IResult { @@ -193,6 +210,7 @@ pub(crate) fn hierarchical_btf_identifier_method( } #[tracable_parser] +#[packrat_parser] pub(crate) fn hierarchical_identifier_or_class_scope( s: Span, ) -> IResult { @@ -207,6 +225,7 @@ pub(crate) fn hierarchical_identifier_or_class_scope( } #[tracable_parser] +#[packrat_parser] pub(crate) fn cover_point(s: Span) -> IResult { let (s, a) = opt(triple( opt(data_type_or_implicit_cover_point), @@ -226,6 +245,7 @@ pub(crate) fn cover_point(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_or_implicit_cover_point(s: Span) -> IResult { alt(( map(terminated(data_type, peek(cover_point_identifier)), |x| { @@ -239,6 +259,7 @@ pub(crate) fn data_type_or_implicit_cover_point(s: Span) -> IResult IResult { alt(( bins_or_empty_non_empty, @@ -247,6 +268,7 @@ pub(crate) fn bins_or_empty(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn bins_or_empty_non_empty(s: Span) -> IResult { let (s, a) = brace(pair( many0(attribute_instance), @@ -259,6 +281,7 @@ pub(crate) fn bins_or_empty_non_empty(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn bins_or_options(s: Span) -> IResult { alt(( map(coverage_option, |x| { @@ -274,6 +297,7 @@ pub(crate) fn bins_or_options(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn bins_or_options_covergroup(s: Span) -> IResult { let (s, a) = opt(wildcard)(s)?; let (s, b) = bins_keyword(s)?; @@ -292,12 +316,14 @@ pub(crate) fn bins_or_options_covergroup(s: Span) -> IResult IResult { let (s, a) = keyword("wildcard")(s)?; Ok((s, Wildcard { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn bins_or_options_cover_point(s: Span) -> IResult { let (s, a) = opt(wildcard)(s)?; let (s, b) = bins_keyword(s)?; @@ -317,6 +343,7 @@ pub(crate) fn bins_or_options_cover_point(s: Span) -> IResult IResult { let (s, a) = opt(wildcard)(s)?; let (s, b) = bins_keyword(s)?; @@ -334,6 +361,7 @@ pub(crate) fn bins_or_options_set_covergroup(s: Span) -> IResult IResult { let (s, a) = opt(wildcard)(s)?; let (s, b) = bins_keyword(s)?; @@ -351,6 +379,7 @@ pub(crate) fn bins_or_options_trans_list(s: Span) -> IResult IResult { let (s, a) = bins_keyword(s)?; let (s, b) = bin_identifier(s)?; @@ -367,6 +396,7 @@ pub(crate) fn bins_or_options_default(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn bins_or_options_default_sequence(s: Span) -> IResult { let (s, a) = bins_keyword(s)?; let (s, b) = bin_identifier(s)?; @@ -383,6 +413,7 @@ pub(crate) fn bins_or_options_default_sequence(s: Span) -> IResult IResult { alt(( map(keyword("bins"), |x| BinsKeyword::Bins(Box::new(x))), @@ -396,6 +427,7 @@ pub(crate) fn bins_keyword(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn trans_list(s: Span) -> IResult { let (s, a) = list(symbol(","), paren(trans_set))(s)?; Ok((s, TransList { nodes: (a,) })) @@ -403,12 +435,14 @@ pub(crate) fn trans_list(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn trans_set(s: Span) -> IResult { let (s, a) = list(symbol("=>"), trans_range_list)(s)?; Ok((s, TransSet { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn trans_range_list(s: Span) -> IResult { alt(( map(trans_item, |x| TransRangeList::TransItem(Box::new(x))), @@ -420,6 +454,7 @@ pub(crate) fn trans_range_list(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn trans_range_list_asterisk(s: Span) -> IResult { let (s, a) = trans_item(s)?; let (s, b) = bracket(pair(symbol("*"), repeat_range))(s)?; @@ -431,6 +466,7 @@ pub(crate) fn trans_range_list_asterisk(s: Span) -> IResult IResult { let (s, a) = trans_item(s)?; let (s, b) = bracket(pair(symbol("->"), repeat_range))(s)?; @@ -442,6 +478,7 @@ pub(crate) fn trans_range_list_arrow(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn trans_range_list_equal(s: Span) -> IResult { let (s, a) = trans_item(s)?; let (s, b) = bracket(pair(symbol("="), repeat_range))(s)?; @@ -452,12 +489,14 @@ pub(crate) fn trans_range_list_equal(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn trans_item(s: Span) -> IResult { let (s, a) = covergroup_range_list(s)?; Ok((s, TransItem { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn repeat_range(s: Span) -> IResult { alt(( map(covergroup_expression, |x| { @@ -469,6 +508,7 @@ pub(crate) fn repeat_range(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn repeat_range_binary(s: Span) -> IResult { let (s, a) = covergroup_expression(s)?; let (s, b) = symbol(":")(s)?; @@ -480,6 +520,7 @@ pub(crate) fn repeat_range_binary(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn cover_cross(s: Span) -> IResult { let (s, a) = opt(pair(cross_identifier, symbol(":")))(s)?; let (s, b) = keyword("cross")(s)?; @@ -495,6 +536,7 @@ pub(crate) fn cover_cross(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_cross_items(s: Span) -> IResult { let (s, a) = cross_item(s)?; let (s, b) = list(symbol(","), cross_item)(s)?; @@ -502,6 +544,7 @@ pub(crate) fn list_of_cross_items(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn cross_item(s: Span) -> IResult { alt(( map(cover_point_identifier, |x| { @@ -514,6 +557,7 @@ pub(crate) fn cross_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn cross_body(s: Span) -> IResult { alt(( cross_body_non_empty, @@ -522,6 +566,7 @@ pub(crate) fn cross_body(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn cross_body_non_empty(s: Span) -> IResult { let (s, a) = brace(many0(pair(cross_body_item, symbol(";"))))(s)?; Ok(( @@ -531,6 +576,7 @@ pub(crate) fn cross_body_non_empty(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn cross_body_item(s: Span) -> IResult { alt(( map(function_declaration, |x| { @@ -543,6 +589,7 @@ pub(crate) fn cross_body_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn bins_selection_or_option(s: Span) -> IResult { alt(( bins_selection_or_option_coverage, @@ -551,6 +598,7 @@ pub(crate) fn bins_selection_or_option(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = coverage_option(s)?; @@ -561,6 +609,7 @@ pub(crate) fn bins_selection_or_option_coverage(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = bins_selection(s)?; @@ -571,6 +620,7 @@ pub(crate) fn bins_selection_or_option_bins(s: Span) -> IResult IResult { let (s, a) = bins_keyword(s)?; let (s, b) = bin_identifier(s)?; @@ -586,6 +636,7 @@ pub(crate) fn bins_selection(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn select_expression(s: Span) -> IResult { alt(( map(select_condition, |x| { @@ -604,6 +655,7 @@ pub(crate) fn select_expression(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn select_expression_not(s: Span) -> IResult { let (s, a) = symbol("!")(s)?; let (s, b) = select_condition(s)?; @@ -615,6 +667,7 @@ pub(crate) fn select_expression_not(s: Span) -> IResult #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn select_expression_and(s: Span) -> IResult { let (s, a) = select_expression(s)?; let (s, b) = symbol("&&")(s)?; @@ -627,6 +680,7 @@ pub(crate) fn select_expression_and(s: Span) -> IResult #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn select_expression_or(s: Span) -> IResult { let (s, a) = select_expression(s)?; let (s, b) = symbol("||")(s)?; @@ -638,6 +692,7 @@ pub(crate) fn select_expression_or(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn select_expression_paren(s: Span) -> IResult { let (s, a) = paren(select_expression)(s)?; Ok(( @@ -648,6 +703,7 @@ pub(crate) fn select_expression_paren(s: Span) -> IResult IResult { let (s, a) = select_expression(s)?; let (s, b) = keyword("with")(s)?; @@ -663,6 +719,7 @@ pub(crate) fn select_expression_with(s: Span) -> IResult #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn select_expression_cross_set(s: Span) -> IResult { let (s, a) = cross_set_expression(s)?; let (s, b) = opt(pair(keyword("matches"), integer_covergroup_expression))(s)?; @@ -673,6 +730,7 @@ pub(crate) fn select_expression_cross_set(s: Span) -> IResult IResult { let (s, a) = keyword("binsof")(s)?; let (s, b) = paren(bins_expression)(s)?; @@ -681,6 +739,7 @@ pub(crate) fn select_condition(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn bins_expression(s: Span) -> IResult { alt(( map(variable_identifier, |x| { @@ -691,6 +750,7 @@ pub(crate) fn bins_expression(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn bins_expression_cover_point(s: Span) -> IResult { let (s, a) = cover_point_identifier(s)?; let (s, b) = opt(pair(symbol("."), bin_identifier))(s)?; @@ -702,12 +762,14 @@ pub(crate) fn bins_expression_cover_point(s: Span) -> IResult IResult { let (s, a) = list(symbol(","), covergroup_value_range)(s)?; Ok((s, CovergroupRangeList { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn covergroup_value_range(s: Span) -> IResult { alt(( map(covergroup_expression, |x| { @@ -718,6 +780,7 @@ pub(crate) fn covergroup_value_range(s: Span) -> IResult IResult { let (s, a) = bracket(triple( covergroup_expression, @@ -731,30 +794,35 @@ pub(crate) fn covergroup_value_range_binary(s: Span) -> IResult IResult { let (s, a) = covergroup_expression(s)?; Ok((s, WithCovergroupExpression { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn set_covergroup_expression(s: Span) -> IResult { let (s, a) = covergroup_expression(s)?; Ok((s, SetCovergroupExpression { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn integer_covergroup_expression(s: Span) -> IResult { let (s, a) = covergroup_expression(s)?; Ok((s, IntegerCovergroupExpression { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn cross_set_expression(s: Span) -> IResult { let (s, a) = covergroup_expression(s)?; Ok((s, CrossSetExpression { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn covergroup_expression(s: Span) -> IResult { let (s, a) = expression(s)?; Ok((s, CovergroupExpression { nodes: (a,) })) diff --git a/sv-parser-parser/src/declarations/declaration_assignments.rs b/sv-parser-parser/src/declarations/declaration_assignments.rs index 8f91fbf..abcb95d 100644 --- a/sv-parser-parser/src/declarations/declaration_assignments.rs +++ b/sv-parser-parser/src/declarations/declaration_assignments.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn defparam_assignment(s: Span) -> IResult { let (s, a) = hierarchical_parameter_identifier(s)?; let (s, b) = symbol("=")(s)?; @@ -11,6 +12,7 @@ pub(crate) fn defparam_assignment(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_decl_assignment(s: Span) -> IResult { let (s, a) = net_identifier(s)?; let (s, b) = many0(unpacked_dimension)(s)?; @@ -19,6 +21,7 @@ pub(crate) fn net_decl_assignment(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn param_assignment(s: Span) -> IResult { let (s, a) = parameter_identifier(s)?; let (s, b) = many0(unpacked_dimension)(s)?; @@ -27,6 +30,7 @@ pub(crate) fn param_assignment(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn specparam_assignment(s: Span) -> IResult { alt(( specparam_assignment_mintypmax, @@ -37,6 +41,7 @@ pub(crate) fn specparam_assignment(s: Span) -> IResult IResult { let (s, a) = specparam_identifier(s)?; let (s, b) = symbol("=")(s)?; @@ -48,6 +53,7 @@ pub(crate) fn specparam_assignment_mintypmax(s: Span) -> IResult IResult { let (s, a) = type_identifier(s)?; let (s, b) = opt(pair(symbol("="), data_type))(s)?; @@ -55,6 +61,7 @@ pub(crate) fn type_assignment(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn pulse_control_specparam(s: Span) -> IResult { alt(( pulse_control_specparam_without_descriptor, @@ -63,6 +70,7 @@ pub(crate) fn pulse_control_specparam(s: Span) -> IResult IResult { @@ -81,6 +89,7 @@ pub(crate) fn pulse_control_specparam_without_descriptor( } #[tracable_parser] +#[packrat_parser] pub(crate) fn pulse_control_specparam_with_descriptor( s: Span, ) -> IResult { @@ -102,24 +111,28 @@ pub(crate) fn pulse_control_specparam_with_descriptor( } #[tracable_parser] +#[packrat_parser] pub(crate) fn error_limit_value(s: Span) -> IResult { let (s, a) = limit_value(s)?; Ok((s, ErrorLimitValue { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn reject_limit_value(s: Span) -> IResult { let (s, a) = limit_value(s)?; Ok((s, RejectLimitValue { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn limit_value(s: Span) -> IResult { let (s, a) = constant_mintypmax_expression(s)?; Ok((s, LimitValue { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn variable_decl_assignment(s: Span) -> IResult { alt(( variable_decl_assignment_dynamic_array, @@ -129,6 +142,7 @@ pub(crate) fn variable_decl_assignment(s: Span) -> IResult IResult { let (s, a) = variable_identifier(s)?; let (s, b) = many0(variable_dimension)(s)?; @@ -142,6 +156,7 @@ pub(crate) fn variable_decl_assignment_variable(s: Span) -> IResult IResult { @@ -158,6 +173,7 @@ pub(crate) fn variable_decl_assignment_dynamic_array( } #[tracable_parser] +#[packrat_parser] pub(crate) fn variable_decl_assignment_class(s: Span) -> IResult { let (s, a) = class_variable_identifier(s)?; let (s, b) = pair(symbol("="), class_new)(s)?; @@ -168,11 +184,13 @@ pub(crate) fn variable_decl_assignment_class(s: Span) -> IResult IResult { alt((class_new_expression, class_new_argument))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_new_argument(s: Span) -> IResult { let (s, a) = opt(class_scope)(s)?; let (s, b) = keyword("new")(s)?; @@ -184,6 +202,7 @@ pub(crate) fn class_new_argument(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_new_expression(s: Span) -> IResult { let (s, a) = keyword("new")(s)?; let (s, b) = expression(s)?; @@ -194,6 +213,7 @@ pub(crate) fn class_new_expression(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn dynamic_array_new(s: Span) -> IResult { let (s, a) = keyword("new")(s)?; let (s, b) = bracket(expression)(s)?; diff --git a/sv-parser-parser/src/declarations/declaration_lists.rs b/sv-parser-parser/src/declarations/declaration_lists.rs index 0d74d8c..2426e9c 100644 --- a/sv-parser-parser/src/declarations/declaration_lists.rs +++ b/sv-parser-parser/src/declarations/declaration_lists.rs @@ -3,18 +3,21 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_defparam_assignments(s: Span) -> IResult { let (s, a) = list(symbol(","), defparam_assignment)(s)?; Ok((s, ListOfDefparamAssignments { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_genvar_identifiers(s: Span) -> IResult { let (s, a) = list(symbol(","), genvar_identifier)(s)?; Ok((s, ListOfGenvarIdentifiers { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_interface_identifiers(s: Span) -> IResult { let (s, a) = list( symbol(","), @@ -24,18 +27,21 @@ pub(crate) fn list_of_interface_identifiers(s: Span) -> IResult IResult { let (s, a) = list(symbol(","), net_decl_assignment)(s)?; Ok((s, ListOfNetDeclAssignments { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_param_assignments(s: Span) -> IResult { let (s, a) = list(symbol(","), param_assignment)(s)?; Ok((s, ListOfParamAssignments { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_port_identifiers(s: Span) -> IResult { let (s, a) = list( symbol(","), @@ -45,18 +51,21 @@ pub(crate) fn list_of_port_identifiers(s: Span) -> IResult IResult { let (s, a) = list(symbol(","), port_identifier)(s)?; Ok((s, ListOfUdpPortIdentifiers { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_specparam_assignments(s: Span) -> IResult { let (s, a) = list(symbol(","), specparam_assignment)(s)?; Ok((s, ListOfSpecparamAssignments { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_tf_variable_identifiers( s: Span, ) -> IResult { @@ -72,6 +81,7 @@ pub(crate) fn list_of_tf_variable_identifiers( } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_type_assignments(s: Span) -> IResult { let (s, a) = list( symbol(","), @@ -84,6 +94,7 @@ pub(crate) fn list_of_type_assignments(s: Span) -> IResult IResult { @@ -92,6 +103,7 @@ pub(crate) fn list_of_variable_decl_assignments( } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_variable_identifiers(s: Span) -> IResult { let (s, a) = list( symbol(","), @@ -101,6 +113,7 @@ pub(crate) fn list_of_variable_identifiers(s: Span) -> IResult IResult { diff --git a/sv-parser-parser/src/declarations/declaration_ranges.rs b/sv-parser-parser/src/declarations/declaration_ranges.rs index 650f1f5..ad731c5 100644 --- a/sv-parser-parser/src/declarations/declaration_ranges.rs +++ b/sv-parser-parser/src/declarations/declaration_ranges.rs @@ -3,11 +3,13 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn unpacked_dimension(s: Span) -> IResult { alt((unpacked_dimension_range, unpacked_dimension_expression))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn unpacked_dimension_range(s: Span) -> IResult { let (s, a) = bracket(constant_range)(s)?; Ok(( @@ -17,6 +19,7 @@ pub(crate) fn unpacked_dimension_range(s: Span) -> IResult IResult { let (s, a) = bracket(constant_expression)(s)?; Ok(( @@ -26,6 +29,7 @@ pub(crate) fn unpacked_dimension_expression(s: Span) -> IResult IResult { alt(( packed_dimension_range, @@ -36,6 +40,7 @@ pub(crate) fn packed_dimension(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn packed_dimension_range(s: Span) -> IResult { let (s, a) = bracket(constant_range)(s)?; Ok(( @@ -45,6 +50,7 @@ pub(crate) fn packed_dimension_range(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn associative_dimension(s: Span) -> IResult { alt(( associative_dimension_data_type, @@ -53,6 +59,7 @@ pub(crate) fn associative_dimension(s: Span) -> IResult IResult { let (s, a) = bracket(data_type)(s)?; Ok(( @@ -62,6 +69,7 @@ pub(crate) fn associative_dimension_data_type(s: Span) -> IResult IResult { let (s, a) = bracket(symbol("*"))(s)?; Ok(( @@ -71,6 +79,7 @@ pub(crate) fn associative_dimension_asterisk(s: Span) -> IResult IResult { alt(( map(unsized_dimension, |x| { @@ -89,6 +98,7 @@ pub(crate) fn variable_dimension(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn queue_dimension(s: Span) -> IResult { let (s, a) = bracket(pair( symbol("$"), @@ -98,6 +108,7 @@ pub(crate) fn queue_dimension(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn unsized_dimension(s: Span) -> IResult { let (s, a) = symbol("[")(s)?; let (s, b) = symbol("]")(s)?; diff --git a/sv-parser-parser/src/declarations/delays.rs b/sv-parser-parser/src/declarations/delays.rs index b389888..da43914 100644 --- a/sv-parser-parser/src/declarations/delays.rs +++ b/sv-parser-parser/src/declarations/delays.rs @@ -3,11 +3,13 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn delay3(s: Span) -> IResult { alt((delay3_single, delay3_mintypmax))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn delay3_single(s: Span) -> IResult { let (s, a) = symbol("#")(s)?; let (s, b) = delay_value(s)?; @@ -15,6 +17,7 @@ pub(crate) fn delay3_single(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn delay3_mintypmax(s: Span) -> IResult { let (s, a) = symbol("#")(s)?; let (s, b) = paren(pair( @@ -32,11 +35,13 @@ pub(crate) fn delay3_mintypmax(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn delay2(s: Span) -> IResult { alt((delay2_single, delay2_mintypmax))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn delay2_single(s: Span) -> IResult { let (s, a) = symbol("#")(s)?; let (s, b) = delay_value(s)?; @@ -44,6 +49,7 @@ pub(crate) fn delay2_single(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn delay2_mintypmax(s: Span) -> IResult { let (s, a) = symbol("#")(s)?; let (s, b) = paren(pair( @@ -57,6 +63,7 @@ pub(crate) fn delay2_mintypmax(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn delay_value(s: Span) -> IResult { alt(( map(unsigned_number, |x| DelayValue::UnsignedNumber(Box::new(x))), diff --git a/sv-parser-parser/src/declarations/function_declarations.rs b/sv-parser-parser/src/declarations/function_declarations.rs index ae10efd..094b577 100644 --- a/sv-parser-parser/src/declarations/function_declarations.rs +++ b/sv-parser-parser/src/declarations/function_declarations.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn function_data_type_or_implicit(s: Span) -> IResult { alt(( map( @@ -29,6 +30,7 @@ pub(crate) fn function_data_type_or_implicit(s: Span) -> IResult IResult { let (s, a) = keyword("function")(s)?; let (s, b) = opt(lifetime)(s)?; @@ -37,6 +39,7 @@ pub(crate) fn function_declaration(s: Span) -> IResult IResult { alt(( function_body_declaration_without_port, @@ -45,6 +48,7 @@ pub(crate) fn function_body_declaration(s: Span) -> IResult IResult { @@ -65,6 +69,7 @@ pub(crate) fn function_body_declaration_without_port( } #[tracable_parser] +#[packrat_parser] pub(crate) fn function_body_declaration_with_port( s: Span, ) -> IResult { @@ -86,6 +91,7 @@ pub(crate) fn function_body_declaration_with_port( } #[tracable_parser] +#[packrat_parser] pub(crate) fn interface_identifier_or_class_scope( s: Span, ) -> IResult { @@ -100,6 +106,7 @@ pub(crate) fn interface_identifier_or_class_scope( } #[tracable_parser] +#[packrat_parser] pub(crate) fn function_prototype(s: Span) -> IResult { let (s, a) = keyword("function")(s)?; let (s, b) = data_type_or_void(s)?; @@ -114,6 +121,7 @@ pub(crate) fn function_prototype(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn dpi_import_export(s: Span) -> IResult { alt(( dpi_import_export_import_function, @@ -124,6 +132,7 @@ pub(crate) fn dpi_import_export(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn dpi_import_export_import_function(s: Span) -> IResult { let (s, a) = keyword("import")(s)?; let (s, b) = dpi_spec_string(s)?; @@ -140,6 +149,7 @@ pub(crate) fn dpi_import_export_import_function(s: Span) -> IResult IResult { let (s, a) = keyword("import")(s)?; let (s, b) = dpi_spec_string(s)?; @@ -156,6 +166,7 @@ pub(crate) fn dpi_import_export_import_task(s: Span) -> IResult IResult { let (s, a) = keyword("export")(s)?; let (s, b) = dpi_spec_string(s)?; @@ -172,6 +183,7 @@ pub(crate) fn dpi_import_export_export_function(s: Span) -> IResult IResult { let (s, a) = keyword("export")(s)?; let (s, b) = dpi_spec_string(s)?; @@ -188,6 +200,7 @@ pub(crate) fn dpi_import_export_export_task(s: Span) -> IResult IResult { alt(( map(keyword("DPI-C"), |x| DpiSpecString::DpiC(Box::new(x))), @@ -196,6 +209,7 @@ pub(crate) fn dpi_spec_string(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn dpi_function_import_property(s: Span) -> IResult { alt(( map(keyword("context"), |x| { @@ -208,18 +222,21 @@ pub(crate) fn dpi_function_import_property(s: Span) -> IResult IResult { let (s, a) = keyword("context")(s)?; Ok((s, DpiTaskImportProperty::Context(Box::new(a)))) } #[tracable_parser] +#[packrat_parser] pub(crate) fn dpi_function_proto(s: Span) -> IResult { let (s, a) = function_prototype(s)?; Ok((s, DpiFunctionProto { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn dpi_task_proto(s: Span) -> IResult { let (s, a) = task_prototype(s)?; Ok((s, DpiTaskProto { nodes: (a,) })) diff --git a/sv-parser-parser/src/declarations/interface_declarations.rs b/sv-parser-parser/src/declarations/interface_declarations.rs index c3bacee..af68d20 100644 --- a/sv-parser-parser/src/declarations/interface_declarations.rs +++ b/sv-parser-parser/src/declarations/interface_declarations.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn modport_declaration(s: Span) -> IResult { let (s, a) = keyword("modport")(s)?; let (s, b) = list(symbol(","), modport_item)(s)?; @@ -11,6 +12,7 @@ pub(crate) fn modport_declaration(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn modport_item(s: Span) -> IResult { let (s, a) = modport_identifier(s)?; let (s, b) = paren(list(symbol(","), modport_ports_declaration))(s)?; @@ -18,6 +20,7 @@ pub(crate) fn modport_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn modport_ports_declaration(s: Span) -> IResult { alt(( modport_ports_declaration_simple, @@ -27,6 +30,7 @@ pub(crate) fn modport_ports_declaration(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = modport_simple_ports_declaration(s)?; @@ -37,6 +41,7 @@ pub(crate) fn modport_ports_declaration_simple(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = modport_tf_ports_declaration(s)?; @@ -47,6 +52,7 @@ pub(crate) fn modport_ports_declaration_tf(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = modport_clocking_declaration(s)?; @@ -59,6 +65,7 @@ pub(crate) fn modport_ports_declaration_clocking(s: Span) -> IResult IResult { let (s, a) = keyword("clocking")(s)?; let (s, b) = clocking_identifier(s)?; @@ -66,6 +73,7 @@ pub(crate) fn modport_clocking_declaration(s: Span) -> IResult IResult { @@ -75,11 +83,13 @@ pub(crate) fn modport_simple_ports_declaration( } #[tracable_parser] +#[packrat_parser] pub(crate) fn modport_simple_port(s: Span) -> IResult { alt((modport_simple_port_named, modport_simple_port_ordered))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn modport_simple_port_ordered(s: Span) -> IResult { let (s, a) = port_identifier(s)?; Ok(( @@ -89,6 +99,7 @@ pub(crate) fn modport_simple_port_ordered(s: Span) -> IResult IResult { let (s, a) = symbol(".")(s)?; let (s, b) = port_identifier(s)?; @@ -100,6 +111,7 @@ pub(crate) fn modport_simple_port_named(s: Span) -> IResult IResult { let (s, a) = import_export(s)?; let (s, b) = list(symbol(","), modport_tf_port)(s)?; @@ -107,6 +119,7 @@ pub(crate) fn modport_tf_ports_declaration(s: Span) -> IResult IResult { alt(( map(method_prototype, |x| { @@ -117,6 +130,7 @@ pub(crate) fn modport_tf_port(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn import_export(s: Span) -> IResult { alt(( map(keyword("import"), |x| ImportExport::Import(Box::new(x))), diff --git a/sv-parser-parser/src/declarations/let_declarations.rs b/sv-parser-parser/src/declarations/let_declarations.rs index da8b9c7..e2a187a 100644 --- a/sv-parser-parser/src/declarations/let_declarations.rs +++ b/sv-parser-parser/src/declarations/let_declarations.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn let_declaration(s: Span) -> IResult { let (s, a) = keyword("let")(s)?; let (s, b) = let_identifier(s)?; @@ -19,18 +20,21 @@ pub(crate) fn let_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn let_identifier(s: Span) -> IResult { let (s, a) = identifier(s)?; Ok((s, LetIdentifier { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn let_port_list(s: Span) -> IResult { let (s, a) = list(symbol(","), let_port_item)(s)?; Ok((s, LetPortList { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn let_port_item(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = let_formal_type(s)?; @@ -46,6 +50,7 @@ pub(crate) fn let_port_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn let_formal_type(s: Span) -> IResult { alt(( map(data_type_or_implicit_let_formal_type, |x| { @@ -56,6 +61,7 @@ pub(crate) fn let_formal_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_or_implicit_let_formal_type(s: Span) -> IResult { alt(( map(terminated(data_type, peek(formal_port_identifier)), |x| { @@ -69,6 +75,7 @@ pub(crate) fn data_type_or_implicit_let_formal_type(s: Span) -> IResult IResult { let (s, a) = opt(package_scope)(s)?; let (s, b) = let_identifier(s)?; @@ -77,12 +84,14 @@ pub(crate) fn let_expression(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn let_list_of_arguments(s: Span) -> IResult { alt((let_list_of_arguments_named, let_list_of_arguments_ordered))(s) } #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn let_list_of_arguments_ordered(s: Span) -> IResult { let (s, a) = list(symbol(","), opt(let_actual_arg))(s)?; let (s, b) = many0(tuple(( @@ -98,6 +107,7 @@ pub(crate) fn let_list_of_arguments_ordered(s: Span) -> IResult IResult { let (s, a) = list( symbol(","), @@ -110,6 +120,7 @@ pub(crate) fn let_list_of_arguments_named(s: Span) -> IResult IResult { let (s, a) = expression(s)?; Ok((s, LetActualArg { nodes: (a,) })) diff --git a/sv-parser-parser/src/declarations/module_parameter_declarations.rs b/sv-parser-parser/src/declarations/module_parameter_declarations.rs index cfaecfe..bd712de 100644 --- a/sv-parser-parser/src/declarations/module_parameter_declarations.rs +++ b/sv-parser-parser/src/declarations/module_parameter_declarations.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn local_parameter_declaration(s: Span) -> IResult { alt(( local_parameter_declaration_param, @@ -11,6 +12,7 @@ pub(crate) fn local_parameter_declaration(s: Span) -> IResult IResult { @@ -26,6 +28,7 @@ pub(crate) fn local_parameter_declaration_param( } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_or_implicit_local_parameter_declaration_param( s: Span, ) -> IResult { @@ -41,6 +44,7 @@ pub(crate) fn data_type_or_implicit_local_parameter_declaration_param( } #[tracable_parser] +#[packrat_parser] pub(crate) fn local_parameter_declaration_type( s: Span, ) -> IResult { @@ -56,11 +60,13 @@ pub(crate) fn local_parameter_declaration_type( } #[tracable_parser] +#[packrat_parser] pub(crate) fn parameter_declaration(s: Span) -> IResult { alt((parameter_declaration_param, parameter_declaration_type))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn parameter_declaration_param(s: Span) -> IResult { let (s, a) = keyword("parameter")(s)?; let (s, b) = data_type_or_implicit_parameter_declaration_param(s)?; @@ -72,6 +78,7 @@ pub(crate) fn parameter_declaration_param(s: Span) -> IResult IResult { @@ -87,6 +94,7 @@ pub(crate) fn data_type_or_implicit_parameter_declaration_param( } #[tracable_parser] +#[packrat_parser] pub(crate) fn parameter_declaration_type(s: Span) -> IResult { let (s, a) = keyword("parameter")(s)?; let (s, b) = keyword("type")(s)?; @@ -98,6 +106,7 @@ pub(crate) fn parameter_declaration_type(s: Span) -> IResult IResult { let (s, a) = keyword("specparam")(s)?; let (s, b) = opt(packed_dimension)(s)?; diff --git a/sv-parser-parser/src/declarations/net_and_variable_types.rs b/sv-parser-parser/src/declarations/net_and_variable_types.rs index a55c6f0..18bcd11 100644 --- a/sv-parser-parser/src/declarations/net_and_variable_types.rs +++ b/sv-parser-parser/src/declarations/net_and_variable_types.rs @@ -5,6 +5,7 @@ use crate::*; #[recursive_parser] #[packrat_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn casting_type(s: Span) -> IResult { alt(( map(simple_type, |x| CastingType::SimpleType(Box::new(x))), @@ -18,6 +19,7 @@ pub(crate) fn casting_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type(s: Span) -> IResult { alt(( data_type_vector, @@ -41,6 +43,7 @@ pub(crate) fn data_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_vector(s: Span) -> IResult { let (s, a) = integer_vector_type(s)?; let (s, b) = opt(signing)(s)?; @@ -52,6 +55,7 @@ pub(crate) fn data_type_vector(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_atom(s: Span) -> IResult { let (s, a) = integer_atom_type(s)?; let (s, b) = opt(signing)(s)?; @@ -59,6 +63,7 @@ pub(crate) fn data_type_atom(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_struct_union(s: Span) -> IResult { let (s, a) = struct_union(s)?; let (s, b) = opt(pair(packed, opt(signing)))(s)?; @@ -73,12 +78,14 @@ pub(crate) fn data_type_struct_union(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn packed(s: Span) -> IResult { let (s, a) = keyword("packed")(s)?; Ok((s, Packed { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_enum(s: Span) -> IResult { let (s, a) = keyword("enum")(s)?; let (s, b) = opt(enum_base_type)(s)?; @@ -93,6 +100,7 @@ pub(crate) fn data_type_enum(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_virtual(s: Span) -> IResult { let (s, a) = keyword("virtual")(s)?; let (s, b) = opt(interface)(s)?; @@ -108,12 +116,14 @@ pub(crate) fn data_type_virtual(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn interface(s: Span) -> IResult { let (s, a) = keyword("interface")(s)?; Ok((s, Interface { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_type(s: Span) -> IResult { let (s, a) = opt(package_scope_or_class_scope)(s)?; let (s, b) = type_identifier(s)?; @@ -127,6 +137,7 @@ pub(crate) fn data_type_type(s: Span) -> IResult { // all data_type_or_implicit call are specialized for each parser #[allow(dead_code)] #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_or_implicit(s: Span) -> IResult { alt(( map(data_type, |x| DataTypeOrImplicit::DataType(Box::new(x))), @@ -137,6 +148,7 @@ pub(crate) fn data_type_or_implicit(s: Span) -> IResult IResult { let (s, a) = opt(signing)(s)?; let (s, b) = many0(packed_dimension)(s)?; @@ -144,6 +156,7 @@ pub(crate) fn implicit_data_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn enum_base_type(s: Span) -> IResult { alt(( enum_base_type_atom, @@ -153,6 +166,7 @@ pub(crate) fn enum_base_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn enum_base_type_atom(s: Span) -> IResult { let (s, a) = integer_atom_type(s)?; let (s, b) = opt(signing)(s)?; @@ -163,6 +177,7 @@ pub(crate) fn enum_base_type_atom(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn enum_base_type_vector(s: Span) -> IResult { let (s, a) = integer_vector_type(s)?; let (s, b) = opt(signing)(s)?; @@ -174,6 +189,7 @@ pub(crate) fn enum_base_type_vector(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn enum_base_type_type(s: Span) -> IResult { let (s, a) = type_identifier(s)?; let (s, b) = opt(packed_dimension)(s)?; @@ -184,6 +200,7 @@ pub(crate) fn enum_base_type_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn enum_name_declaration(s: Span) -> IResult { let (s, a) = enum_identifier(s)?; let (s, b) = opt(bracket(pair( @@ -196,6 +213,7 @@ pub(crate) fn enum_name_declaration(s: Span) -> IResult IResult { let (s, a) = class_type(s)?; let (s, b) = symbol("::")(s)?; @@ -203,6 +221,7 @@ pub(crate) fn class_scope(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_type(s: Span) -> IResult { let (s, a) = ps_class_identifier(s)?; let (s, b) = opt(parameter_value_assignment)(s)?; @@ -215,6 +234,7 @@ pub(crate) fn class_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn integer_type(s: Span) -> IResult { alt(( map(integer_vector_type, |x| { @@ -227,6 +247,7 @@ pub(crate) fn integer_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn integer_atom_type(s: Span) -> IResult { alt(( map(keyword("byte"), |x| IntegerAtomType::Byte(Box::new(x))), @@ -245,6 +266,7 @@ pub(crate) fn integer_atom_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn integer_vector_type(s: Span) -> IResult { alt(( map(keyword("bit"), |x| IntegerVectorType::Bit(Box::new(x))), @@ -254,6 +276,7 @@ pub(crate) fn integer_vector_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn non_integer_type(s: Span) -> IResult { alt(( map(keyword("shortreal"), |x| { @@ -267,6 +290,7 @@ pub(crate) fn non_integer_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_type(s: Span) -> IResult { alt(( map(keyword("supply0"), |x| NetType::Supply0(Box::new(x))), @@ -285,6 +309,7 @@ pub(crate) fn net_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_port_type(s: Span) -> IResult { alt(( net_port_type_data_type, @@ -296,6 +321,7 @@ pub(crate) fn net_port_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_port_type_data_type(s: Span) -> IResult { let (s, a) = opt(net_type)(s)?; let (s, b) = data_type_or_implicit_net_port_type_data_type(s)?; @@ -306,6 +332,7 @@ pub(crate) fn net_port_type_data_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_or_implicit_net_port_type_data_type( s: Span, ) -> IResult { @@ -320,6 +347,7 @@ pub(crate) fn data_type_or_implicit_net_port_type_data_type( } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_port_type_interconnect(s: Span) -> IResult { let (s, a) = keyword("interconnect")(s)?; let (s, b) = implicit_data_type(s)?; @@ -330,12 +358,14 @@ pub(crate) fn net_port_type_interconnect(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn variable_port_type(s: Span) -> IResult { let (s, a) = var_data_type(s)?; Ok((s, VariablePortType { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn var_data_type(s: Span) -> IResult { alt(( map(terminated(data_type, peek(variable_identifier)), |x| { @@ -346,6 +376,7 @@ pub(crate) fn var_data_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn var_data_type_var(s: Span) -> IResult { let (s, a) = keyword("var")(s)?; let (s, b) = data_type_or_implicit_var_data_type_var(s)?; @@ -356,6 +387,7 @@ pub(crate) fn var_data_type_var(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_or_implicit_var_data_type_var( s: Span, ) -> IResult { @@ -371,6 +403,7 @@ pub(crate) fn data_type_or_implicit_var_data_type_var( } #[tracable_parser] +#[packrat_parser] pub(crate) fn signing(s: Span) -> IResult { alt(( map(keyword("signed"), |x| Signing::Signed(Box::new(x))), @@ -380,6 +413,7 @@ pub(crate) fn signing(s: Span) -> IResult { #[packrat_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn simple_type(s: Span) -> IResult { alt(( map(integer_type, |x| SimpleType::IntegerType(Box::new(x))), @@ -396,6 +430,7 @@ pub(crate) fn simple_type(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn struct_union_member(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = opt(random_qualifier)(s)?; @@ -411,6 +446,7 @@ pub(crate) fn struct_union_member(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_or_void(s: Span) -> IResult { alt(( map(data_type, |x| DataTypeOrVoid::DataType(Box::new(x))), @@ -419,6 +455,7 @@ pub(crate) fn data_type_or_void(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn struct_union(s: Span) -> IResult { alt(( map(keyword("struct"), |x| StructUnion::Struct(Box::new(x))), @@ -430,11 +467,13 @@ pub(crate) fn struct_union(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn type_reference(s: Span) -> IResult { alt((type_reference_expression, type_reference_data_type))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn type_reference_expression(s: Span) -> IResult { let (s, a) = keyword("type")(s)?; let (s, b) = paren(expression)(s)?; @@ -445,6 +484,7 @@ pub(crate) fn type_reference_expression(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn type_reference_data_type(s: Span) -> IResult { let (s, a) = keyword("type")(s)?; let (s, b) = paren(data_type)(s)?; diff --git a/sv-parser-parser/src/declarations/port_declarations.rs b/sv-parser-parser/src/declarations/port_declarations.rs index 011d0e4..5b62ae6 100644 --- a/sv-parser-parser/src/declarations/port_declarations.rs +++ b/sv-parser-parser/src/declarations/port_declarations.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn inout_declaration(s: Span) -> IResult { let (s, a) = keyword("inout")(s)?; let (s, b) = net_port_type(s)?; @@ -11,11 +12,13 @@ pub(crate) fn inout_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn input_declaration(s: Span) -> IResult { alt((input_declaration_net, input_declaration_variable))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn input_declaration_net(s: Span) -> IResult { let (s, a) = keyword("input")(s)?; let (s, b) = net_port_type(s)?; @@ -27,6 +30,7 @@ pub(crate) fn input_declaration_net(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn input_declaration_variable(s: Span) -> IResult { let (s, a) = keyword("input")(s)?; let (s, b) = variable_port_type(s)?; @@ -38,11 +42,13 @@ pub(crate) fn input_declaration_variable(s: Span) -> IResult IResult { alt((output_declaration_net, output_declaration_variable))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn output_declaration_net(s: Span) -> IResult { let (s, a) = keyword("output")(s)?; let (s, b) = net_port_type(s)?; @@ -54,6 +60,7 @@ pub(crate) fn output_declaration_net(s: Span) -> IResult IResult { let (s, a) = keyword("output")(s)?; let (s, b) = variable_port_type(s)?; @@ -65,6 +72,7 @@ pub(crate) fn output_declaration_variable(s: Span) -> IResult IResult { let (s, a) = interface_identifier(s)?; let (s, b) = opt(pair(symbol("."), modport_identifier))(s)?; @@ -73,6 +81,7 @@ pub(crate) fn interface_port_declaration(s: Span) -> IResult IResult { let (s, a) = keyword("ref")(s)?; let (s, b) = variable_port_type(s)?; diff --git a/sv-parser-parser/src/declarations/strengths.rs b/sv-parser-parser/src/declarations/strengths.rs index 0a5d524..5e26c9b 100644 --- a/sv-parser-parser/src/declarations/strengths.rs +++ b/sv-parser-parser/src/declarations/strengths.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn drive_strength(s: Span) -> IResult { alt(( drive_strength01, @@ -15,6 +16,7 @@ pub(crate) fn drive_strength(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn drive_strength01(s: Span) -> IResult { let (s, a) = paren(triple(strength0, symbol(","), strength1))(s)?; Ok(( @@ -24,6 +26,7 @@ pub(crate) fn drive_strength01(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn drive_strength10(s: Span) -> IResult { let (s, a) = paren(triple(strength1, symbol(","), strength0))(s)?; Ok(( @@ -33,6 +36,7 @@ pub(crate) fn drive_strength10(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn drive_strength0z(s: Span) -> IResult { let (s, a) = paren(triple(strength0, symbol(","), keyword("highz1")))(s)?; Ok(( @@ -42,6 +46,7 @@ pub(crate) fn drive_strength0z(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn drive_strength1z(s: Span) -> IResult { let (s, a) = paren(triple(strength1, symbol(","), keyword("highz0")))(s)?; Ok(( @@ -51,6 +56,7 @@ pub(crate) fn drive_strength1z(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn drive_strengthz1(s: Span) -> IResult { let (s, a) = paren(triple(keyword("highz0"), symbol(","), strength1))(s)?; Ok(( @@ -60,6 +66,7 @@ pub(crate) fn drive_strengthz1(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn drive_strengthz0(s: Span) -> IResult { let (s, a) = paren(triple(keyword("highz1"), symbol(","), strength0))(s)?; Ok(( @@ -69,6 +76,7 @@ pub(crate) fn drive_strengthz0(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn strength0(s: Span) -> IResult { alt(( map(keyword("supply0"), |x| Strength0::Supply0(Box::new(x))), @@ -79,6 +87,7 @@ pub(crate) fn strength0(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn strength1(s: Span) -> IResult { alt(( map(keyword("supply1"), |x| Strength1::Supply1(Box::new(x))), @@ -89,6 +98,7 @@ pub(crate) fn strength1(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn charge_strength(s: Span) -> IResult { alt(( charge_strength_small, @@ -98,6 +108,7 @@ pub(crate) fn charge_strength(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn charge_strength_small(s: Span) -> IResult { let (s, a) = paren(keyword("small"))(s)?; Ok(( @@ -107,6 +118,7 @@ pub(crate) fn charge_strength_small(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn charge_strength_medium(s: Span) -> IResult { let (s, a) = paren(keyword("medium"))(s)?; Ok(( @@ -116,6 +128,7 @@ pub(crate) fn charge_strength_medium(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn charge_strength_large(s: Span) -> IResult { let (s, a) = paren(keyword("large"))(s)?; Ok(( diff --git a/sv-parser-parser/src/declarations/task_declarations.rs b/sv-parser-parser/src/declarations/task_declarations.rs index 1ba48b5..e3c0183 100644 --- a/sv-parser-parser/src/declarations/task_declarations.rs +++ b/sv-parser-parser/src/declarations/task_declarations.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn task_declaration(s: Span) -> IResult { let (s, a) = keyword("task")(s)?; let (s, b) = opt(lifetime)(s)?; @@ -11,6 +12,7 @@ pub(crate) fn task_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn task_body_declaration(s: Span) -> IResult { alt(( task_body_declaration_without_port, @@ -19,6 +21,7 @@ pub(crate) fn task_body_declaration(s: Span) -> IResult IResult { let (s, a) = opt(interface_identifier_or_class_scope)(s)?; let (s, b) = task_identifier(s)?; @@ -36,6 +39,7 @@ pub(crate) fn task_body_declaration_without_port(s: Span) -> IResult IResult { let (s, a) = opt(interface_identifier_or_class_scope)(s)?; let (s, b) = task_identifier(s)?; @@ -54,6 +58,7 @@ pub(crate) fn task_body_declaration_with_port(s: Span) -> IResult IResult { alt(( map(block_item_declaration, |x| { @@ -66,12 +71,14 @@ pub(crate) fn tf_item_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn tf_port_list(s: Span) -> IResult { let (s, a) = list(symbol(","), tf_port_item)(s)?; Ok((s, TfPortList { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn tf_port_item(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = opt(tf_port_direction)(s)?; @@ -91,6 +98,7 @@ pub(crate) fn tf_port_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_or_implicit_tf_port_item(s: Span) -> IResult { alt(( map( @@ -125,6 +133,7 @@ pub(crate) fn data_type_or_implicit_tf_port_item(s: Span) -> IResult IResult { alt(( map(port_direction, |x| { @@ -137,6 +146,7 @@ pub(crate) fn tf_port_direction(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn tf_port_declaration(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = tf_port_direction(s)?; @@ -153,6 +163,7 @@ pub(crate) fn tf_port_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_or_implicit_tf_port_declaration( s: Span, ) -> IResult { @@ -168,6 +179,7 @@ pub(crate) fn data_type_or_implicit_tf_port_declaration( } #[tracable_parser] +#[packrat_parser] pub(crate) fn task_prototype(s: Span) -> IResult { let (s, a) = keyword("task")(s)?; let (s, b) = task_identifier(s)?; diff --git a/sv-parser-parser/src/declarations/type_declarations.rs b/sv-parser-parser/src/declarations/type_declarations.rs index ef0ebd7..5abeb46 100644 --- a/sv-parser-parser/src/declarations/type_declarations.rs +++ b/sv-parser-parser/src/declarations/type_declarations.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn data_declaration(s: Span) -> IResult { alt(( data_declaration_variable, @@ -19,6 +20,7 @@ pub(crate) fn data_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_declaration_variable(s: Span) -> IResult { let (s, a) = opt(r#const)(s)?; let (s, b) = opt(var)(s)?; @@ -35,6 +37,7 @@ pub(crate) fn data_declaration_variable(s: Span) -> IResult IResult { @@ -50,12 +53,14 @@ pub(crate) fn data_type_or_implicit_data_declaration_variable( } #[tracable_parser] +#[packrat_parser] pub(crate) fn r#const(s: Span) -> IResult { let (s, a) = keyword("const")(s)?; Ok((s, Const { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn package_import_declaration(s: Span) -> IResult { let (s, a) = keyword("import")(s)?; let (s, b) = list(symbol(","), package_import_item)(s)?; @@ -64,11 +69,13 @@ pub(crate) fn package_import_declaration(s: Span) -> IResult IResult { alt((package_import_item_identifier, package_import_item_asterisk))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn package_import_item_identifier(s: Span) -> IResult { let (s, a) = package_identifier(s)?; let (s, b) = symbol("::")(s)?; @@ -80,6 +87,7 @@ pub(crate) fn package_import_item_identifier(s: Span) -> IResult IResult { let (s, a) = package_identifier(s)?; let (s, b) = symbol("::")(s)?; @@ -91,6 +99,7 @@ pub(crate) fn package_import_item_asterisk(s: Span) -> IResult IResult { alt(( package_export_declaration_asterisk, @@ -99,6 +108,7 @@ pub(crate) fn package_export_declaration(s: Span) -> IResult IResult { @@ -114,6 +124,7 @@ pub(crate) fn package_export_declaration_asterisk( } #[tracable_parser] +#[packrat_parser] pub(crate) fn package_export_declaration_item(s: Span) -> IResult { let (s, a) = keyword("export")(s)?; let (s, b) = list(symbol(","), package_import_item)(s)?; @@ -125,6 +136,7 @@ pub(crate) fn package_export_declaration_item(s: Span) -> IResult IResult { let (s, a) = keyword("genvar")(s)?; let (s, b) = list_of_genvar_identifiers(s)?; @@ -133,6 +145,7 @@ pub(crate) fn genvar_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_declaration(s: Span) -> IResult { alt(( net_declaration_interconnect, @@ -142,6 +155,7 @@ pub(crate) fn net_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_declaration_net_type(s: Span) -> IResult { let (s, a) = net_type(s)?; let (s, b) = opt(strength)(s)?; @@ -159,6 +173,7 @@ pub(crate) fn net_declaration_net_type(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_type_or_implicit_net_declaration_net_type( s: Span, ) -> IResult { @@ -178,6 +193,7 @@ pub(crate) fn data_type_or_implicit_net_declaration_net_type( } #[tracable_parser] +#[packrat_parser] pub(crate) fn strength(s: Span) -> IResult { alt(( map(drive_strength, |x| Strength::Drive(Box::new(x))), @@ -186,6 +202,7 @@ pub(crate) fn strength(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn vector_scalar(s: Span) -> IResult { alt(( map(keyword("vectored"), |x| VectorScalar::Vectored(Box::new(x))), @@ -194,6 +211,7 @@ pub(crate) fn vector_scalar(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_declaration_net_type_identifier(s: Span) -> IResult { let (s, a) = net_type_identifier(s)?; let (s, b) = opt(delay_control)(s)?; @@ -208,6 +226,7 @@ pub(crate) fn net_declaration_net_type_identifier(s: Span) -> IResult IResult { let (s, a) = keyword("interconnect")(s)?; let (s, b) = implicit_data_type(s)?; @@ -229,6 +248,7 @@ pub(crate) fn net_declaration_interconnect(s: Span) -> IResult IResult { alt(( type_declaration_data_type, @@ -238,6 +258,7 @@ pub(crate) fn type_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn type_declaration_data_type(s: Span) -> IResult { let (s, a) = keyword("typedef")(s)?; let (s, b) = data_type(s)?; @@ -253,6 +274,7 @@ pub(crate) fn type_declaration_data_type(s: Span) -> IResult IResult { let (s, a) = keyword("typedef")(s)?; let (s, b) = interface_instance_identifier(s)?; @@ -270,6 +292,7 @@ pub(crate) fn type_declaration_interface(s: Span) -> IResult IResult { let (s, a) = keyword("typedef")(s)?; let (s, b) = opt(type_declaration_keyword)(s)?; @@ -284,6 +307,7 @@ pub(crate) fn type_declaration_reserved(s: Span) -> IResult IResult { alt(( map(keyword("enum"), |x| { @@ -305,6 +329,7 @@ pub(crate) fn type_declaration_keyword(s: Span) -> IResult IResult { alt(( net_type_declaration_data_type, @@ -313,6 +338,7 @@ pub(crate) fn net_type_declaration(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_type_declaration_data_type(s: Span) -> IResult { let (s, a) = keyword("nettype")(s)?; let (s, b) = data_type(s)?; @@ -332,6 +358,7 @@ pub(crate) fn net_type_declaration_data_type(s: Span) -> IResult IResult { let (s, a) = keyword("nettype")(s)?; let (s, b) = opt(package_scope_or_class_scope)(s)?; @@ -347,6 +374,7 @@ pub(crate) fn net_type_declaration_net_type(s: Span) -> IResult IResult { alt(( map(keyword("static"), |x| Lifetime::Static(Box::new(x))), diff --git a/sv-parser-parser/src/expressions/concatenations.rs b/sv-parser-parser/src/expressions/concatenations.rs index e07b65f..f51b9bb 100644 --- a/sv-parser-parser/src/expressions/concatenations.rs +++ b/sv-parser-parser/src/expressions/concatenations.rs @@ -3,18 +3,21 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn concatenation(s: Span) -> IResult { let (s, a) = brace(list(symbol(","), expression))(s)?; Ok((s, Concatenation { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_concatenation(s: Span) -> IResult { let (s, a) = brace(list(symbol(","), constant_expression))(s)?; Ok((s, ConstantConcatenation { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_multiple_concatenation( s: Span, ) -> IResult { @@ -23,12 +26,14 @@ pub(crate) fn constant_multiple_concatenation( } #[tracable_parser] +#[packrat_parser] pub(crate) fn module_path_concatenation(s: Span) -> IResult { let (s, a) = brace(list(symbol(","), module_path_expression))(s)?; Ok((s, ModulePathConcatenation { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn module_path_multiple_concatenation( s: Span, ) -> IResult { @@ -37,12 +42,14 @@ pub(crate) fn module_path_multiple_concatenation( } #[tracable_parser] +#[packrat_parser] pub(crate) fn multiple_concatenation(s: Span) -> IResult { let (s, a) = brace(pair(expression, concatenation))(s)?; Ok((s, MultipleConcatenation { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn streaming_concatenation(s: Span) -> IResult { let (s, a) = brace(triple( stream_operator, @@ -53,6 +60,7 @@ pub(crate) fn streaming_concatenation(s: Span) -> IResult IResult { alt(( map(symbol(">>"), |x| StreamOperator { nodes: (x,) }), @@ -61,6 +69,7 @@ pub(crate) fn stream_operator(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn slice_size(s: Span) -> IResult { alt(( map(simple_type, |x| SliceSize::SimpleType(Box::new(x))), @@ -71,6 +80,7 @@ pub(crate) fn slice_size(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn stream_concatenation(s: Span) -> IResult { let (s, a) = brace(list(symbol(","), stream_expression))(s)?; Ok((s, StreamConcatenation { nodes: (a,) })) @@ -78,6 +88,7 @@ pub(crate) fn stream_concatenation(s: Span) -> IResult IResult { let (s, a) = expression(s)?; let (s, b) = opt(pair(keyword("with"), bracket(array_range_expression)))(s)?; @@ -85,6 +96,7 @@ pub(crate) fn stream_expression(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn array_range_expression(s: Span) -> IResult { alt(( map(expression, |x| { @@ -98,6 +110,7 @@ pub(crate) fn array_range_expression(s: Span) -> IResult IResult { let (s, a) = expression(s)?; let (s, b) = symbol(":")(s)?; @@ -110,6 +123,7 @@ pub(crate) fn array_range_expression_colon(s: Span) -> IResult IResult { let (s, a) = expression(s)?; let (s, b) = symbol("+:")(s)?; @@ -124,6 +138,7 @@ pub(crate) fn array_range_expression_plus_colon(s: Span) -> IResult IResult { let (s, a) = expression(s)?; let (s, b) = symbol("-:")(s)?; @@ -137,6 +152,7 @@ pub(crate) fn array_range_expression_minus_colon(s: Span) -> IResult IResult { diff --git a/sv-parser-parser/src/expressions/expression_leftside_values.rs b/sv-parser-parser/src/expressions/expression_leftside_values.rs index d7a1fb2..81afe4f 100644 --- a/sv-parser-parser/src/expressions/expression_leftside_values.rs +++ b/sv-parser-parser/src/expressions/expression_leftside_values.rs @@ -2,13 +2,14 @@ use crate::*; // ----------------------------------------------------------------------------- -#[packrat_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn net_lvalue(s: Span) -> IResult { alt((net_lvalue_identifier, net_lvalue_lvalue, net_lvalue_pattern))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_lvalue_identifier(s: Span) -> IResult { let (s, a) = ps_or_hierarchical_net_identifier(s)?; let (s, b) = constant_select(s)?; @@ -19,6 +20,7 @@ pub(crate) fn net_lvalue_identifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_lvalue_pattern(s: Span) -> IResult { let (s, a) = opt(assignment_pattern_expression_type)(s)?; let (s, b) = assignment_pattern_net_lvalue(s)?; @@ -29,6 +31,7 @@ pub(crate) fn net_lvalue_pattern(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_lvalue_lvalue(s: Span) -> IResult { let (s, a) = brace(list(symbol(","), net_lvalue))(s)?; Ok(( @@ -37,8 +40,8 @@ pub(crate) fn net_lvalue_lvalue(s: Span) -> IResult { )) } -#[packrat_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn variable_lvalue(s: Span) -> IResult { alt(( variable_lvalue_identifier, @@ -51,6 +54,7 @@ pub(crate) fn variable_lvalue(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn variable_lvalue_identifier(s: Span) -> IResult { let (s, a) = opt(implicit_class_handle_or_package_scope)(s)?; let (s, b) = hierarchical_variable_identifier(s)?; @@ -62,6 +66,7 @@ pub(crate) fn variable_lvalue_identifier(s: Span) -> IResult IResult { let (s, a) = opt(assignment_pattern_expression_type)(s)?; let (s, b) = assignment_pattern_variable_lvalue(s)?; @@ -72,6 +77,7 @@ pub(crate) fn variable_lvalue_pattern(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn variable_lvalue_lvalue(s: Span) -> IResult { let (s, a) = brace(list(symbol(","), variable_lvalue))(s)?; Ok(( @@ -81,6 +87,7 @@ pub(crate) fn variable_lvalue_lvalue(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn nonrange_variable_lvalue(s: Span) -> IResult { let (s, a) = opt(implicit_class_handle_or_package_scope)(s)?; let (s, b) = hierarchical_variable_identifier(s)?; diff --git a/sv-parser-parser/src/expressions/expressions.rs b/sv-parser-parser/src/expressions/expressions.rs index 5993563..5f8655e 100644 --- a/sv-parser-parser/src/expressions/expressions.rs +++ b/sv-parser-parser/src/expressions/expressions.rs @@ -3,11 +3,13 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn inc_or_dec_expression(s: Span) -> IResult { alt((inc_or_dec_expression_prefix, inc_or_dec_expression_suffix))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn inc_or_dec_expression_prefix(s: Span) -> IResult { let (s, a) = inc_or_dec_operator(s)?; let (s, b) = many0(attribute_instance)(s)?; @@ -20,6 +22,7 @@ pub(crate) fn inc_or_dec_expression_prefix(s: Span) -> IResult IResult { let (s, a) = variable_lvalue(s)?; let (s, b) = many0(attribute_instance)(s)?; @@ -32,6 +35,7 @@ pub(crate) fn inc_or_dec_expression_suffix(s: Span) -> IResult IResult { let (s, a) = cond_predicate(s)?; let (s, b) = symbol("?")(s)?; @@ -47,8 +51,8 @@ pub(crate) fn conditional_expression(s: Span) -> IResult IResult { alt(( constant_expression_binary, @@ -61,6 +65,7 @@ pub(crate) fn constant_expression(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_expression_unary(s: Span) -> IResult { let (s, a) = unary_operator(s)?; let (s, b) = many0(attribute_instance)(s)?; @@ -73,6 +78,7 @@ pub(crate) fn constant_expression_unary(s: Span) -> IResult IResult { let (s, a) = constant_expression(s)?; let (s, b) = binary_operator(s)?; @@ -88,6 +94,7 @@ pub(crate) fn constant_expression_binary(s: Span) -> IResult IResult { let (s, a) = constant_expression(s)?; let (s, b) = symbol("?")(s)?; @@ -104,6 +111,7 @@ pub(crate) fn constant_expression_ternary(s: Span) -> IResult IResult { alt(( constant_mintypmax_expression_ternary, @@ -115,6 +123,7 @@ pub(crate) fn constant_mintypmax_expression(s: Span) -> IResult IResult { @@ -132,6 +141,7 @@ pub(crate) fn constant_mintypmax_expression_ternary( } #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_param_expression(s: Span) -> IResult { alt(( map(symbol("$"), |x| { @@ -147,6 +157,7 @@ pub(crate) fn constant_param_expression(s: Span) -> IResult IResult { alt(( map(symbol("$"), |x| ParamExpression::Dollar(Box::new(x))), @@ -158,6 +169,7 @@ pub(crate) fn param_expression(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_range_expression(s: Span) -> IResult { alt(( map(constant_part_select_range, |x| { @@ -170,6 +182,7 @@ pub(crate) fn constant_range_expression(s: Span) -> IResult IResult { alt(( map(constant_range, |x| { @@ -183,6 +196,7 @@ pub(crate) fn constant_part_select_range(s: Span) -> IResult IResult { let (s, a) = constant_expression(s)?; let (s, b) = symbol(":")(s)?; @@ -192,6 +206,7 @@ pub(crate) fn constant_range(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_indexed_range(s: Span) -> IResult { let (s, a) = constant_expression(s)?; let (s, b) = alt((symbol("+:"), symbol("-:")))(s)?; @@ -199,8 +214,8 @@ pub(crate) fn constant_indexed_range(s: Span) -> IResult IResult { alt(( expression_binary, @@ -223,6 +238,7 @@ pub(crate) fn expression(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn expression_unary(s: Span) -> IResult { let (s, x) = unary_operator(s)?; let (s, y) = many0(attribute_instance)(s)?; @@ -234,6 +250,7 @@ pub(crate) fn expression_unary(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn expression_operator_assignment(s: Span) -> IResult { let (s, a) = paren(operator_assignment)(s)?; Ok(( @@ -244,6 +261,7 @@ pub(crate) fn expression_operator_assignment(s: Span) -> IResult IResult { let (s, a) = expression(s)?; let (s, b) = binary_operator(s)?; @@ -258,6 +276,7 @@ pub(crate) fn expression_binary(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn tagged_union_expression(s: Span) -> IResult { let (s, a) = keyword("tagged")(s)?; let (s, b) = member_identifier(s)?; @@ -267,6 +286,7 @@ pub(crate) fn tagged_union_expression(s: Span) -> IResult IResult { let (s, a) = expression(s)?; let (s, b) = keyword("inside")(s)?; @@ -275,6 +295,7 @@ pub(crate) fn inside_expression(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn value_range(s: Span) -> IResult { alt(( value_range_binary, @@ -283,6 +304,7 @@ pub(crate) fn value_range(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn value_range_binary(s: Span) -> IResult { let (s, a) = bracket(triple(expression, symbol(":"), expression))(s)?; Ok(( @@ -292,6 +314,7 @@ pub(crate) fn value_range_binary(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn mintypmax_expression(s: Span) -> IResult { alt(( mintypmax_expression_ternary, @@ -301,6 +324,7 @@ pub(crate) fn mintypmax_expression(s: Span) -> IResult IResult { let (s, a) = expression(s)?; let (s, b) = symbol(":")(s)?; @@ -317,6 +341,7 @@ pub(crate) fn mintypmax_expression_ternary(s: Span) -> IResult IResult { @@ -335,6 +360,7 @@ pub(crate) fn module_path_conditional_expression( } #[tracable_parser] +#[packrat_parser] pub(crate) fn module_path_expression(s: Span) -> IResult { alt(( map(module_path_primary, |x| { @@ -349,6 +375,7 @@ pub(crate) fn module_path_expression(s: Span) -> IResult IResult { let (s, a) = unary_module_path_operator(s)?; let (s, b) = many0(attribute_instance)(s)?; @@ -361,6 +388,7 @@ pub(crate) fn module_path_expression_unary(s: Span) -> IResult IResult { let (s, a) = module_path_expression(s)?; let (s, b) = binary_module_path_operator(s)?; @@ -375,6 +403,7 @@ pub(crate) fn module_path_expression_binary(s: Span) -> IResult IResult { @@ -388,6 +417,7 @@ pub(crate) fn module_path_mintypmax_expression( #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn module_path_mintypmax_expression_ternary( s: Span, ) -> IResult { @@ -405,6 +435,7 @@ pub(crate) fn module_path_mintypmax_expression_ternary( } #[tracable_parser] +#[packrat_parser] pub(crate) fn part_select_range(s: Span) -> IResult { alt(( map(constant_range, |x| { @@ -418,6 +449,7 @@ pub(crate) fn part_select_range(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn indexed_range(s: Span) -> IResult { let (s, a) = expression(s)?; let (s, b) = alt((symbol("+:"), symbol("-:")))(s)?; @@ -426,6 +458,7 @@ pub(crate) fn indexed_range(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn genvar_expression(s: Span) -> IResult { let (s, a) = constant_expression(s)?; Ok((s, GenvarExpression { nodes: (a,) })) diff --git a/sv-parser-parser/src/expressions/numbers.rs b/sv-parser-parser/src/expressions/numbers.rs index 0b01e15..2236566 100644 --- a/sv-parser-parser/src/expressions/numbers.rs +++ b/sv-parser-parser/src/expressions/numbers.rs @@ -2,8 +2,8 @@ use crate::*; // ----------------------------------------------------------------------------- -#[packrat_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn number(s: Span) -> IResult { alt(( map(real_number, |x| Number::RealNumber(Box::new(x))), @@ -12,6 +12,7 @@ pub(crate) fn number(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn integral_number(s: Span) -> IResult { alt(( map(octal_number, |x| IntegralNumber::OctalNumber(Box::new(x))), @@ -24,6 +25,7 @@ pub(crate) fn integral_number(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn decimal_number(s: Span) -> IResult { alt(( decimal_number_base_unsigned, @@ -36,6 +38,7 @@ pub(crate) fn decimal_number(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn decimal_number_base_unsigned(s: Span) -> IResult { let (s, a) = opt(size)(s)?; let (s, b) = decimal_base(s)?; @@ -47,6 +50,7 @@ pub(crate) fn decimal_number_base_unsigned(s: Span) -> IResult IResult { let (s, a) = opt(size)(s)?; let (s, b) = decimal_base(s)?; @@ -58,6 +62,7 @@ pub(crate) fn decimal_number_base_x_number(s: Span) -> IResult IResult { let (s, a) = opt(size)(s)?; let (s, b) = decimal_base(s)?; @@ -69,6 +74,7 @@ pub(crate) fn decimal_number_base_z_number(s: Span) -> IResult IResult { let (s, a) = opt(size)(s)?; let (s, b) = binary_base(s)?; @@ -77,6 +83,7 @@ pub(crate) fn binary_number(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn octal_number(s: Span) -> IResult { let (s, a) = opt(size)(s)?; let (s, b) = octal_base(s)?; @@ -85,6 +92,7 @@ pub(crate) fn octal_number(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn hex_number(s: Span) -> IResult { let (s, a) = opt(size)(s)?; let (s, b) = hex_base(s)?; @@ -93,6 +101,7 @@ pub(crate) fn hex_number(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn sign(s: Span) -> IResult { alt(( map(symbol("+"), |x| Sign::Plus(Box::new(x))), @@ -101,12 +110,14 @@ pub(crate) fn sign(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn size(s: Span) -> IResult { let (s, a) = non_zero_unsigned_number(s)?; Ok((s, Size { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn non_zero_unsigned_number(s: Span) -> IResult { let (s, a) = ws(non_zero_unsigned_number_impl)(s)?; Ok((s, NonZeroUnsignedNumber { nodes: a })) @@ -122,6 +133,7 @@ pub(crate) fn non_zero_unsigned_number_impl(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn real_number(s: Span) -> IResult { alt(( real_number_floating, @@ -132,6 +144,7 @@ pub(crate) fn real_number(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn real_number_floating(s: Span) -> IResult { let (s, a) = unsigned_number(s)?; let (s, b) = opt(pair(symbol("."), unsigned_number))(s)?; @@ -147,6 +160,7 @@ pub(crate) fn real_number_floating(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn fixed_point_number(s: Span) -> IResult { let (s, a) = unsigned_number(s)?; let (s, b) = map(tag("."), |x: Span| Symbol { @@ -157,12 +171,14 @@ pub(crate) fn fixed_point_number(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn exp(s: Span) -> IResult { let (s, a) = alt((symbol("e"), symbol("E")))(s)?; Ok((s, Exp { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn unsigned_number(s: Span) -> IResult { let (s, a) = ws(unsigned_number_impl)(s)?; Ok((s, UnsignedNumber { nodes: a })) @@ -178,6 +194,7 @@ pub(crate) fn unsigned_number_impl(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn binary_value(s: Span) -> IResult { let (s, a) = ws(binary_value_impl)(s)?; Ok((s, BinaryValue { nodes: a })) @@ -193,6 +210,7 @@ pub(crate) fn binary_value_impl(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn octal_value(s: Span) -> IResult { let (s, a) = ws(octal_value_impl)(s)?; Ok((s, OctalValue { nodes: a })) @@ -208,6 +226,7 @@ pub(crate) fn octal_value_impl(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn hex_value(s: Span) -> IResult { let (s, a) = ws(hex_value_impl)(s)?; Ok((s, HexValue { nodes: a })) @@ -225,6 +244,7 @@ pub(crate) fn hex_value_impl(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn decimal_base(s: Span) -> IResult { let (s, a) = ws(decimal_base_impl)(s)?; Ok((s, DecimalBase { nodes: a })) @@ -237,6 +257,7 @@ pub(crate) fn decimal_base_impl(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn binary_base(s: Span) -> IResult { let (s, a) = ws(binary_base_impl)(s)?; Ok((s, BinaryBase { nodes: a })) @@ -249,6 +270,7 @@ pub(crate) fn binary_base_impl(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn octal_base(s: Span) -> IResult { let (s, a) = ws(octal_base_impl)(s)?; Ok((s, OctalBase { nodes: a })) @@ -261,6 +283,7 @@ pub(crate) fn octal_base_impl(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn hex_base(s: Span) -> IResult { let (s, a) = ws(hex_base_impl)(s)?; Ok((s, HexBase { nodes: a })) @@ -273,6 +296,7 @@ pub(crate) fn hex_base_impl(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn x_number(s: Span) -> IResult { let (s, a) = ws(x_number_impl)(s)?; Ok((s, XNumber { nodes: a })) @@ -288,6 +312,7 @@ pub(crate) fn x_number_impl(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn z_number(s: Span) -> IResult { let (s, a) = ws(z_number_impl)(s)?; Ok((s, ZNumber { nodes: a })) @@ -303,6 +328,7 @@ pub(crate) fn z_number_impl(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn unbased_unsized_literal(s: Span) -> IResult { let (s, a) = alt(( symbol("'0"), diff --git a/sv-parser-parser/src/expressions/operators.rs b/sv-parser-parser/src/expressions/operators.rs index 7c39b17..0cd2b14 100644 --- a/sv-parser-parser/src/expressions/operators.rs +++ b/sv-parser-parser/src/expressions/operators.rs @@ -2,8 +2,8 @@ use crate::*; // ----------------------------------------------------------------------------- -#[packrat_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn unary_operator(s: Span) -> IResult { let (s, a) = alt(( symbol("+"), @@ -22,6 +22,7 @@ pub(crate) fn unary_operator(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn binary_operator(s: Span) -> IResult { let (s, a) = alt(( alt(( @@ -62,12 +63,14 @@ pub(crate) fn binary_operator(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn inc_or_dec_operator(s: Span) -> IResult { let (s, a) = alt((symbol("++"), symbol("--")))(s)?; Ok((s, IncOrDecOperator { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn unary_module_path_operator(s: Span) -> IResult { let (s, a) = alt(( symbol("!"), @@ -84,6 +87,7 @@ pub(crate) fn unary_module_path_operator(s: Span) -> IResult IResult { let (s, a) = alt(( symbol("=="), diff --git a/sv-parser-parser/src/expressions/primaries.rs b/sv-parser-parser/src/expressions/primaries.rs index 9952df2..05157a8 100644 --- a/sv-parser-parser/src/expressions/primaries.rs +++ b/sv-parser-parser/src/expressions/primaries.rs @@ -2,8 +2,8 @@ use crate::*; // ----------------------------------------------------------------------------- -#[packrat_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_primary(s: Span) -> IResult { alt(( map(keyword("null"), |x| ConstantPrimary::Null(Box::new(x))), @@ -39,6 +39,7 @@ pub(crate) fn constant_primary(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_primary_ps_parameter(s: Span) -> IResult { let (s, a) = ps_parameter_identifier(s)?; let (s, b) = constant_select(s)?; @@ -49,6 +50,7 @@ pub(crate) fn constant_primary_ps_parameter(s: Span) -> IResult IResult { let (s, a) = specparam_identifier(s)?; let (s, b) = opt(bracket(constant_range_expression))(s)?; @@ -59,6 +61,7 @@ pub(crate) fn constant_primary_specparam(s: Span) -> IResult IResult { let (s, a) = formal_port_identifier(s)?; let (s, b) = constant_select(s)?; @@ -69,6 +72,7 @@ pub(crate) fn constant_primary_formal_port(s: Span) -> IResult IResult { let (s, a) = package_scope_or_class_scope(s)?; let (s, b) = enum_identifier(s)?; @@ -79,6 +83,7 @@ pub(crate) fn constant_primary_enum(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_primary_concatenation(s: Span) -> IResult { let (s, a) = constant_concatenation(s)?; let (s, b) = opt(bracket(constant_range_expression))(s)?; @@ -89,6 +94,7 @@ pub(crate) fn constant_primary_concatenation(s: Span) -> IResult IResult { let (s, a) = constant_multiple_concatenation(s)?; let (s, b) = opt(bracket(constant_range_expression))(s)?; @@ -101,6 +107,7 @@ pub(crate) fn constant_primary_multiple_concatenation(s: Span) -> IResult IResult { let (s, a) = paren(constant_mintypmax_expression)(s)?; Ok(( @@ -112,6 +119,7 @@ pub(crate) fn constant_primary_mintypmax_expression(s: Span) -> IResult IResult { alt(( map(number, |x| ModulePathPrimary::Number(Box::new(x))), @@ -130,6 +138,7 @@ pub(crate) fn module_path_primary(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn module_path_primary_mintypmax_expression( s: Span, ) -> IResult { @@ -140,8 +149,8 @@ pub(crate) fn module_path_primary_mintypmax_expression( )) } -#[packrat_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn primary(s: Span) -> IResult { alt(( map(keyword("this"), |x| Primary::This(Box::new(x))), @@ -173,6 +182,7 @@ pub(crate) fn primary(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn primary_hierarchical(s: Span) -> IResult { let (s, a) = opt(class_qualifier_or_package_scope)(s)?; let (s, b) = hierarchical_identifier(s)?; @@ -184,6 +194,7 @@ pub(crate) fn primary_hierarchical(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn primary_concatenation(s: Span) -> IResult { let (s, a) = concatenation(s)?; let (s, b) = opt(bracket(range_expression))(s)?; @@ -194,6 +205,7 @@ pub(crate) fn primary_concatenation(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn primary_multiple_concatenation(s: Span) -> IResult { let (s, a) = multiple_concatenation(s)?; let (s, b) = opt(bracket(range_expression))(s)?; @@ -204,6 +216,7 @@ pub(crate) fn primary_multiple_concatenation(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn primary_mintypmax_expression(s: Span) -> IResult { let (s, a) = paren(mintypmax_expression)(s)?; Ok(( @@ -213,6 +226,7 @@ pub(crate) fn primary_mintypmax_expression(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_qualifier_or_package_scope( s: Span, ) -> IResult { @@ -228,6 +242,7 @@ pub(crate) fn class_qualifier_or_package_scope( #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn class_qualifier(s: Span) -> IResult { let (s, a) = opt(local)(s)?; let (s, b) = opt(implicit_class_handle_or_class_scope)(s)?; @@ -235,6 +250,7 @@ pub(crate) fn class_qualifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn range_expression(s: Span) -> IResult { alt(( map(expression, |x| RangeExpression::Expression(Box::new(x))), @@ -244,8 +260,8 @@ pub(crate) fn range_expression(s: Span) -> IResult { ))(s) } -#[packrat_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn primary_literal(s: Span) -> IResult { alt(( map(time_literal, |x| PrimaryLiteral::TimeLiteral(Box::new(x))), @@ -260,11 +276,13 @@ pub(crate) fn primary_literal(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn time_literal(s: Span) -> IResult { alt((time_literal_unsigned, time_literal_fixed_point))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn time_literal_unsigned(s: Span) -> IResult { let (s, a) = unsigned_number(s)?; let (s, b) = time_unit(s)?; @@ -275,6 +293,7 @@ pub(crate) fn time_literal_unsigned(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn time_literal_fixed_point(s: Span) -> IResult { let (s, a) = fixed_point_number(s)?; let (s, b) = time_unit(s)?; @@ -285,6 +304,7 @@ pub(crate) fn time_literal_fixed_point(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn time_unit(s: Span) -> IResult { alt(( map(keyword("s"), |x| TimeUnit::S(Box::new(x))), @@ -297,6 +317,7 @@ pub(crate) fn time_unit(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn implicit_class_handle(s: Span) -> IResult { alt(( map( @@ -311,12 +332,14 @@ pub(crate) fn implicit_class_handle(s: Span) -> IResult IResult { let (s, a) = many0(bracket(expression))(s)?; Ok((s, BitSelect { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn select(s: Span) -> IResult { let (s, a) = opt(triple( many0(terminated( @@ -332,6 +355,7 @@ pub(crate) fn select(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn nonrange_select(s: Span) -> IResult { let (s, a) = opt(triple( many0(triple(symbol("."), member_identifier, bit_select)), @@ -343,12 +367,14 @@ pub(crate) fn nonrange_select(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_bit_select(s: Span) -> IResult { let (s, a) = many0(bracket(constant_expression))(s)?; Ok((s, ConstantBitSelect { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_select(s: Span) -> IResult { let (s, a) = opt(triple( many0(terminated( @@ -365,6 +391,7 @@ pub(crate) fn constant_select(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_cast(s: Span) -> IResult { let (s, a) = casting_type(s)?; let (s, b) = symbol("'")(s)?; @@ -373,6 +400,7 @@ pub(crate) fn constant_cast(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_let_expression(s: Span) -> IResult { let (s, a) = let_expression(s)?; Ok((s, ConstantLetExpression { nodes: (a,) })) @@ -380,6 +408,7 @@ pub(crate) fn constant_let_expression(s: Span) -> IResult IResult { let (s, a) = casting_type(s)?; let (s, b) = symbol("'")(s)?; diff --git a/sv-parser-parser/src/expressions/strings.rs b/sv-parser-parser/src/expressions/strings.rs index e0c2ae2..ed86aca 100644 --- a/sv-parser-parser/src/expressions/strings.rs +++ b/sv-parser-parser/src/expressions/strings.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn string_literal(s: Span) -> IResult { let (s, a) = ws(string_literal_impl)(s)?; Ok((s, StringLiteral { nodes: a })) diff --git a/sv-parser-parser/src/expressions/subroutine_calls.rs b/sv-parser-parser/src/expressions/subroutine_calls.rs index 50daa16..4eb91d6 100644 --- a/sv-parser-parser/src/expressions/subroutine_calls.rs +++ b/sv-parser-parser/src/expressions/subroutine_calls.rs @@ -3,12 +3,14 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn constant_function_call(s: Span) -> IResult { let (s, a) = function_subroutine_call(s)?; Ok((s, ConstantFunctionCall { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn tf_call(s: Span) -> IResult { let (s, a) = ps_or_hierarchical_tf_identifier(s)?; let (s, b) = many0(attribute_instance)(s)?; @@ -17,6 +19,7 @@ pub(crate) fn tf_call(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn system_tf_call(s: Span) -> IResult { alt(( system_tf_call_arg_optional, @@ -26,6 +29,7 @@ pub(crate) fn system_tf_call(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn system_tf_call_arg_optional(s: Span) -> IResult { let (s, a) = system_tf_identifier(s)?; let (s, b) = opt(paren(list_of_arguments))(s)?; @@ -36,6 +40,7 @@ pub(crate) fn system_tf_call_arg_optional(s: Span) -> IResult IResult { let (s, a) = system_tf_identifier(s)?; let (s, b) = paren(pair(data_type, opt(pair(symbol(","), expression))))(s)?; @@ -46,6 +51,7 @@ pub(crate) fn system_tf_call_arg_data_type(s: Span) -> IResult IResult { let (s, a) = system_tf_identifier(s)?; let (s, b) = paren(pair( @@ -58,8 +64,8 @@ pub(crate) fn system_tf_call_arg_expression(s: Span) -> IResult IResult { alt(( map(method_call, |x| SubroutineCall::MethodCall(Box::new(x))), @@ -72,6 +78,7 @@ pub(crate) fn subroutine_call(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn subroutine_call_randomize(s: Span) -> IResult { let (s, a) = opt(pair(keyword("std"), symbol("::")))(s)?; let (s, b) = randomize_call(s)?; @@ -82,17 +89,20 @@ pub(crate) fn subroutine_call_randomize(s: Span) -> IResult IResult { map(subroutine_call, |x| FunctionSubroutineCall { nodes: (x,) })(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_arguments(s: Span) -> IResult { alt((list_of_arguments_named, list_of_arguments_ordered))(s) } #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_arguments_ordered(s: Span) -> IResult { let (s, a) = list(symbol(","), opt(expression))(s)?; let (s, b) = many0(tuple(( @@ -108,6 +118,7 @@ pub(crate) fn list_of_arguments_ordered(s: Span) -> IResult IResult { let (s, a) = symbol(".")(s)?; let (s, b) = identifier(s)?; @@ -128,6 +139,7 @@ pub(crate) fn list_of_arguments_named(s: Span) -> IResult #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn method_call(s: Span) -> IResult { let (s, a) = method_call_root(s)?; let (s, b) = symbol(".")(s)?; @@ -137,6 +149,7 @@ pub(crate) fn method_call(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn method_call_body(s: Span) -> IResult { alt(( method_call_body_user, @@ -147,6 +160,7 @@ pub(crate) fn method_call_body(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn method_call_body_user(s: Span) -> IResult { let (s, a) = method_identifier(s)?; let (s, b) = many0(attribute_instance)(s)?; @@ -158,6 +172,7 @@ pub(crate) fn method_call_body_user(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn built_in_method_call(s: Span) -> IResult { alt(( map(array_manipulation_call, |x| { @@ -170,6 +185,7 @@ pub(crate) fn built_in_method_call(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn array_manipulation_call(s: Span) -> IResult { let (s, a) = array_method_name(s)?; let (s, b) = many0(attribute_instance)(s)?; @@ -184,6 +200,7 @@ pub(crate) fn array_manipulation_call(s: Span) -> IResult IResult { let (s, a) = keyword("randomize")(s)?; let (s, b) = many0(attribute_instance)(s)?; @@ -202,6 +219,7 @@ pub(crate) fn randomize_call(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn variable_identifier_list_or_null( s: Span, ) -> IResult { @@ -216,6 +234,7 @@ pub(crate) fn variable_identifier_list_or_null( } #[tracable_parser] +#[packrat_parser] pub(crate) fn method_call_root(s: Span) -> IResult { alt(( map(primary, |x| MethodCallRoot::Primary(Box::new(x))), @@ -226,6 +245,7 @@ pub(crate) fn method_call_root(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn array_method_name(s: Span) -> IResult { alt(( map(keyword("unique"), |x| ArrayMethodName::Unique(Box::new(x))), diff --git a/sv-parser-parser/src/general/attributes.rs b/sv-parser-parser/src/general/attributes.rs index 85649c4..9c53a4b 100644 --- a/sv-parser-parser/src/general/attributes.rs +++ b/sv-parser-parser/src/general/attributes.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn attribute_instance(s: Span) -> IResult { let (s, a) = symbol("(*")(s)?; let (s, b) = list(symbol(","), attr_spec)(s)?; @@ -11,6 +12,7 @@ pub(crate) fn attribute_instance(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn attr_spec(s: Span) -> IResult { let (s, a) = identifier(s)?; let (s, b) = opt(pair(symbol("="), constant_expression))(s)?; diff --git a/sv-parser-parser/src/general/comments.rs b/sv-parser-parser/src/general/comments.rs index b92c92f..3f8fd5c 100644 --- a/sv-parser-parser/src/general/comments.rs +++ b/sv-parser-parser/src/general/comments.rs @@ -3,11 +3,13 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn comment(s: Span) -> IResult { alt((one_line_comment, block_comment))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn one_line_comment(s: Span) -> IResult { let (s, a) = tag("//")(s)?; let (s, b) = is_not("\n")(s)?; @@ -21,6 +23,7 @@ pub(crate) fn one_line_comment(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn block_comment(s: Span) -> IResult { let (s, a) = tag("/*")(s)?; let (s, b) = is_not("*/")(s)?; diff --git a/sv-parser-parser/src/general/identifiers.rs b/sv-parser-parser/src/general/identifiers.rs index 9ccecdf..82df870 100644 --- a/sv-parser-parser/src/general/identifiers.rs +++ b/sv-parser-parser/src/general/identifiers.rs @@ -27,6 +27,7 @@ pub(crate) fn bin_identifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn c_identifier(s: Span) -> IResult { let (s, a) = ws(c_identifier_impl)(s)?; Ok((s, CIdentifier { nodes: a })) @@ -200,8 +201,8 @@ pub(crate) fn hierarchical_event_identifier(s: Span) -> IResult IResult { let (s, a) = opt(root)(s)?; let (s, b) = many0(triple(identifier, constant_bit_select, symbol(".")))(s)?; @@ -210,6 +211,7 @@ pub(crate) fn hierarchical_identifier(s: Span) -> IResult IResult { let (s, a) = keyword("$root")(s)?; let (s, b) = symbol(".")(s)?; @@ -266,8 +268,8 @@ pub(crate) fn hierarchical_variable_identifier( Ok((s, HierarchicalVariableIdentifier { nodes: (a,) })) } -#[packrat_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn identifier(s: Span) -> IResult { alt(( map(escaped_identifier, |x| { @@ -369,8 +371,8 @@ pub(crate) fn package_identifier(s: Span) -> IResult { Ok((s, PackageIdentifier { nodes: (a,) })) } -#[packrat_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn package_scope(s: Span) -> IResult { alt(( package_scope_package, @@ -379,6 +381,7 @@ pub(crate) fn package_scope(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn package_scope_package(s: Span) -> IResult { let (s, a) = package_identifier(s)?; let (s, b) = symbol("::")(s)?; @@ -389,6 +392,7 @@ pub(crate) fn package_scope_package(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn unit(s: Span) -> IResult { let (s, a) = keyword("$unit")(s)?; let (s, b) = symbol("::")(s)?; @@ -426,6 +430,7 @@ pub(crate) fn property_identifier(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn ps_class_identifier(s: Span) -> IResult { let (s, a) = opt(package_scope)(s)?; let (s, b) = class_identifier(s)?; @@ -433,6 +438,7 @@ pub(crate) fn ps_class_identifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn ps_covergroup_identifier(s: Span) -> IResult { let (s, a) = opt(package_scope)(s)?; let (s, b) = covergroup_identifier(s)?; @@ -440,6 +446,7 @@ pub(crate) fn ps_covergroup_identifier(s: Span) -> IResult IResult { let (s, a) = opt(package_scope)(s)?; let (s, b) = checker_identifier(s)?; @@ -447,6 +454,7 @@ pub(crate) fn ps_checker_identifier(s: Span) -> IResult IResult { let (s, a) = opt(package_scope)(s)?; let (s, b) = identifier(s)?; @@ -454,6 +462,7 @@ pub(crate) fn ps_identifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn ps_or_hierarchical_array_identifier( s: Span, ) -> IResult { @@ -463,6 +472,7 @@ pub(crate) fn ps_or_hierarchical_array_identifier( } #[tracable_parser] +#[packrat_parser] pub(crate) fn ps_or_hierarchical_net_identifier( s: Span, ) -> IResult { @@ -475,6 +485,7 @@ pub(crate) fn ps_or_hierarchical_net_identifier( } #[tracable_parser] +#[packrat_parser] pub(crate) fn ps_or_hierarchical_net_identifier_package_scope( s: Span, ) -> IResult { @@ -489,6 +500,7 @@ pub(crate) fn ps_or_hierarchical_net_identifier_package_scope( } #[tracable_parser] +#[packrat_parser] pub(crate) fn ps_or_hierarchical_property_identifier( s: Span, ) -> IResult { @@ -501,6 +513,7 @@ pub(crate) fn ps_or_hierarchical_property_identifier( } #[tracable_parser] +#[packrat_parser] pub(crate) fn ps_or_hierarchical_property_identifier_package_scope( s: Span, ) -> IResult { @@ -515,6 +528,7 @@ pub(crate) fn ps_or_hierarchical_property_identifier_package_scope( } #[tracable_parser] +#[packrat_parser] pub(crate) fn ps_or_hierarchical_sequence_identifier( s: Span, ) -> IResult { @@ -527,6 +541,7 @@ pub(crate) fn ps_or_hierarchical_sequence_identifier( } #[tracable_parser] +#[packrat_parser] pub(crate) fn ps_or_hierarchical_sequence_identifier_package_scope( s: Span, ) -> IResult { @@ -541,6 +556,7 @@ pub(crate) fn ps_or_hierarchical_sequence_identifier_package_scope( } #[tracable_parser] +#[packrat_parser] pub(crate) fn ps_or_hierarchical_tf_identifier( s: Span, ) -> IResult { @@ -553,6 +569,7 @@ pub(crate) fn ps_or_hierarchical_tf_identifier( } #[tracable_parser] +#[packrat_parser] pub(crate) fn ps_or_hierarchical_tf_identifier_package_scope( s: Span, ) -> IResult { @@ -566,8 +583,8 @@ pub(crate) fn ps_or_hierarchical_tf_identifier_package_scope( )) } -#[packrat_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn ps_parameter_identifier(s: Span) -> IResult { alt(( ps_parameter_identifier_scope, @@ -576,6 +593,7 @@ pub(crate) fn ps_parameter_identifier(s: Span) -> IResult IResult { let (s, a) = opt(package_scope_or_class_scope)(s)?; let (s, b) = parameter_identifier(s)?; @@ -586,6 +604,7 @@ pub(crate) fn ps_parameter_identifier_scope(s: Span) -> IResult IResult { let (s, a) = many0(triple( generate_block_identifier, @@ -599,8 +618,8 @@ pub(crate) fn ps_parameter_identifier_generate(s: Span) -> IResult IResult { let (s, a) = opt(local_or_package_scope_or_class_scope)(s)?; let (s, b) = type_identifier(s)?; @@ -620,6 +639,7 @@ pub(crate) fn signal_identifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn simple_identifier(s: Span) -> IResult { let (s, a) = ws(simple_identifier_impl)(s)?; Ok((s, SimpleIdentifier { nodes: a })) @@ -648,6 +668,7 @@ pub(crate) fn specparam_identifier(s: Span) -> IResult IResult { let (s, a) = ws(system_tf_identifier_impl)(s)?; Ok((s, SystemTfIdentifier { nodes: a })) @@ -705,6 +726,7 @@ pub(crate) fn variable_identifier(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn implicit_class_handle_or_class_scope_or_package_scope( s: Span, ) -> IResult { @@ -722,6 +744,7 @@ pub(crate) fn implicit_class_handle_or_class_scope_or_package_scope( } #[tracable_parser] +#[packrat_parser] pub(crate) fn implicit_class_handle_or_package_scope( s: Span, ) -> IResult { @@ -736,6 +759,7 @@ pub(crate) fn implicit_class_handle_or_package_scope( } #[tracable_parser] +#[packrat_parser] pub(crate) fn implicit_class_handle_or_class_scope( s: Span, ) -> IResult { @@ -750,6 +774,7 @@ pub(crate) fn implicit_class_handle_or_class_scope( } #[tracable_parser] +#[packrat_parser] pub(crate) fn package_scope_or_class_scope(s: Span) -> IResult { alt(( map(package_scope, |x| { @@ -762,6 +787,7 @@ pub(crate) fn package_scope_or_class_scope(s: Span) -> IResult IResult { @@ -779,6 +805,7 @@ pub(crate) fn local_or_package_scope_or_class_scope( } #[tracable_parser] +#[packrat_parser] pub(crate) fn local(s: Span) -> IResult { let (s, a) = keyword("local")(s)?; let (s, b) = symbol("::")(s)?; diff --git a/sv-parser-parser/src/instantiations/checker_instantiation.rs b/sv-parser-parser/src/instantiations/checker_instantiation.rs index df69218..dad891b 100644 --- a/sv-parser-parser/src/instantiations/checker_instantiation.rs +++ b/sv-parser-parser/src/instantiations/checker_instantiation.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn checker_instantiation(s: Span) -> IResult { let (s, a) = ps_checker_identifier(s)?; let (s, b) = name_of_instance(s)?; @@ -17,6 +18,7 @@ pub(crate) fn checker_instantiation(s: Span) -> IResult IResult { @@ -28,6 +30,7 @@ pub(crate) fn list_of_checker_port_connections( #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_checker_port_connections_ordered( s: Span, ) -> IResult { @@ -41,6 +44,7 @@ pub(crate) fn list_of_checker_port_connections_ordered( } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_checker_port_connections_named( s: Span, ) -> IResult { @@ -55,6 +59,7 @@ pub(crate) fn list_of_checker_port_connections_named( #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn ordered_checker_port_connection( s: Span, ) -> IResult { @@ -64,6 +69,7 @@ pub(crate) fn ordered_checker_port_connection( } #[tracable_parser] +#[packrat_parser] pub(crate) fn named_checker_port_connection(s: Span) -> IResult { alt(( named_checker_port_connection_identifier, @@ -72,6 +78,7 @@ pub(crate) fn named_checker_port_connection(s: Span) -> IResult IResult { @@ -88,6 +95,7 @@ pub(crate) fn named_checker_port_connection_identifier( } #[tracable_parser] +#[packrat_parser] pub(crate) fn named_checker_port_connection_asterisk( s: Span, ) -> IResult { diff --git a/sv-parser-parser/src/instantiations/generated_instantiation.rs b/sv-parser-parser/src/instantiations/generated_instantiation.rs index 0c53aad..59c0634 100644 --- a/sv-parser-parser/src/instantiations/generated_instantiation.rs +++ b/sv-parser-parser/src/instantiations/generated_instantiation.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn generate_region(s: Span) -> IResult { let (s, a) = keyword("generate")(s)?; let (s, b) = many0(generate_item)(s)?; @@ -11,6 +12,7 @@ pub(crate) fn generate_region(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn loop_generate_construct(s: Span) -> IResult { let (s, a) = keyword("for")(s)?; let (s, b) = paren(tuple(( @@ -25,6 +27,7 @@ pub(crate) fn loop_generate_construct(s: Span) -> IResult IResult { let (s, a) = opt(map(keyword("genvar"), |x| Genvar { nodes: (x,) }))(s)?; let (s, b) = genvar_identifier(s)?; @@ -39,6 +42,7 @@ pub(crate) fn generate_initialization(s: Span) -> IResult IResult { alt(( genvar_iteration_assignment, @@ -48,6 +52,7 @@ pub(crate) fn genvar_iteration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn genvar_iteration_assignment(s: Span) -> IResult { let (s, a) = genvar_identifier(s)?; let (s, b) = assignment_operator(s)?; @@ -59,6 +64,7 @@ pub(crate) fn genvar_iteration_assignment(s: Span) -> IResult IResult { let (s, a) = inc_or_dec_operator(s)?; let (s, b) = genvar_identifier(s)?; @@ -69,6 +75,7 @@ pub(crate) fn genvar_iteration_prefix(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn genvar_iteration_suffix(s: Span) -> IResult { let (s, a) = genvar_identifier(s)?; let (s, b) = inc_or_dec_operator(s)?; @@ -79,6 +86,7 @@ pub(crate) fn genvar_iteration_suffix(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn conditional_generate_construct( s: Span, ) -> IResult { @@ -93,6 +101,7 @@ pub(crate) fn conditional_generate_construct( } #[tracable_parser] +#[packrat_parser] pub(crate) fn if_generate_construct(s: Span) -> IResult { let (s, a) = keyword("if")(s)?; let (s, b) = paren(constant_expression)(s)?; @@ -107,6 +116,7 @@ pub(crate) fn if_generate_construct(s: Span) -> IResult IResult { let (s, a) = keyword("case")(s)?; let (s, b) = paren(constant_expression)(s)?; @@ -121,12 +131,14 @@ pub(crate) fn case_generate_construct(s: Span) -> IResult IResult { alt((case_generate_item_nondefault, case_generate_item_default))(s) } #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn case_generate_item_nondefault(s: Span) -> IResult { let (s, a) = list(symbol(","), constant_expression)(s)?; let (s, b) = symbol(":")(s)?; @@ -138,6 +150,7 @@ pub(crate) fn case_generate_item_nondefault(s: Span) -> IResult IResult { let (s, a) = keyword("default")(s)?; let (s, b) = opt(symbol(":"))(s)?; @@ -149,6 +162,7 @@ pub(crate) fn case_generate_item_default(s: Span) -> IResult IResult { alt(( map(generate_item, |x| GenerateBlock::GenerateItem(Box::new(x))), @@ -157,6 +171,7 @@ pub(crate) fn generate_block(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn generate_block_multiple(s: Span) -> IResult { let (s, a) = opt(pair(generate_block_identifier, symbol(":")))(s)?; let (s, b) = keyword("begin")(s)?; @@ -173,6 +188,7 @@ pub(crate) fn generate_block_multiple(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn generate_item(s: Span) -> IResult { alt(( map(module_or_generate_item, |x| { diff --git a/sv-parser-parser/src/instantiations/interface_instantiation.rs b/sv-parser-parser/src/instantiations/interface_instantiation.rs index 828a842..aa1f957 100644 --- a/sv-parser-parser/src/instantiations/interface_instantiation.rs +++ b/sv-parser-parser/src/instantiations/interface_instantiation.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn interface_instantiation(s: Span) -> IResult { let (s, a) = interface_identifier(s)?; let (s, b) = opt(parameter_value_assignment)(s)?; diff --git a/sv-parser-parser/src/instantiations/module_instantiation.rs b/sv-parser-parser/src/instantiations/module_instantiation.rs index 6abfac5..fff26f6 100644 --- a/sv-parser-parser/src/instantiations/module_instantiation.rs +++ b/sv-parser-parser/src/instantiations/module_instantiation.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn module_instantiation(s: Span) -> IResult { let (s, a) = module_identifier(s)?; let (s, b) = opt(parameter_value_assignment)(s)?; @@ -17,6 +18,7 @@ pub(crate) fn module_instantiation(s: Span) -> IResult IResult { let (s, a) = symbol("#")(s)?; let (s, b) = paren(opt(list_of_parameter_assignments))(s)?; @@ -24,6 +26,7 @@ pub(crate) fn parameter_value_assignment(s: Span) -> IResult IResult { alt(( list_of_parameter_assignments_named, @@ -33,6 +36,7 @@ pub(crate) fn list_of_parameter_assignments(s: Span) -> IResult IResult { @@ -46,6 +50,7 @@ pub(crate) fn list_of_parameter_assignments_ordered( } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_parameter_assignments_named( s: Span, ) -> IResult { @@ -59,12 +64,14 @@ pub(crate) fn list_of_parameter_assignments_named( } #[tracable_parser] +#[packrat_parser] pub(crate) fn ordered_parameter_assignment(s: Span) -> IResult { let (s, x) = param_expression(s)?; Ok((s, OrderedParameterAssignment { nodes: (x,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn named_parameter_assignment(s: Span) -> IResult { let (s, a) = symbol(".")(s)?; let (s, b) = parameter_identifier(s)?; @@ -73,6 +80,7 @@ pub(crate) fn named_parameter_assignment(s: Span) -> IResult IResult { let (s, a) = name_of_instance(s)?; let (s, b) = paren(opt(list_of_port_connections))(s)?; @@ -80,6 +88,7 @@ pub(crate) fn hierarchical_instance(s: Span) -> IResult IResult { let (s, x) = instance_identifier(s)?; let (s, y) = many0(unpacked_dimension)(s)?; @@ -87,6 +96,7 @@ pub(crate) fn name_of_instance(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_port_connections(s: Span) -> IResult { alt(( list_of_port_connections_named, @@ -96,6 +106,7 @@ pub(crate) fn list_of_port_connections(s: Span) -> IResult IResult { let (s, a) = list(symbol(","), ordered_port_connection)(s)?; Ok(( @@ -105,6 +116,7 @@ pub(crate) fn list_of_port_connections_ordered(s: Span) -> IResult IResult { let (s, a) = list(symbol(","), named_port_connection)(s)?; Ok(( @@ -115,6 +127,7 @@ pub(crate) fn list_of_port_connections_named(s: Span) -> IResult IResult { let (s, x) = many0(attribute_instance)(s)?; let (s, y) = opt(expression)(s)?; @@ -122,6 +135,7 @@ pub(crate) fn ordered_port_connection(s: Span) -> IResult IResult { alt(( named_port_connection_identifier, @@ -130,6 +144,7 @@ pub(crate) fn named_port_connection(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = symbol(".")(s)?; @@ -144,6 +159,7 @@ pub(crate) fn named_port_connection_identifier(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = symbol(".*")(s)?; diff --git a/sv-parser-parser/src/instantiations/program_instantiation.rs b/sv-parser-parser/src/instantiations/program_instantiation.rs index ca4cda6..2285062 100644 --- a/sv-parser-parser/src/instantiations/program_instantiation.rs +++ b/sv-parser-parser/src/instantiations/program_instantiation.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn program_instantiation(s: Span) -> IResult { let (s, a) = program_identifier(s)?; let (s, b) = opt(parameter_value_assignment)(s)?; diff --git a/sv-parser-parser/src/lib.rs b/sv-parser-parser/src/lib.rs index 72f0790..5e135a6 100644 --- a/sv-parser-parser/src/lib.rs +++ b/sv-parser-parser/src/lib.rs @@ -72,21 +72,21 @@ impl HasTracableInfo for SpanInfo { } } -impl HasExtraState for SpanInfo { - fn get_extra_state(&self) -> RecursiveInfo { - self.recursive_info - } -} -//impl HasExtraState<()> for SpanInfo { -// fn get_extra_state(&self) -> () { -// () +//impl HasExtraState for SpanInfo { +// fn get_extra_state(&self) -> RecursiveInfo { +// self.recursive_info // } //} +impl HasExtraState<()> for SpanInfo { + fn get_extra_state(&self) -> () { + () + } +} // ----------------------------------------------------------------------------- -nom_packrat::storage!(AnyNode, RecursiveInfo); -//nom_packrat::storage!(AnyNode); +//nom_packrat::storage!(AnyNode, RecursiveInfo); +nom_packrat::storage!(AnyNode); pub fn parse_sv(s: &str) -> Result { let s = Span::new_extra(s, SpanInfo::default()); diff --git a/sv-parser-parser/src/primitive_instances/primitive_gate_and_switch_types.rs b/sv-parser-parser/src/primitive_instances/primitive_gate_and_switch_types.rs index 722ae94..aa58dd3 100644 --- a/sv-parser-parser/src/primitive_instances/primitive_gate_and_switch_types.rs +++ b/sv-parser-parser/src/primitive_instances/primitive_gate_and_switch_types.rs @@ -3,12 +3,14 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn cmos_switchtype(s: Span) -> IResult { let (s, a) = alt((keyword("cmos"), keyword("rcmos")))(s)?; Ok((s, CmosSwitchtype { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn enable_gatetype(s: Span) -> IResult { let (s, a) = alt(( keyword("bufif0"), @@ -20,6 +22,7 @@ pub(crate) fn enable_gatetype(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn mos_switchtype(s: Span) -> IResult { let (s, a) = alt(( keyword("nmos"), @@ -31,6 +34,7 @@ pub(crate) fn mos_switchtype(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn n_input_gatetype(s: Span) -> IResult { let (s, a) = alt(( keyword("and"), @@ -44,12 +48,14 @@ pub(crate) fn n_input_gatetype(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn n_output_gatetype(s: Span) -> IResult { let (s, a) = alt((keyword("buf"), keyword("not")))(s)?; Ok((s, NOutputGatetype { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn pass_en_switchtype(s: Span) -> IResult { let (s, a) = alt(( keyword("tranif0"), @@ -61,6 +67,7 @@ pub(crate) fn pass_en_switchtype(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn pass_switchtype(s: Span) -> IResult { let (s, a) = alt((keyword("tran"), keyword("rtran")))(s)?; Ok((s, PassSwitchtype { nodes: (a,) })) diff --git a/sv-parser-parser/src/primitive_instances/primitive_instantiation_and_instances.rs b/sv-parser-parser/src/primitive_instances/primitive_instantiation_and_instances.rs index 517d331..281e79a 100644 --- a/sv-parser-parser/src/primitive_instances/primitive_instantiation_and_instances.rs +++ b/sv-parser-parser/src/primitive_instances/primitive_instantiation_and_instances.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn gate_instantiation(s: Span) -> IResult { alt(( gate_instantiation_cmos, @@ -18,6 +19,7 @@ pub(crate) fn gate_instantiation(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn gate_instantiation_cmos(s: Span) -> IResult { let (s, a) = cmos_switchtype(s)?; let (s, b) = opt(delay3)(s)?; @@ -32,6 +34,7 @@ pub(crate) fn gate_instantiation_cmos(s: Span) -> IResult IResult { let (s, a) = enable_gatetype(s)?; let (s, b) = opt(drive_strength)(s)?; @@ -47,6 +50,7 @@ pub(crate) fn gate_instantiation_enable(s: Span) -> IResult IResult { let (s, a) = mos_switchtype(s)?; let (s, b) = opt(delay3)(s)?; @@ -61,6 +65,7 @@ pub(crate) fn gate_instantiation_mos(s: Span) -> IResult IResult { let (s, a) = n_input_gatetype(s)?; let (s, b) = opt(drive_strength)(s)?; @@ -76,6 +81,7 @@ pub(crate) fn gate_instantiation_n_input(s: Span) -> IResult IResult { let (s, a) = n_output_gatetype(s)?; let (s, b) = opt(drive_strength)(s)?; @@ -91,6 +97,7 @@ pub(crate) fn gate_instantiation_n_output(s: Span) -> IResult IResult { let (s, a) = pass_en_switchtype(s)?; let (s, b) = opt(delay2)(s)?; @@ -105,6 +112,7 @@ pub(crate) fn gate_instantiation_pass_en(s: Span) -> IResult IResult { let (s, a) = pass_switchtype(s)?; let (s, b) = list(symbol(","), pass_switch_instance)(s)?; @@ -116,6 +124,7 @@ pub(crate) fn gate_instantiation_pass(s: Span) -> IResult IResult { let (s, a) = keyword("pulldown")(s)?; let (s, b) = opt(pulldown_strength)(s)?; @@ -130,6 +139,7 @@ pub(crate) fn gate_instantiation_pulldown(s: Span) -> IResult IResult { let (s, a) = keyword("pullup")(s)?; let (s, b) = opt(pullup_strength)(s)?; @@ -144,6 +154,7 @@ pub(crate) fn gate_instantiation_pullup(s: Span) -> IResult IResult { let (s, a) = opt(name_of_instance)(s)?; let (s, b) = paren(tuple(( @@ -159,6 +170,7 @@ pub(crate) fn cmos_switch_instance(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn enable_gate_instance(s: Span) -> IResult { let (s, a) = opt(name_of_instance)(s)?; let (s, b) = paren(tuple(( @@ -172,6 +184,7 @@ pub(crate) fn enable_gate_instance(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn mos_switch_instance(s: Span) -> IResult { let (s, a) = opt(name_of_instance)(s)?; let (s, b) = paren(tuple(( @@ -185,6 +198,7 @@ pub(crate) fn mos_switch_instance(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn n_input_gate_instance(s: Span) -> IResult { let (s, a) = opt(name_of_instance)(s)?; let (s, b) = paren(tuple(( @@ -196,6 +210,7 @@ pub(crate) fn n_input_gate_instance(s: Span) -> IResult IResult { let (s, a) = opt(name_of_instance)(s)?; let (s, b) = paren(tuple(( @@ -210,6 +225,7 @@ pub(crate) fn n_output_gate_instance(s: Span) -> IResult IResult { let (s, a) = opt(name_of_instance)(s)?; let (s, b) = paren(tuple((inout_terminal, symbol(","), inout_terminal)))(s)?; @@ -217,6 +233,7 @@ pub(crate) fn pass_switch_instance(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn pass_enable_switch_instance(s: Span) -> IResult { let (s, a) = opt(name_of_instance)(s)?; let (s, b) = paren(tuple(( @@ -230,6 +247,7 @@ pub(crate) fn pass_enable_switch_instance(s: Span) -> IResult IResult { let (s, a) = opt(name_of_instance)(s)?; let (s, b) = paren(output_terminal)(s)?; diff --git a/sv-parser-parser/src/primitive_instances/primitive_strengths.rs b/sv-parser-parser/src/primitive_instances/primitive_strengths.rs index 778c7c0..b5e59a5 100644 --- a/sv-parser-parser/src/primitive_instances/primitive_strengths.rs +++ b/sv-parser-parser/src/primitive_instances/primitive_strengths.rs @@ -3,11 +3,13 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn pulldown_strength(s: Span) -> IResult { alt((pulldown_strength01, pulldown_strength10, pulldown_strength0))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn pulldown_strength01(s: Span) -> IResult { let (s, a) = paren(triple(strength0, symbol(","), strength1))(s)?; Ok(( @@ -17,6 +19,7 @@ pub(crate) fn pulldown_strength01(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn pulldown_strength10(s: Span) -> IResult { let (s, a) = paren(triple(strength1, symbol(","), strength0))(s)?; Ok(( @@ -26,6 +29,7 @@ pub(crate) fn pulldown_strength10(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn pulldown_strength0(s: Span) -> IResult { let (s, a) = paren(strength0)(s)?; Ok(( @@ -35,11 +39,13 @@ pub(crate) fn pulldown_strength0(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn pullup_strength(s: Span) -> IResult { alt((pullup_strength01, pullup_strength10, pullup_strength1))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn pullup_strength01(s: Span) -> IResult { let (s, a) = paren(triple(strength0, symbol(","), strength1))(s)?; Ok(( @@ -49,6 +55,7 @@ pub(crate) fn pullup_strength01(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn pullup_strength10(s: Span) -> IResult { let (s, a) = paren(triple(strength1, symbol(","), strength0))(s)?; Ok(( @@ -58,6 +65,7 @@ pub(crate) fn pullup_strength10(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn pullup_strength1(s: Span) -> IResult { let (s, a) = paren(strength1)(s)?; Ok(( diff --git a/sv-parser-parser/src/primitive_instances/primitive_terminals.rs b/sv-parser-parser/src/primitive_instances/primitive_terminals.rs index 117cf2c..001568a 100644 --- a/sv-parser-parser/src/primitive_instances/primitive_terminals.rs +++ b/sv-parser-parser/src/primitive_instances/primitive_terminals.rs @@ -3,36 +3,42 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn enable_terminal(s: Span) -> IResult { let (s, a) = expression(s)?; Ok((s, EnableTerminal { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn inout_terminal(s: Span) -> IResult { let (s, a) = net_lvalue(s)?; Ok((s, InoutTerminal { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn input_terminal(s: Span) -> IResult { let (s, a) = expression(s)?; Ok((s, InputTerminal { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn ncontrol_terminal(s: Span) -> IResult { let (s, a) = expression(s)?; Ok((s, NcontrolTerminal { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn output_terminal(s: Span) -> IResult { let (s, a) = net_lvalue(s)?; Ok((s, OutputTerminal { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn pcontrol_terminal(s: Span) -> IResult { let (s, a) = expression(s)?; Ok((s, PcontrolTerminal { nodes: (a,) })) diff --git a/sv-parser-parser/src/source_text/checker_items.rs b/sv-parser-parser/src/source_text/checker_items.rs index 2b8a2b4..ac82983 100644 --- a/sv-parser-parser/src/source_text/checker_items.rs +++ b/sv-parser-parser/src/source_text/checker_items.rs @@ -3,12 +3,14 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn checker_port_list(s: Span) -> IResult { let (s, a) = list(symbol(","), checker_port_item)(s)?; Ok((s, CheckerPortList { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn checker_port_item(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = opt(checker_port_direction)(s)?; @@ -25,6 +27,7 @@ pub(crate) fn checker_port_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn checker_port_direction(s: Span) -> IResult { alt(( map(keyword("input"), |x| { @@ -37,6 +40,7 @@ pub(crate) fn checker_port_direction(s: Span) -> IResult IResult { alt(( map(checker_or_generate_item_declaration, |x| { @@ -64,6 +68,7 @@ pub(crate) fn checker_or_generate_item(s: Span) -> IResult IResult { @@ -96,6 +101,7 @@ pub(crate) fn checker_or_generate_item_declaration( } #[tracable_parser] +#[packrat_parser] pub(crate) fn checker_or_generate_item_declaration_data( s: Span, ) -> IResult { @@ -110,12 +116,14 @@ pub(crate) fn checker_or_generate_item_declaration_data( } #[tracable_parser] +#[packrat_parser] pub(crate) fn rand(s: Span) -> IResult { let (s, a) = keyword("rand")(s)?; Ok((s, Rand { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn checker_or_generate_item_declaration_clocking( s: Span, ) -> IResult { @@ -134,6 +142,7 @@ pub(crate) fn checker_or_generate_item_declaration_clocking( } #[tracable_parser] +#[packrat_parser] pub(crate) fn checker_or_generate_item_declaration_disable( s: Span, ) -> IResult { @@ -153,6 +162,7 @@ pub(crate) fn checker_or_generate_item_declaration_disable( } #[tracable_parser] +#[packrat_parser] pub(crate) fn checker_generate_item(s: Span) -> IResult { alt(( map(loop_generate_construct, |x| { diff --git a/sv-parser-parser/src/source_text/class_items.rs b/sv-parser-parser/src/source_text/class_items.rs index 7a38300..2155c5f 100644 --- a/sv-parser-parser/src/source_text/class_items.rs +++ b/sv-parser-parser/src/source_text/class_items.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn class_item(s: Span) -> IResult { alt(( class_item_property, @@ -21,6 +22,7 @@ pub(crate) fn class_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_item_property(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = class_property(s)?; @@ -31,6 +33,7 @@ pub(crate) fn class_item_property(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_item_method(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = class_method(s)?; @@ -41,6 +44,7 @@ pub(crate) fn class_item_method(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_item_constraint(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = class_constraint(s)?; @@ -51,6 +55,7 @@ pub(crate) fn class_item_constraint(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_item_declaration(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = class_declaration(s)?; @@ -61,6 +66,7 @@ pub(crate) fn class_item_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_item_covergroup(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = covergroup_declaration(s)?; @@ -71,11 +77,13 @@ pub(crate) fn class_item_covergroup(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_property(s: Span) -> IResult { alt((class_property_non_const, class_property_const))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_property_non_const(s: Span) -> IResult { let (s, a) = many0(property_qualifier)(s)?; let (s, b) = data_declaration(s)?; @@ -86,6 +94,7 @@ pub(crate) fn class_property_non_const(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_property_const(s: Span) -> IResult { let (s, a) = keyword("const")(s)?; let (s, b) = many0(class_item_qualifier)(s)?; @@ -102,6 +111,7 @@ pub(crate) fn class_property_const(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_method(s: Span) -> IResult { alt(( class_method_task, @@ -114,6 +124,7 @@ pub(crate) fn class_method(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_method_task(s: Span) -> IResult { let (s, a) = many0(method_qualifier)(s)?; let (s, b) = task_declaration(s)?; @@ -124,6 +135,7 @@ pub(crate) fn class_method_task(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_method_function(s: Span) -> IResult { let (s, a) = many0(method_qualifier)(s)?; let (s, b) = function_declaration(s)?; @@ -134,6 +146,7 @@ pub(crate) fn class_method_function(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_method_pure_virtual(s: Span) -> IResult { let (s, a) = keyword("pure")(s)?; let (s, b) = keyword("virtual")(s)?; @@ -149,6 +162,7 @@ pub(crate) fn class_method_pure_virtual(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_method_extern_method(s: Span) -> IResult { let (s, a) = keyword("extern")(s)?; let (s, b) = many0(method_qualifier)(s)?; @@ -163,6 +177,7 @@ pub(crate) fn class_method_extern_method(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_method_constructor(s: Span) -> IResult { let (s, a) = many0(method_qualifier)(s)?; let (s, b) = class_constructor_declaration(s)?; @@ -173,6 +188,7 @@ pub(crate) fn class_method_constructor(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_method_extern_constructor(s: Span) -> IResult { let (s, a) = keyword("extern")(s)?; let (s, b) = many0(method_qualifier)(s)?; @@ -184,6 +200,7 @@ pub(crate) fn class_method_extern_constructor(s: Span) -> IResult IResult { let (s, a) = keyword("function")(s)?; let (s, b) = keyword("new")(s)?; @@ -198,6 +215,7 @@ pub(crate) fn class_constructor_prototype(s: Span) -> IResult IResult { alt(( map(constraint_prototype, |x| { @@ -210,6 +228,7 @@ pub(crate) fn class_constraint(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_item_qualifier(s: Span) -> IResult { alt(( map(keyword("static"), |x| { @@ -223,6 +242,7 @@ pub(crate) fn class_item_qualifier(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn property_qualifier(s: Span) -> IResult { alt(( map(random_qualifier, |x| { @@ -235,6 +255,7 @@ pub(crate) fn property_qualifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn random_qualifier(s: Span) -> IResult { alt(( map(keyword("randc"), |x| RandomQualifier::Randc(Box::new(x))), @@ -243,6 +264,7 @@ pub(crate) fn random_qualifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn method_qualifier(s: Span) -> IResult { alt(( map(pair(keyword("pure"), keyword("virtual")), |x| { @@ -258,6 +280,7 @@ pub(crate) fn method_qualifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn method_prototype(s: Span) -> IResult { alt(( map(task_prototype, |x| { @@ -270,6 +293,7 @@ pub(crate) fn method_prototype(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_constructor_declaration(s: Span) -> IResult { let (s, a) = keyword("function")(s)?; let (s, b) = opt(class_scope)(s)?; @@ -296,6 +320,7 @@ pub(crate) fn class_constructor_declaration(s: Span) -> IResult IResult { let (s, a) = keyword("new")(s)?; Ok((s, New { nodes: (a,) })) diff --git a/sv-parser-parser/src/source_text/configuration_source_text.rs b/sv-parser-parser/src/source_text/configuration_source_text.rs index f63cee9..996ba1c 100644 --- a/sv-parser-parser/src/source_text/configuration_source_text.rs +++ b/sv-parser-parser/src/source_text/configuration_source_text.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn config_declaration(s: Span) -> IResult { let (s, a) = keyword("config")(s)?; let (s, b) = config_identifier(s)?; @@ -21,6 +22,7 @@ pub(crate) fn config_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn design_statement(s: Span) -> IResult { let (s, a) = keyword("design")(s)?; let (s, b) = many0(pair( @@ -32,6 +34,7 @@ pub(crate) fn design_statement(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn config_rule_statement(s: Span) -> IResult { alt(( config_rule_statement_default, @@ -43,6 +46,7 @@ pub(crate) fn config_rule_statement(s: Span) -> IResult IResult { let (s, a) = default_clause(s)?; let (s, b) = liblist_clause(s)?; @@ -54,6 +58,7 @@ pub(crate) fn config_rule_statement_default(s: Span) -> IResult IResult { let (s, a) = inst_clause(s)?; let (s, b) = liblist_clause(s)?; @@ -65,6 +70,7 @@ pub(crate) fn config_rule_statement_inst_lib(s: Span) -> IResult IResult { let (s, a) = inst_clause(s)?; let (s, b) = use_clause(s)?; @@ -76,6 +82,7 @@ pub(crate) fn config_rule_statement_inst_use(s: Span) -> IResult IResult { let (s, a) = cell_clause(s)?; let (s, b) = liblist_clause(s)?; @@ -87,6 +94,7 @@ pub(crate) fn config_rule_statement_cell_lib(s: Span) -> IResult IResult { let (s, a) = cell_clause(s)?; let (s, b) = use_clause(s)?; @@ -98,12 +106,14 @@ pub(crate) fn config_rule_statement_cell_use(s: Span) -> IResult IResult { let (s, a) = keyword("default")(s)?; Ok((s, DefaultClause { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn inst_clause(s: Span) -> IResult { let (s, a) = keyword("instance")(s)?; let (s, b) = inst_name(s)?; @@ -111,6 +121,7 @@ pub(crate) fn inst_clause(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn inst_name(s: Span) -> IResult { let (s, a) = topmodule_identifier(s)?; let (s, b) = many0(pair(symbol("."), instance_identifier))(s)?; @@ -118,6 +129,7 @@ pub(crate) fn inst_name(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn cell_clause(s: Span) -> IResult { let (s, a) = keyword("cell")(s)?; let (s, b) = opt(pair(library_identifier, symbol(".")))(s)?; @@ -126,6 +138,7 @@ pub(crate) fn cell_clause(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn liblist_clause(s: Span) -> IResult { let (s, a) = keyword("liblist")(s)?; let (s, b) = many0(library_identifier)(s)?; @@ -133,11 +146,13 @@ pub(crate) fn liblist_clause(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn use_clause(s: Span) -> IResult { alt((use_clause_cell, use_clause_named, use_clause_cell_named))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn use_clause_cell(s: Span) -> IResult { let (s, a) = keyword("use")(s)?; let (s, b) = opt(pair(library_identifier, symbol(".")))(s)?; @@ -152,6 +167,7 @@ pub(crate) fn use_clause_cell(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn use_clause_named(s: Span) -> IResult { let (s, a) = keyword("use")(s)?; let (s, b) = list(symbol(","), named_parameter_assignment)(s)?; @@ -163,6 +179,7 @@ pub(crate) fn use_clause_named(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn use_clause_cell_named(s: Span) -> IResult { let (s, a) = keyword("use")(s)?; let (s, b) = opt(pair(library_identifier, symbol(".")))(s)?; @@ -178,6 +195,7 @@ pub(crate) fn use_clause_cell_named(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn config(s: Span) -> IResult { let (s, a) = keyword("config")(s)?; Ok((s, Config { nodes: (a,) })) diff --git a/sv-parser-parser/src/source_text/constraints.rs b/sv-parser-parser/src/source_text/constraints.rs index 8c96863..ca5cabd 100644 --- a/sv-parser-parser/src/source_text/constraints.rs +++ b/sv-parser-parser/src/source_text/constraints.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn constraint_declaration(s: Span) -> IResult { let (s, a) = opt(r#static)(s)?; let (s, b) = keyword("constraint")(s)?; @@ -17,18 +18,21 @@ pub(crate) fn constraint_declaration(s: Span) -> IResult IResult { let (s, a) = keyword("static")(s)?; Ok((s, Static { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn constraint_block(s: Span) -> IResult { let (s, a) = brace(many0(constraint_block_item))(s)?; Ok((s, ConstraintBlock { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn constraint_block_item(s: Span) -> IResult { alt(( constraint_block_item_solve, @@ -39,6 +43,7 @@ pub(crate) fn constraint_block_item(s: Span) -> IResult IResult { let (s, a) = keyword("solve")(s)?; let (s, b) = solve_before_list(s)?; @@ -54,12 +59,14 @@ pub(crate) fn constraint_block_item_solve(s: Span) -> IResult IResult { let (s, a) = list(symbol(","), constraint_primary)(s)?; Ok((s, SolveBeforeList { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn constraint_primary(s: Span) -> IResult { let (s, a) = opt(implicit_class_handle_or_class_scope)(s)?; let (s, b) = hierarchical_identifier(s)?; @@ -68,6 +75,7 @@ pub(crate) fn constraint_primary(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn constraint_expression(s: Span) -> IResult { alt(( constraint_expression_expression, @@ -83,6 +91,7 @@ pub(crate) fn constraint_expression(s: Span) -> IResult IResult { let (s, a) = opt(soft)(s)?; let (s, b) = expression_or_dist(s)?; @@ -96,6 +105,7 @@ pub(crate) fn constraint_expression_expression(s: Span) -> IResult IResult { let (s, a) = keyword("soft")(s)?; Ok((s, Soft { nodes: (a,) })) @@ -103,6 +113,7 @@ pub(crate) fn soft(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn constraint_expression_arrow(s: Span) -> IResult { let (s, a) = expression(s)?; let (s, b) = symbol("->")(s)?; @@ -114,6 +125,7 @@ pub(crate) fn constraint_expression_arrow(s: Span) -> IResult IResult { let (s, a) = keyword("if")(s)?; let (s, b) = paren(expression)(s)?; @@ -128,6 +140,7 @@ pub(crate) fn constraint_expression_if(s: Span) -> IResult IResult { let (s, a) = keyword("foreach")(s)?; let (s, b) = paren(pair( @@ -142,6 +155,7 @@ pub(crate) fn constraint_expression_foreach(s: Span) -> IResult IResult { let (s, a) = keyword("disable")(s)?; let (s, b) = keyword("soft")(s)?; @@ -156,6 +170,7 @@ pub(crate) fn constraint_expression_disable(s: Span) -> IResult IResult { let (s, a) = keyword("unique")(s)?; let (s, b) = brace(open_range_list)(s)?; @@ -163,6 +178,7 @@ pub(crate) fn uniqueness_constraint(s: Span) -> IResult IResult { alt(( map(constraint_expression, |x| { @@ -173,6 +189,7 @@ pub(crate) fn constraint_set(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn constraint_set_brace(s: Span) -> IResult { let (s, a) = brace(many0(constraint_expression))(s)?; Ok(( @@ -183,6 +200,7 @@ pub(crate) fn constraint_set_brace(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn dist_list(s: Span) -> IResult { let (s, a) = list(symbol(","), dist_item)(s)?; Ok((s, DistList { nodes: (a,) })) @@ -190,6 +208,7 @@ pub(crate) fn dist_list(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn dist_item(s: Span) -> IResult { let (s, a) = value_range(s)?; let (s, b) = opt(dist_weight)(s)?; @@ -197,11 +216,13 @@ pub(crate) fn dist_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn dist_weight(s: Span) -> IResult { alt((dist_weight_equal, dist_weight_divide))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn dist_weight_equal(s: Span) -> IResult { let (s, a) = symbol(":=")(s)?; let (s, b) = expression(s)?; @@ -212,6 +233,7 @@ pub(crate) fn dist_weight_equal(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn dist_weight_divide(s: Span) -> IResult { let (s, a) = symbol(":/")(s)?; let (s, b) = expression(s)?; @@ -222,6 +244,7 @@ pub(crate) fn dist_weight_divide(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn constraint_prototype(s: Span) -> IResult { let (s, a) = opt(constraint_prototype_qualifier)(s)?; let (s, b) = opt(r#static)(s)?; @@ -237,6 +260,7 @@ pub(crate) fn constraint_prototype(s: Span) -> IResult IResult { @@ -251,6 +275,7 @@ pub(crate) fn constraint_prototype_qualifier( } #[tracable_parser] +#[packrat_parser] pub(crate) fn extern_constraint_declaration(s: Span) -> IResult { let (s, a) = opt(r#static)(s)?; let (s, b) = keyword("constraint")(s)?; @@ -266,6 +291,7 @@ pub(crate) fn extern_constraint_declaration(s: Span) -> IResult IResult { let (s, a) = list(symbol(","), identifier)(s)?; Ok((s, IdentifierList { nodes: (a,) })) diff --git a/sv-parser-parser/src/source_text/interface_items.rs b/sv-parser-parser/src/source_text/interface_items.rs index 13503ba..e7085b4 100644 --- a/sv-parser-parser/src/source_text/interface_items.rs +++ b/sv-parser-parser/src/source_text/interface_items.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn interface_or_generate_item(s: Span) -> IResult { alt(( interface_or_generate_item_module, @@ -12,6 +13,7 @@ pub(crate) fn interface_or_generate_item(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = module_common_item(s)?; @@ -22,6 +24,7 @@ pub(crate) fn interface_or_generate_item_module(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = extern_tf_declaration(s)?; @@ -32,11 +35,13 @@ pub(crate) fn interface_or_generate_item_extern(s: Span) -> IResult IResult { alt((extern_tf_declaration_method, extern_tf_declaration_task))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn extern_tf_declaration_method(s: Span) -> IResult { let (s, a) = keyword("extern")(s)?; let (s, b) = method_prototype(s)?; @@ -48,6 +53,7 @@ pub(crate) fn extern_tf_declaration_method(s: Span) -> IResult IResult { let (s, a) = keyword("extern")(s)?; let (s, b) = keyword("forkjoin")(s)?; @@ -62,6 +68,7 @@ pub(crate) fn extern_tf_declaration_task(s: Span) -> IResult IResult { alt(( map(pair(port_declaration, symbol(";")), |x| { @@ -74,6 +81,7 @@ pub(crate) fn interface_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn non_port_interface_item(s: Span) -> IResult { alt(( map(generate_region, |x| { diff --git a/sv-parser-parser/src/source_text/library_source_text.rs b/sv-parser-parser/src/source_text/library_source_text.rs index 8b5b147..75e0352 100644 --- a/sv-parser-parser/src/source_text/library_source_text.rs +++ b/sv-parser-parser/src/source_text/library_source_text.rs @@ -3,12 +3,14 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn library_text(s: Span) -> IResult { let (s, a) = many0(library_description)(s)?; Ok((s, LibraryText { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn library_description(s: Span) -> IResult { alt(( map(library_declaration, |x| { @@ -25,6 +27,7 @@ pub(crate) fn library_description(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn library_declaration(s: Span) -> IResult { let (s, a) = keyword("library")(s)?; let (s, b) = library_identifier(s)?; @@ -40,6 +43,7 @@ pub(crate) fn library_declaration(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn include_statement(s: Span) -> IResult { let (s, a) = keyword("include")(s)?; let (s, b) = file_path_spec(s)?; @@ -48,6 +52,7 @@ pub(crate) fn include_statement(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn file_path_spec(s: Span) -> IResult { alt(( map(string_literal, |x| FilePathSpec::Literal(x)), @@ -56,6 +61,7 @@ pub(crate) fn file_path_spec(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn file_path_spec_non_literal(s: Span) -> IResult { let (s, a) = ws(map(is_not(",; "), |x| into_locate(x)))(s)?; Ok(( diff --git a/sv-parser-parser/src/source_text/module_items.rs b/sv-parser-parser/src/source_text/module_items.rs index 6129e6c..cd4e071 100644 --- a/sv-parser-parser/src/source_text/module_items.rs +++ b/sv-parser-parser/src/source_text/module_items.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn elaboration_system_task(s: Span) -> IResult { alt(( elaboration_system_task_fatal, @@ -13,6 +14,7 @@ pub(crate) fn elaboration_system_task(s: Span) -> IResult IResult { let (s, a) = keyword("$fatal")(s)?; let (s, b) = opt(paren(pair( @@ -27,6 +29,7 @@ pub(crate) fn elaboration_system_task_fatal(s: Span) -> IResult IResult { let (s, a) = keyword("$error")(s)?; let (s, b) = opt(paren(opt(list_of_arguments)))(s)?; @@ -38,6 +41,7 @@ pub(crate) fn elaboration_system_task_error(s: Span) -> IResult IResult { let (s, a) = keyword("$warning")(s)?; let (s, b) = opt(paren(opt(list_of_arguments)))(s)?; @@ -51,6 +55,7 @@ pub(crate) fn elaboration_system_task_warning(s: Span) -> IResult IResult { let (s, a) = keyword("$info")(s)?; let (s, b) = opt(paren(opt(list_of_arguments)))(s)?; @@ -62,6 +67,7 @@ pub(crate) fn elaboration_system_task_info(s: Span) -> IResult IResult { alt(( map(symbol("0"), |x| FinishNumber::Zero(Box::new(x))), @@ -71,6 +77,7 @@ pub(crate) fn finish_number(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn module_common_item(s: Span) -> IResult { alt(( map(module_or_generate_item_declaration, |x| { @@ -114,6 +121,7 @@ pub(crate) fn module_common_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn module_item(s: Span) -> IResult { alt(( map(pair(port_declaration, symbol(";")), |x| { @@ -126,6 +134,7 @@ pub(crate) fn module_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn module_or_generate_item(s: Span) -> IResult { alt(( module_or_generate_item_parameter, @@ -137,6 +146,7 @@ pub(crate) fn module_or_generate_item(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = parameter_override(s)?; @@ -147,6 +157,7 @@ pub(crate) fn module_or_generate_item_parameter(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = gate_instantiation(s)?; @@ -157,6 +168,7 @@ pub(crate) fn module_or_generate_item_gate(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = udp_instantiation(s)?; @@ -167,6 +179,7 @@ pub(crate) fn module_or_generate_item_udp(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = module_instantiation(s)?; @@ -178,6 +191,7 @@ pub(crate) fn module_or_generate_item_module(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = module_common_item(s)?; @@ -190,6 +204,7 @@ pub(crate) fn module_or_generate_item_module_item(s: Span) -> IResult IResult { @@ -209,6 +224,7 @@ pub(crate) fn module_or_generate_item_declaration( } #[tracable_parser] +#[packrat_parser] pub(crate) fn module_or_generate_item_declaration_clocking( s: Span, ) -> IResult { @@ -227,6 +243,7 @@ pub(crate) fn module_or_generate_item_declaration_clocking( } #[tracable_parser] +#[packrat_parser] pub(crate) fn module_or_generate_item_declaration_disable( s: Span, ) -> IResult { @@ -246,6 +263,7 @@ pub(crate) fn module_or_generate_item_declaration_disable( } #[tracable_parser] +#[packrat_parser] pub(crate) fn non_port_module_item(s: Span) -> IResult { alt(( map(generate_region, |x| { @@ -274,6 +292,7 @@ pub(crate) fn non_port_module_item(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn non_port_module_item_specparam(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = specparam_declaration(s)?; @@ -284,6 +303,7 @@ pub(crate) fn non_port_module_item_specparam(s: Span) -> IResult IResult { let (s, a) = keyword("defparam")(s)?; let (s, b) = list_of_defparam_assignments(s)?; @@ -292,11 +312,13 @@ pub(crate) fn parameter_override(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn bind_directive(s: Span) -> IResult { alt((bind_directive_scope, bind_directive_instance))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn bind_directive_scope(s: Span) -> IResult { let (s, a) = keyword("bind")(s)?; let (s, b) = bind_target_scope(s)?; @@ -312,6 +334,7 @@ pub(crate) fn bind_directive_scope(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn bind_directive_instance(s: Span) -> IResult { let (s, a) = keyword("bind")(s)?; let (s, b) = bind_target_instance(s)?; @@ -326,6 +349,7 @@ pub(crate) fn bind_directive_instance(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn bind_target_scope(s: Span) -> IResult { alt(( map(module_identifier, |x| { @@ -338,6 +362,7 @@ pub(crate) fn bind_target_scope(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn bind_target_instance(s: Span) -> IResult { let (s, a) = hierarchical_identifier(s)?; let (s, b) = constant_bit_select(s)?; @@ -345,12 +370,14 @@ pub(crate) fn bind_target_instance(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn bind_target_instance_list(s: Span) -> IResult { let (s, a) = list(symbol(","), bind_target_instance)(s)?; Ok((s, BindTargetInstanceList { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn bind_instantiation(s: Span) -> IResult { alt(( map(program_instantiation, |x| { diff --git a/sv-parser-parser/src/source_text/module_parameters_and_ports.rs b/sv-parser-parser/src/source_text/module_parameters_and_ports.rs index 2dc45a0..bf8395c 100644 --- a/sv-parser-parser/src/source_text/module_parameters_and_ports.rs +++ b/sv-parser-parser/src/source_text/module_parameters_and_ports.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn parameter_port_list(s: Span) -> IResult { alt(( parameter_port_list_assignment, @@ -12,6 +13,7 @@ pub(crate) fn parameter_port_list(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn parameter_port_list_assignment(s: Span) -> IResult { let (s, a) = symbol("#")(s)?; let (s, b) = paren(pair( @@ -25,6 +27,7 @@ pub(crate) fn parameter_port_list_assignment(s: Span) -> IResult IResult { let (s, a) = symbol("#")(s)?; let (s, b) = paren(list(symbol(","), parameter_port_declaration))(s)?; @@ -35,6 +38,7 @@ pub(crate) fn parameter_port_list_declaration(s: Span) -> IResult IResult { let (s, a) = symbol("#")(s)?; let (s, b) = symbol("(")(s)?; @@ -43,6 +47,7 @@ pub(crate) fn parameter_port_list_empty(s: Span) -> IResult IResult { alt(( map(parameter_declaration, |x| { @@ -57,6 +62,7 @@ pub(crate) fn parameter_port_declaration(s: Span) -> IResult IResult { @@ -71,6 +77,7 @@ pub(crate) fn parameter_port_declaration_param_list( } #[tracable_parser] +#[packrat_parser] pub(crate) fn parameter_port_declaration_type_list( s: Span, ) -> IResult { @@ -85,12 +92,14 @@ pub(crate) fn parameter_port_declaration_type_list( } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_ports(s: Span) -> IResult { let (s, a) = paren(list(symbol(","), port))(s)?; Ok((s, ListOfPorts { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_port_declarations(s: Span) -> IResult { let (s, a) = paren(opt(list( symbol(","), @@ -100,6 +109,7 @@ pub(crate) fn list_of_port_declarations(s: Span) -> IResult IResult { alt(( port_declaration_inout, @@ -111,6 +121,7 @@ pub(crate) fn port_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn port_declaration_inout(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = inout_declaration(s)?; @@ -121,6 +132,7 @@ pub(crate) fn port_declaration_inout(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn port_declaration_input(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = input_declaration(s)?; @@ -131,6 +143,7 @@ pub(crate) fn port_declaration_input(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn port_declaration_output(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = output_declaration(s)?; @@ -141,6 +154,7 @@ pub(crate) fn port_declaration_output(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn port_declaration_ref(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = ref_declaration(s)?; @@ -151,6 +165,7 @@ pub(crate) fn port_declaration_ref(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn port_declaration_interface(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = interface_port_declaration(s)?; @@ -161,18 +176,21 @@ pub(crate) fn port_declaration_interface(s: Span) -> IResult IResult { alt((port_non_named, port_named))(s) } #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn port_non_named(s: Span) -> IResult { let (s, a) = opt(port_expression)(s)?; Ok((s, Port::NonNamed(Box::new(PortNonNamed { nodes: (a,) })))) } #[tracable_parser] +#[packrat_parser] pub(crate) fn port_named(s: Span) -> IResult { let (s, a) = symbol(".")(s)?; let (s, b) = port_identifier(s)?; @@ -181,6 +199,7 @@ pub(crate) fn port_named(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn port_expression(s: Span) -> IResult { alt(( map(port_reference, |x| { @@ -191,6 +210,7 @@ pub(crate) fn port_expression(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn port_expressio_named(s: Span) -> IResult { let (s, a) = brace(list(symbol(","), port_reference))(s)?; Ok(( @@ -200,6 +220,7 @@ pub(crate) fn port_expressio_named(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn port_reference(s: Span) -> IResult { let (s, a) = port_identifier(s)?; let (s, b) = constant_select(s)?; @@ -207,6 +228,7 @@ pub(crate) fn port_reference(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn port_direction(s: Span) -> IResult { alt(( map(keyword("input"), |x| PortDirection::Input(Box::new(x))), @@ -217,6 +239,7 @@ pub(crate) fn port_direction(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn net_port_header(s: Span) -> IResult { let (s, a) = opt(port_direction)(s)?; let (s, b) = net_port_type(s)?; @@ -224,6 +247,7 @@ pub(crate) fn net_port_header(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn variable_port_header(s: Span) -> IResult { let (s, a) = opt(port_direction)(s)?; let (s, b) = variable_port_type(s)?; @@ -231,6 +255,7 @@ pub(crate) fn variable_port_header(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn interface_port_header(s: Span) -> IResult { alt(( interface_port_header_identifier, @@ -239,6 +264,7 @@ pub(crate) fn interface_port_header(s: Span) -> IResult IResult { let (s, a) = interface_identifier(s)?; let (s, b) = opt(pair(symbol("."), modport_identifier))(s)?; @@ -249,6 +275,7 @@ pub(crate) fn interface_port_header_identifier(s: Span) -> IResult IResult { let (s, a) = keyword("interface")(s)?; let (s, b) = opt(pair(symbol("."), modport_identifier))(s)?; @@ -259,6 +286,7 @@ pub(crate) fn interface_port_header_interface(s: Span) -> IResult IResult { alt(( ansi_port_declaration_net, @@ -268,6 +296,7 @@ pub(crate) fn ansi_port_declaration(s: Span) -> IResult IResult { let (s, a) = opt(net_port_header_or_interface_port_header)(s)?; let (s, b) = port_identifier(s)?; @@ -282,6 +311,7 @@ pub(crate) fn ansi_port_declaration_net(s: Span) -> IResult IResult { @@ -296,6 +326,7 @@ pub(crate) fn net_port_header_or_interface_port_header( } #[tracable_parser] +#[packrat_parser] pub(crate) fn ansi_port_declaration_port(s: Span) -> IResult { let (s, a) = opt(variable_port_header)(s)?; let (s, b) = port_identifier(s)?; @@ -310,6 +341,7 @@ pub(crate) fn ansi_port_declaration_port(s: Span) -> IResult IResult { let (s, a) = opt(port_direction)(s)?; let (s, b) = symbol(".")(s)?; diff --git a/sv-parser-parser/src/source_text/package_items.rs b/sv-parser-parser/src/source_text/package_items.rs index d87b9ab..76647db 100644 --- a/sv-parser-parser/src/source_text/package_items.rs +++ b/sv-parser-parser/src/source_text/package_items.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn package_item(s: Span) -> IResult { alt(( map(package_or_generate_item_declaration, |x| { @@ -21,6 +22,7 @@ pub(crate) fn package_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn package_or_generate_item_declaration( s: Span, ) -> IResult { @@ -74,6 +76,7 @@ pub(crate) fn package_or_generate_item_declaration( } #[tracable_parser] +#[packrat_parser] pub(crate) fn anonymous_program(s: Span) -> IResult { let (s, a) = keyword("program")(s)?; let (s, b) = symbol(";")(s)?; @@ -88,6 +91,7 @@ pub(crate) fn anonymous_program(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn anonymous_program_item(s: Span) -> IResult { alt(( map(task_declaration, |x| { diff --git a/sv-parser-parser/src/source_text/program_items.rs b/sv-parser-parser/src/source_text/program_items.rs index 3830704..6143ba2 100644 --- a/sv-parser-parser/src/source_text/program_items.rs +++ b/sv-parser-parser/src/source_text/program_items.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn program_item(s: Span) -> IResult { alt(( map(pair(port_declaration, symbol(";")), |x| { @@ -15,6 +16,7 @@ pub(crate) fn program_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn non_port_program_item(s: Span) -> IResult { alt(( non_port_program_item_assign, @@ -32,6 +34,7 @@ pub(crate) fn non_port_program_item(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = continuous_assign(s)?; @@ -43,6 +46,7 @@ pub(crate) fn non_port_program_item_assign(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = module_or_generate_item_declaration(s)?; @@ -53,6 +57,7 @@ pub(crate) fn non_port_program_item_module(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = initial_construct(s)?; @@ -63,6 +68,7 @@ pub(crate) fn non_port_program_item_initial(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = final_construct(s)?; @@ -73,6 +79,7 @@ pub(crate) fn non_port_program_item_final(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = concurrent_assertion_item(s)?; @@ -83,6 +90,7 @@ pub(crate) fn non_port_program_item_assertion(s: Span) -> IResult IResult { alt(( map(loop_generate_construct, |x| { diff --git a/sv-parser-parser/src/source_text/system_verilog_source_text.rs b/sv-parser-parser/src/source_text/system_verilog_source_text.rs index 6794f2c..7a7af18 100644 --- a/sv-parser-parser/src/source_text/system_verilog_source_text.rs +++ b/sv-parser-parser/src/source_text/system_verilog_source_text.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn source_text(s: Span) -> IResult { let (s, a) = opt(timeunits_declaration)(s)?; let (s, b) = many0(description)(s)?; @@ -10,6 +11,7 @@ pub(crate) fn source_text(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn description(s: Span) -> IResult { alt(( map(module_declaration, |x| { @@ -40,6 +42,7 @@ pub(crate) fn description(s: Span) -> IResult { #[recursive_parser] #[tracable_parser] +#[packrat_parser] pub(crate) fn description_package_item(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = package_item(s)?; @@ -50,6 +53,7 @@ pub(crate) fn description_package_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn description_bind_directive(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = bind_directive(s)?; @@ -60,6 +64,7 @@ pub(crate) fn description_bind_directive(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn module_nonansi_header(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = module_keyword(s)?; @@ -78,6 +83,7 @@ pub(crate) fn module_nonansi_header(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = module_keyword(s)?; @@ -96,6 +102,7 @@ pub(crate) fn module_ansi_header(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn module_declaration(s: Span) -> IResult { alt(( module_declaration_nonansi, @@ -107,6 +114,7 @@ pub(crate) fn module_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn module_declaration_nonansi(s: Span) -> IResult { let (s, a) = module_nonansi_header(s)?; let (s, b) = opt(timeunits_declaration)(s)?; @@ -122,6 +130,7 @@ pub(crate) fn module_declaration_nonansi(s: Span) -> IResult IResult { let (s, a) = module_ansi_header(s)?; let (s, b) = opt(timeunits_declaration)(s)?; @@ -137,6 +146,7 @@ pub(crate) fn module_declaration_ansi(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = module_keyword(s)?; @@ -157,6 +167,7 @@ pub(crate) fn module_declaration_wildcard(s: Span) -> IResult IResult { let (s, a) = keyword("extern")(s)?; let (s, b) = module_nonansi_header(s)?; @@ -169,6 +180,7 @@ pub(crate) fn module_declaration_extern_nonansi(s: Span) -> IResult IResult { let (s, a) = keyword("extern")(s)?; let (s, b) = module_ansi_header(s)?; @@ -179,6 +191,7 @@ pub(crate) fn module_declaration_extern_ansi(s: Span) -> IResult IResult { alt(( map(keyword("module"), |x| ModuleKeyword::Module(Box::new(x))), @@ -189,6 +202,7 @@ pub(crate) fn module_keyword(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn interface_declaration(s: Span) -> IResult { alt(( interface_declaration_nonansi, @@ -200,6 +214,7 @@ pub(crate) fn interface_declaration(s: Span) -> IResult IResult { let (s, a) = interface_nonansi_header(s)?; let (s, b) = opt(timeunits_declaration)(s)?; @@ -215,6 +230,7 @@ pub(crate) fn interface_declaration_nonansi(s: Span) -> IResult IResult { let (s, a) = interface_ansi_header(s)?; let (s, b) = opt(timeunits_declaration)(s)?; @@ -230,6 +246,7 @@ pub(crate) fn interface_declaration_ansi(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("interface")(s)?; @@ -250,6 +267,7 @@ pub(crate) fn interface_declaration_wildcard(s: Span) -> IResult IResult { let (s, a) = keyword("extern")(s)?; let (s, b) = interface_nonansi_header(s)?; @@ -262,6 +280,7 @@ pub(crate) fn interface_declaration_extern_nonansi(s: Span) -> IResult IResult { let (s, a) = keyword("extern")(s)?; let (s, b) = interface_ansi_header(s)?; @@ -274,6 +293,7 @@ pub(crate) fn interface_declaration_extern_ansi(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("interface")(s)?; @@ -292,6 +312,7 @@ pub(crate) fn interface_nonansi_header(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("interface")(s)?; @@ -310,6 +331,7 @@ pub(crate) fn interface_ansi_header(s: Span) -> IResult IResult { alt(( program_declaration_nonansi, @@ -321,6 +343,7 @@ pub(crate) fn program_declaration(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn program_declaration_nonansi(s: Span) -> IResult { let (s, a) = program_nonansi_header(s)?; let (s, b) = opt(timeunits_declaration)(s)?; @@ -336,6 +359,7 @@ pub(crate) fn program_declaration_nonansi(s: Span) -> IResult IResult { let (s, a) = program_ansi_header(s)?; let (s, b) = opt(timeunits_declaration)(s)?; @@ -351,6 +375,7 @@ pub(crate) fn program_declaration_ansi(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("program")(s)?; @@ -370,6 +395,7 @@ pub(crate) fn program_declaration_wildcard(s: Span) -> IResult IResult { let (s, a) = keyword("extern")(s)?; let (s, b) = program_nonansi_header(s)?; @@ -382,6 +408,7 @@ pub(crate) fn program_declaration_extern_nonansi(s: Span) -> IResult IResult { let (s, a) = keyword("extern")(s)?; let (s, b) = program_ansi_header(s)?; @@ -392,6 +419,7 @@ pub(crate) fn program_declaration_extern_ansi(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("prgogram")(s)?; @@ -410,6 +438,7 @@ pub(crate) fn program_nonansi_header(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("program")(s)?; @@ -428,6 +457,7 @@ pub(crate) fn program_ansi_header(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn checker_declaration(s: Span) -> IResult { let (s, a) = keyword("checker")(s)?; let (s, b) = checker_identifier(s)?; @@ -445,6 +475,7 @@ pub(crate) fn checker_declaration(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn class_declaration(s: Span) -> IResult { let (s, a) = opt(map(keyword("virtual"), |x| Virtual { nodes: (x,) }))(s)?; let (s, b) = keyword("class")(s)?; @@ -473,6 +504,7 @@ pub(crate) fn class_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn interface_class_type(s: Span) -> IResult { let (s, a) = ps_class_identifier(s)?; let (s, b) = opt(parameter_value_assignment)(s)?; @@ -480,6 +512,7 @@ pub(crate) fn interface_class_type(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn interface_class_declaration(s: Span) -> IResult { let (s, a) = keyword("interface")(s)?; let (s, b) = keyword("class")(s)?; @@ -502,6 +535,7 @@ pub(crate) fn interface_class_declaration(s: Span) -> IResult IResult { alt(( map(type_declaration, |x| { @@ -519,6 +553,7 @@ pub(crate) fn interface_class_item(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn interface_class_item_method(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = interface_class_method(s)?; @@ -529,6 +564,7 @@ pub(crate) fn interface_class_item_method(s: Span) -> IResult IResult { let (s, a) = keyword("pure")(s)?; let (s, b) = keyword("virtual")(s)?; @@ -543,6 +579,7 @@ pub(crate) fn interface_class_method(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("package")(s)?; @@ -562,6 +599,7 @@ pub(crate) fn package_declaration(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn timeunits_declaration(s: Span) -> IResult { alt(( timeunits_declaration_timeunit_timeprecision, @@ -572,6 +610,7 @@ pub(crate) fn timeunits_declaration(s: Span) -> IResult IResult { let (s, a) = keyword("timeunit")(s)?; let (s, b) = time_literal(s)?; @@ -586,6 +625,7 @@ pub(crate) fn timeunits_declaration_timeunit(s: Span) -> IResult IResult { let (s, a) = keyword("timeprecision")(s)?; let (s, b) = time_literal(s)?; @@ -599,6 +639,7 @@ pub(crate) fn timeunits_declaration_timeprecision(s: Span) -> IResult IResult { @@ -619,6 +660,7 @@ pub(crate) fn timeunits_declaration_timeunit_timeprecision( } #[tracable_parser] +#[packrat_parser] pub(crate) fn timeunits_declaration_timeprecision_timeunit( s: Span, ) -> IResult { diff --git a/sv-parser-parser/src/specify_section/specify_block_declaration.rs b/sv-parser-parser/src/specify_section/specify_block_declaration.rs index 532aaa0..d47657c 100644 --- a/sv-parser-parser/src/specify_section/specify_block_declaration.rs +++ b/sv-parser-parser/src/specify_section/specify_block_declaration.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn specify_block(s: Span) -> IResult { let (s, a) = keyword("specify")(s)?; let (s, b) = many0(specify_item)(s)?; @@ -11,6 +12,7 @@ pub(crate) fn specify_block(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn specify_item(s: Span) -> IResult { alt(( map(specparam_declaration, |x| { @@ -32,6 +34,7 @@ pub(crate) fn specify_item(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn pulsestyle_declaration(s: Span) -> IResult { let (s, a) = alt(( keyword("pulsestyle_onevent"), @@ -43,6 +46,7 @@ pub(crate) fn pulsestyle_declaration(s: Span) -> IResult IResult { let (s, a) = alt((keyword("showcalcelled"), keyword("noshowcancelled")))(s)?; let (s, b) = list_of_path_outputs(s)?; diff --git a/sv-parser-parser/src/specify_section/specify_block_terminals.rs b/sv-parser-parser/src/specify_section/specify_block_terminals.rs index b609a5a..580b2a0 100644 --- a/sv-parser-parser/src/specify_section/specify_block_terminals.rs +++ b/sv-parser-parser/src/specify_section/specify_block_terminals.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn specify_input_terminal_descriptor( s: Span, ) -> IResult { @@ -12,6 +13,7 @@ pub(crate) fn specify_input_terminal_descriptor( } #[tracable_parser] +#[packrat_parser] pub(crate) fn specify_output_terminal_descriptor( s: Span, ) -> IResult { @@ -21,6 +23,7 @@ pub(crate) fn specify_output_terminal_descriptor( } #[tracable_parser] +#[packrat_parser] pub(crate) fn input_identifier(s: Span) -> IResult { alt(( map(input_port_identifier, |x| { @@ -34,6 +37,7 @@ pub(crate) fn input_identifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn input_identifier_interface(s: Span) -> IResult { let (s, a) = interface_identifier(s)?; let (s, b) = symbol(".")(s)?; @@ -45,6 +49,7 @@ pub(crate) fn input_identifier_interface(s: Span) -> IResult IResult { alt(( map(output_port_identifier, |x| { @@ -58,6 +63,7 @@ pub(crate) fn output_identifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn output_identifier_interface(s: Span) -> IResult { let (s, a) = interface_identifier(s)?; let (s, b) = symbol(".")(s)?; diff --git a/sv-parser-parser/src/specify_section/specify_path_declarations.rs b/sv-parser-parser/src/specify_section/specify_path_declarations.rs index 6065b0b..191c775 100644 --- a/sv-parser-parser/src/specify_section/specify_path_declarations.rs +++ b/sv-parser-parser/src/specify_section/specify_path_declarations.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn path_declaration(s: Span) -> IResult { alt(( map(pair(simple_path_declaration, symbol(";")), |x| { @@ -18,6 +19,7 @@ pub(crate) fn path_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn simple_path_declaration(s: Span) -> IResult { alt(( simple_path_declaration_parallel, @@ -26,6 +28,7 @@ pub(crate) fn simple_path_declaration(s: Span) -> IResult IResult { let (s, a) = parallel_path_description(s)?; let (s, b) = symbol("=")(s)?; @@ -39,6 +42,7 @@ pub(crate) fn simple_path_declaration_parallel(s: Span) -> IResult IResult { let (s, a) = full_path_description(s)?; let (s, b) = symbol("=")(s)?; @@ -50,6 +54,7 @@ pub(crate) fn simple_path_declaration_full(s: Span) -> IResult IResult { let (s, a) = paren(tuple(( specify_input_terminal_descriptor, @@ -61,6 +66,7 @@ pub(crate) fn parallel_path_description(s: Span) -> IResult IResult { let (s, a) = paren(tuple(( list_of_path_inputs, @@ -72,12 +78,14 @@ pub(crate) fn full_path_description(s: Span) -> IResult IResult { let (s, a) = list(symbol(","), specify_input_terminal_descriptor)(s)?; Ok((s, ListOfPathInputs { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_path_outputs(s: Span) -> IResult { let (s, a) = list(symbol(","), specify_output_terminal_descriptor)(s)?; Ok((s, ListOfPathOutputs { nodes: (a,) })) diff --git a/sv-parser-parser/src/specify_section/specify_path_delays.rs b/sv-parser-parser/src/specify_section/specify_path_delays.rs index 7574da5..771f349 100644 --- a/sv-parser-parser/src/specify_section/specify_path_delays.rs +++ b/sv-parser-parser/src/specify_section/specify_path_delays.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn path_delay_value(s: Span) -> IResult { alt(( map(list_of_path_delay_expressions, |x| { @@ -13,6 +14,7 @@ pub(crate) fn path_delay_value(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn path_delay_value_paren(s: Span) -> IResult { let (s, a) = paren(list_of_path_delay_expressions)(s)?; Ok(( @@ -22,24 +24,28 @@ pub(crate) fn path_delay_value_paren(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn list_of_path_delay_expressions(s: Span) -> IResult { let (s, a) = list(symbol(","), t_path_delay_expression)(s)?; Ok((s, ListOfPathDelayExpressions { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn t_path_delay_expression(s: Span) -> IResult { let (s, a) = path_delay_expression(s)?; Ok((s, TPathDelayExpression { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn path_delay_expression(s: Span) -> IResult { let (s, a) = constant_mintypmax_expression(s)?; Ok((s, PathDelayExpression { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn edge_sensitive_path_declaration( s: Span, ) -> IResult { @@ -50,6 +56,7 @@ pub(crate) fn edge_sensitive_path_declaration( } #[tracable_parser] +#[packrat_parser] pub(crate) fn edge_sensitive_path_declaration_parallel( s: Span, ) -> IResult { @@ -65,6 +72,7 @@ pub(crate) fn edge_sensitive_path_declaration_parallel( } #[tracable_parser] +#[packrat_parser] pub(crate) fn edge_sensitive_path_declaration_full( s: Span, ) -> IResult { @@ -80,6 +88,7 @@ pub(crate) fn edge_sensitive_path_declaration_full( } #[tracable_parser] +#[packrat_parser] pub(crate) fn parallel_edge_sensitive_path_description( s: Span, ) -> IResult { @@ -99,6 +108,7 @@ pub(crate) fn parallel_edge_sensitive_path_description( } #[tracable_parser] +#[packrat_parser] pub(crate) fn full_edge_sensitive_path_description( s: Span, ) -> IResult { @@ -118,12 +128,14 @@ pub(crate) fn full_edge_sensitive_path_description( } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_source_expression(s: Span) -> IResult { let (s, a) = expression(s)?; Ok((s, DataSourceExpression { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn edge_identifier(s: Span) -> IResult { alt(( map(keyword("posedge"), |x| EdgeIdentifier::Posedge(Box::new(x))), @@ -133,6 +145,7 @@ pub(crate) fn edge_identifier(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn state_dependent_path_declaration( s: Span, ) -> IResult { @@ -144,6 +157,7 @@ pub(crate) fn state_dependent_path_declaration( } #[tracable_parser] +#[packrat_parser] pub(crate) fn state_dependent_path_declaration_if_simple( s: Span, ) -> IResult { @@ -159,6 +173,7 @@ pub(crate) fn state_dependent_path_declaration_if_simple( } #[tracable_parser] +#[packrat_parser] pub(crate) fn state_dependent_path_declaration_if_edge_sensitive( s: Span, ) -> IResult { @@ -174,6 +189,7 @@ pub(crate) fn state_dependent_path_declaration_if_edge_sensitive( } #[tracable_parser] +#[packrat_parser] pub(crate) fn state_dependent_path_declaration_if_none( s: Span, ) -> IResult { @@ -188,6 +204,7 @@ pub(crate) fn state_dependent_path_declaration_if_none( } #[tracable_parser] +#[packrat_parser] pub(crate) fn polarity_operator(s: Span) -> IResult { alt(( map(symbol("+"), |x| PolarityOperator { nodes: (x,) }), diff --git a/sv-parser-parser/src/specify_section/system_timing_check_command_arguments.rs b/sv-parser-parser/src/specify_section/system_timing_check_command_arguments.rs index e501686..51f6c3c 100644 --- a/sv-parser-parser/src/specify_section/system_timing_check_command_arguments.rs +++ b/sv-parser-parser/src/specify_section/system_timing_check_command_arguments.rs @@ -3,24 +3,28 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn timecheck_condition(s: Span) -> IResult { let (s, a) = mintypmax_expression(s)?; Ok((s, TimecheckCondition { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn controlled_referecne_event(s: Span) -> IResult { let (s, a) = controlled_timing_check_event(s)?; Ok((s, ControlledReferenceEvent { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn data_event(s: Span) -> IResult { let (s, a) = timing_check_event(s)?; Ok((s, DataEvent { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn delayed_data(s: Span) -> IResult { alt(( map(terminal_identifier, |x| { @@ -31,6 +35,7 @@ pub(crate) fn delayed_data(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn delayed_data_with_mintypmax(s: Span) -> IResult { let (s, a) = terminal_identifier(s)?; let (s, b) = bracket(constant_mintypmax_expression)(s)?; @@ -41,6 +46,7 @@ pub(crate) fn delayed_data_with_mintypmax(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn delayed_reference(s: Span) -> IResult { alt(( map(terminal_identifier, |x| { @@ -51,6 +57,7 @@ pub(crate) fn delayed_reference(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn delayed_reference_with_mintypmax(s: Span) -> IResult { let (s, a) = terminal_identifier(s)?; let (s, b) = bracket(constant_mintypmax_expression)(s)?; @@ -61,54 +68,63 @@ pub(crate) fn delayed_reference_with_mintypmax(s: Span) -> IResult IResult { let (s, a) = mintypmax_expression(s)?; Ok((s, EndEdgeOffset { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn event_based_flag(s: Span) -> IResult { let (s, a) = constant_expression(s)?; Ok((s, EventBasedFlag { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn notifier(s: Span) -> IResult { let (s, a) = variable_identifier(s)?; Ok((s, Notifier { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn referecne_event(s: Span) -> IResult { let (s, a) = timing_check_event(s)?; Ok((s, ReferenceEvent { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn remain_active_flag(s: Span) -> IResult { let (s, a) = constant_mintypmax_expression(s)?; Ok((s, RemainActiveFlag { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn timestamp_condition(s: Span) -> IResult { let (s, a) = mintypmax_expression(s)?; Ok((s, TimestampCondition { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn start_edge_offset(s: Span) -> IResult { let (s, a) = mintypmax_expression(s)?; Ok((s, StartEdgeOffset { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn threshold(s: Span) -> IResult { let (s, a) = constant_expression(s)?; Ok((s, Threshold { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn timing_check_limit(s: Span) -> IResult { let (s, a) = expression(s)?; Ok((s, TimingCheckLimit { nodes: (a,) })) diff --git a/sv-parser-parser/src/specify_section/system_timing_check_commands.rs b/sv-parser-parser/src/specify_section/system_timing_check_commands.rs index b0a92af..1e8c65b 100644 --- a/sv-parser-parser/src/specify_section/system_timing_check_commands.rs +++ b/sv-parser-parser/src/specify_section/system_timing_check_commands.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn system_timing_check(s: Span) -> IResult { alt(( map(setup_timing_check, |x| { @@ -45,6 +46,7 @@ pub(crate) fn system_timing_check(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn setup_timing_check(s: Span) -> IResult { let (s, a) = keyword("$setup")(s)?; let (s, b) = paren(tuple(( @@ -60,6 +62,7 @@ pub(crate) fn setup_timing_check(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn hold_timing_check(s: Span) -> IResult { let (s, a) = keyword("$setup")(s)?; let (s, b) = paren(tuple(( @@ -75,6 +78,7 @@ pub(crate) fn hold_timing_check(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn setuphold_timing_check(s: Span) -> IResult { let (s, a) = keyword("$setuphold")(s)?; let (s, b) = paren(tuple(( @@ -108,6 +112,7 @@ pub(crate) fn setuphold_timing_check(s: Span) -> IResult IResult { let (s, a) = keyword("$recovery")(s)?; let (s, b) = paren(tuple(( @@ -123,6 +128,7 @@ pub(crate) fn recovery_timing_check(s: Span) -> IResult IResult { let (s, a) = keyword("$removal")(s)?; let (s, b) = paren(tuple(( @@ -138,6 +144,7 @@ pub(crate) fn removal_timing_check(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn recrem_timing_check(s: Span) -> IResult { let (s, a) = keyword("$recrem")(s)?; let (s, b) = paren(tuple(( @@ -171,6 +178,7 @@ pub(crate) fn recrem_timing_check(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn skew_timing_check(s: Span) -> IResult { let (s, a) = keyword("$skew")(s)?; let (s, b) = paren(tuple(( @@ -186,6 +194,7 @@ pub(crate) fn skew_timing_check(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn timeskew_timing_check(s: Span) -> IResult { let (s, a) = keyword("$timeskew")(s)?; let (s, b) = paren(tuple(( @@ -209,6 +218,7 @@ pub(crate) fn timeskew_timing_check(s: Span) -> IResult IResult { let (s, a) = keyword("$fullskew")(s)?; let (s, b) = paren(tuple(( @@ -234,6 +244,7 @@ pub(crate) fn fullskew_timing_check(s: Span) -> IResult IResult { let (s, a) = keyword("$period")(s)?; let (s, b) = paren(tuple(( @@ -247,6 +258,7 @@ pub(crate) fn period_timing_check(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn width_timing_check(s: Span) -> IResult { let (s, a) = keyword("$width")(s)?; let (s, b) = paren(tuple(( @@ -262,6 +274,7 @@ pub(crate) fn width_timing_check(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn nocharge_timing_check(s: Span) -> IResult { let (s, a) = keyword("$nocharge")(s)?; let (s, b) = paren(tuple(( diff --git a/sv-parser-parser/src/specify_section/system_timing_check_event_definitions.rs b/sv-parser-parser/src/specify_section/system_timing_check_event_definitions.rs index ec5a284..566fea6 100644 --- a/sv-parser-parser/src/specify_section/system_timing_check_event_definitions.rs +++ b/sv-parser-parser/src/specify_section/system_timing_check_event_definitions.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn timing_check_event(s: Span) -> IResult { let (s, a) = opt(timing_check_event_control)(s)?; let (s, b) = specify_terminal_descriptor(s)?; @@ -11,6 +12,7 @@ pub(crate) fn timing_check_event(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn controlled_timing_check_event(s: Span) -> IResult { let (s, a) = timing_check_event_control(s)?; let (s, b) = specify_terminal_descriptor(s)?; @@ -19,6 +21,7 @@ pub(crate) fn controlled_timing_check_event(s: Span) -> IResult IResult { alt(( map(keyword("posedge"), |x| { @@ -37,6 +40,7 @@ pub(crate) fn timing_check_event_control(s: Span) -> IResult IResult { alt(( map(specify_input_terminal_descriptor, |x| { @@ -49,6 +53,7 @@ pub(crate) fn specify_terminal_descriptor(s: Span) -> IResult IResult { let (s, a) = keyword("edge")(s)?; let (s, b) = bracket(list(symbol(","), edge_descriptor))(s)?; @@ -56,6 +61,7 @@ pub(crate) fn edge_control_specifier(s: Span) -> IResult IResult { alt(( map(keyword("01"), |x| EdgeDescriptor { nodes: (x,) }), @@ -80,6 +86,7 @@ pub(crate) fn edge_descriptor(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn timing_check_condition(s: Span) -> IResult { alt(( map(scalar_timing_check_condition, |x| { @@ -90,6 +97,7 @@ pub(crate) fn timing_check_condition(s: Span) -> IResult IResult { let (s, a) = paren(scalar_timing_check_condition)(s)?; Ok(( @@ -99,6 +107,7 @@ pub(crate) fn timing_check_condition_paren(s: Span) -> IResult IResult { alt(( map(expression, |x| { @@ -110,6 +119,7 @@ pub(crate) fn scalar_timing_check_condition(s: Span) -> IResult IResult { @@ -124,6 +134,7 @@ pub(crate) fn scalar_timing_check_condition_unary( } #[tracable_parser] +#[packrat_parser] pub(crate) fn scalar_timing_check_condition_binary( s: Span, ) -> IResult { @@ -139,6 +150,7 @@ pub(crate) fn scalar_timing_check_condition_binary( } #[tracable_parser] +#[packrat_parser] pub(crate) fn scalar_constant(s: Span) -> IResult { alt(( map(keyword("1'b0"), |x| ScalarConstant { nodes: (x,) }), diff --git a/sv-parser-parser/src/tests.rs b/sv-parser-parser/src/tests.rs index b282f03..26762f7 100644 --- a/sv-parser-parser/src/tests.rs +++ b/sv-parser-parser/src/tests.rs @@ -2388,13 +2388,13 @@ mod spec { // endclass"##, // Ok((_, _)) //); - //test!( - // many1(module_item), - // r##"Packet p; // declare a variable of class Packet - // p = new; // initialize variable to a new allocated object - // // of the class Packet"##, - // Ok((_, _)) - //); + test!( + many1(module_item), + r##"Packet p; // declare a variable of class Packet + p = new; // initialize variable to a new allocated object + // of the class Packet"##, + Ok((_, _)) + ); test!( many1(module_item), r##"class obj_example; @@ -3225,14 +3225,16 @@ mod spec { PutImp#(int) put_ref = fifo_obj;"##, Ok((_, _)) ); - //test!( - // many1(module_item), - // r##"GetImp#(int) get_ref; - // Fifo#(int) fifo_obj = new; - // PutImp#(int) put_ref = fifo_obj; - // $cast(get_ref, put_ref);"##, - // Ok((_, _)) - //); + test!( + many1(module_item), + r##"initial begin + GetImp#(int) get_ref; + Fifo#(int) fifo_obj = new; + PutImp#(int) put_ref = fifo_obj; + $cast(get_ref, put_ref); + end"##, + Ok((_, _)) + ); test!( many1(module_item), r##"initial begin @@ -3396,7 +3398,5665 @@ mod spec { Ok((_, _)) ); } + + #[test] + fn clause9() { + test!( + many1(module_item), + r##"initial begin + a = 0; // initialize a + for (int index = 0; index < size; index++) + memory[index] = 0; // initialize memory word + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + inputs = 'b000000; // initialize at time zero + #10 inputs = 'b011001; // first pattern + #10 inputs = 'b011011; // second pattern + #10 inputs = 'b011000; // third pattern + #10 inputs = 'b001000; // last pattern + end"##, + Ok((_, _)) + ); + test!(many1(module_item), r##"always areg = ~areg;"##, Ok((_, _))); + test!( + many1(module_item), + r##"always #half_period areg = ~areg;"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"always_comb + // a = b & c; + // always_comb + // d <= #1ns b & c;"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"always_comb + begin + a = b & c; + A1:assert (a != e) else if (!disable_error) $error("failed"); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always_latch + if(ck) q <= d;"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always_ff @(posedge clock iff reset == 0 or posedge reset) begin + r1 <= reset ? 0 : r2 + 1; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"final + begin + $display("Number of cycles executed %d",$time/period); + $display("Final PC = %h",PC); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + areg = breg; + creg = areg; // creg stores the value of breg + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + areg = breg; + @(posedge clock) creg = areg; // assignment delayed until + end // posedge on clock"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"parameter d = 50; // d declared as a parameter and + logic [7:0] r; // r declared as an 8-bit variable + initial begin // a waveform controlled by sequential delays + #d r = 'h35; + #d r = 'hE2; + #d r = 'h00; + #d r = 'hF7; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + fork + #50 r = 'h35; + #100 r = 'hE2; + #150 r = 'h00; + #200 r = 'hF7; + join + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + fork + begin + statement1; // one process with 2 statements + statement2; + end + join + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + fork + begin + $display( "First Block\n" ); + # 20ns; + end + begin + $display( "Second Block\n" ); + @eventA; + end + join + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"task wait_20; + fork + # 20; + return ; // Illegal: cannot return; task lives in another process + join_none + endtask"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial + for( int j = 1; j <= 3; ++j ) + fork + automatic int k = j; // local copy, k, for each value of j + #k $write( "%0d", k ); + begin + automatic int m = j; // the value of m is undetermined + end + join_none"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + fork + #200 r = 'hF7; + #150 r = 'h00; + #100 r = 'hE2; + #50 r = 'h35; + join + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + fork + @Aevent; + @Bevent; + join + areg = breg; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + fork + @enable_a + begin + #ta wa = 0; + #ta wa = 1; + #ta wa = 0; + end + @enable_b + begin + #tb wb = 1; + #tb wb = 0; + #tb wb = 1; + end + join + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin: blockB // block name after the begin or fork + end: blockB"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + labelB: fork // label before the begin or fork + join_none : labelB + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + #10 rega = regb; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + #d rega = regb; // d is defined as a parameter + #((d+e)/2) rega = regb; // delay is average of d and e + #regr regr = regr + 1; // delay is the value in regr + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + @r rega = regb; // controlled by any value change in the reg r + @(posedge clock) rega = regb; // controlled by posedge on clock + forever @(negedge clock) rega = regb; // controlled by negedge on clock + forever @(edge clock) rega = regb; // controlled by edge on clock + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"real AOR[]; // dynamic array of reals + byte stream[$]; // queue of bytes + initial wait(AOR.size() > 0); // waits for array to be allocated + initial wait($bits(stream) > 60); // waits for total number of bits + // in stream greater than 60 + + Packet p = new; // Packet 1 -- Packet is defined in 8.2 + Packet q = new; // Packet 2 + initial fork + @(p.status); // Wait for status in Packet 1 to change + @p; // Wait for a change to handle p + # 10 p = q; // triggers @p. + // @(p.status) now waits for status in Packet 2 to change, + // if not already different from Packet 1 + join"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + @(trig or enable) rega = regb; // controlled by trig or enable + + @(posedge clk_a or posedge clk_b or trig) rega = regb; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @(a, b, c, d, e); + always @(posedge clk, negedge rstn); + always @(a or b, c, d or e);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @(*) // equivalent to @(a or b or c or d or f) + y = (a & b) | (c & d) | myfunction(f);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @* begin // equivalent to @(a or b or c or d or tmp1 or tmp2) + tmp1 = a & b; + tmp2 = c & d; + y = tmp1 | tmp2; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @* begin // equivalent to @(b) + @(i) kid = b; // i is not added to @* + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @* begin // equivalent to @(a or b or c or d) + x = a ^ b; + @* // equivalent to @(c or d) + x = c ^ d; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @* begin // same as @(a or en) + y = 8'hff; + y[a] = !en; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @* begin // same as @(state or go or ws) + next = 4'b0; + case (1'b1) + state[IDLE]: if (go) next[READ] = 1'b1; + else next[IDLE] = 1'b1; + state[READ]: next[DLY ] = 1'b1; + state[DLY ]: if (!ws) next[DONE] = 1'b1; + else next[READ] = 1'b1; + state[DONE]: next[IDLE] = 1'b1; + endcase + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module latch (output logic [31:0] y, input [31:0] a, input enable); + always @(a iff enable == 1) + y <= a; //latch is in transparent mode + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence abc; + @(posedge clk) a ##1 b ##1 c; + endsequence + + program test; + initial begin + @ abc $display( "Saw a-b-c" ); + end + endprogram"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + wait (!enable) #10 a = b; + #10 c = d; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence abc; + @(posedge clk) a ##1 b ##1 c; + endsequence + + sequence de; + @(negedge clk) d ##[2:5] e; + endsequence + + program check; + initial begin + wait( abc.triggered || de.triggered ); + if( abc.triggered ) + $display( "abc succeeded" ); + if( de.triggered ) + $display( "de succeeded" ); + end + endprogram"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // repeat (3) @ (event_expression) + // // will execute event_expression three times + // repeat (-3) @ (event_expression) + // // will not execute event_expression. + // repeat (a) @ (event_expression) + // // if a is assigned -3, it will execute the event_expression if a is + // // declared as an unsigned variable, but not if a is signed + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + fork + #5 a = b; + #5 b = a; + join + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + fork // data swap + a = #5 b; + b = #5 a; + join + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + fork // data shift + a = @(posedge clk) b; + b = @(posedge clk) c; + join + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + a <= repeat(5) @(posedge clk) data; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + a = repeat(num) @(clk) data; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + a <= repeat(a+b) @(posedge phi1 or negedge phi2) data; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + a <= repeat(a+b) @(edge phi1) data; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin : test + fork + child1(); + child2(); + join_none + do_test(); + end : test + + task do_test(); + fork + child3(); + child4(); + fork : child5 // nested fork-join_none is a child process + descendant1(); + descendant2(); + join_none + join_none + do_sequence(); + wait fork; // block until child1 ... child7 complete + endtask + + function void do_sequence(); + fork + child6(); + child7(); + join_none + endfunction"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin : block_name + rega = regb; + disable block_name; + regc = rega; // this assignment will never execute + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin : block_name + if (a == 0) + disable block_name; + end // end of named block + // continue with code following named block"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module m (); + always + begin : always1 + t1: task1( ); // task call + end + + always + begin + disable m.always1; // exit always1, which will exit task1, + // if it was currently executing + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"task proc_a; + begin + if (a == 0) + disable proc_a; // return if true + end + endtask"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin : outer_block + for (i = 0; i < n; i = i+1) begin : inner_block + @clk + if (a == 0) // "continue" loop + disable inner_block ; + @clk + if (a == b) // "break" from loop + disable outer_block; + end + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + fork + begin : event_expr + @ev1; + repeat (3) @trig; + #d action (areg, breg); + end + @reset disable event_expr; + join + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always begin : monostable + #250 q = 0; + end + + always @retrig begin + disable monostable; + q = 1; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"task get_first( output int adr ); + fork + wait_device( 1, adr ); + wait_device( 7, adr ); + wait_device( 13, adr ); + join_any + disable fork; + endtask"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"class process; + // typedef enum { FINISHED, RUNNING, WAITING, SUSPENDED, KILLED } state; + + // static function process self(); + // function state status(); + // function void kill(); + // task await(); + // function void suspend(); + // function void resume(); + // function void srandom( int seed ); + // function string get_randstate(); + // function void set_randstate( string state ); + // endclass"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"task automatic do_n_way( int N ); + // process job[] = new [N]; + + // foreach (job[j]) + // fork + // automatic int k = j; + // begin job[k] = process::self(); ... ; end + // join_none + + // foreach (job[j]) // wait for all processes to start + // wait( job[j] != null ); + // job[1].await(); // wait for first process to finish + + // foreach (job[j]) begin + // if ( job[j].status != process::FINISHED ) + // job[j].kill(); + // end + // endtask"##, + // Ok((_, _)) + //); + } + + #[test] + fn clause10() { + //test!( + // many1(module_item), + // r##"initial begin + // #1ns r = a; + // r = #1ns a; + // r <= #1ns a; + // end + // assign #2.5ns sum = a + b;"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"wire (strong1, pull0) mynet = enable;"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"wire mynet ; + assign (strong1, pull0) mynet = enable;"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module adder (sum_out, carry_out, carry_in, ina, inb); + output [3:0] sum_out; + output carry_out; + input [3:0] ina, inb; + input carry_in; + + wire carry_out, carry_in; + wire [3:0] sum_out, ina, inb; + + assign {carry_out, sum_out} = ina + inb + carry_in; + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module select_bus(busout, bus0, bus1, bus2, bus3, enable, s); + parameter n = 16; + parameter Zee = 16'bz; + output [1:n] busout; + input [1:n] bus0, bus1, bus2, bus3; + input enable; + input [1:2] s; + + tri [1:n] data; // net declaration + + // net declaration with continuous assignment + tri [1:n] busout = enable ? data : Zee; + + // assignment statement with four continuous assignments + assign + data = (s == 0) ? bus0 : Zee, + data = (s == 1) ? bus1 : Zee, + data = (s == 2) ? bus2 : Zee, + data = (s == 3) ? bus3 : Zee; + endmodule"##, + Ok((_, _)) + ); + test!(many1(module_item), r##"wire #10 wireA;"##, Ok((_, _))); + test!( + many1(module_item), + r##"initial begin + rega = 0; + rega[3] = 1; // a bit-select + rega[3:5] = 7; // a part-select + mema[address] = 8'hff; // assignment to a mem element + {carry, acc} = rega + regb; // a concatenation + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module evaluates (out); + output out; + logic a, b, c; + + initial begin + a = 0; + b = 1; + c = 0; + end + + always c = #5 ~c; + + always @(posedge c) begin + a <= b; // evaluates, schedules, + b <= a; // and executes in two steps + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module nonblock1; + logic a, b, c, d, e, f; + + // blocking assignments + initial begin + a = #10 1; // a will be assigned 1 at time 10 + b = #2 0; // b will be assigned 0 at time 12 + c = #4 1; // c will be assigned 1 at time 16 + end + + // nonblocking assignments + initial begin + d <= #10 1; // d will be assigned 1 at time 10 + e <= #2 0; // e will be assigned 0 at time 2 + f <= #4 1; // f will be assigned 1 at time 4 + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module nonblock2; + logic a, b; + initial begin + a = 0; + b = 1; + a <= b; // evaluates, schedules, + b <= a; // and executes in two steps + end + + initial begin + $monitor ($time, ,"a = %b b = %b", a, b); + #100 $finish; + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module multiple; + logic a; + initial a = 1; + // The assigned value of the variable is determinate + + initial begin + a <= #4 0; // schedules a = 0 at time 4 + a <= #4 1; // schedules a = 1 at time 4 + end // At time 4, a = 1 + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module multiple2; + logic a; + + initial a = 1; + initial a <= #4 0; // schedules 0 at time 4 + initial a <= #4 1; // schedules 1 at time 4 + + // At time 4, a = ?? + // The assigned value of the variable is indeterminate + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module multiple3; + logic a; + initial #8 a <= #8 1; // executed at time 8; + // schedules an update of 1 at time 16 + initial #12 a <= #4 0; // executed at time 12; + // schedules an update of 0 at time 16 + + // Because it is determinate that the update of a to the value 1 + // is scheduled before the update of a to the value 0, + // then it is determinate that a will have the value 0 + // at the end of time slot 16. + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module multiple4; + logic r1; + logic [2:0] i; + + initial begin + // makes assignments to r1 without cancelling previous assignments + for (i = 0; i <= 5; i++) + r1 <= # (i*10) i[0]; + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"wire w = vara & varb; // net with a continuous assignment + + logic v = consta & constb; // variable with initialization"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + force a = b + f(c) ; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module dff (q, d, clear, preset, clock); + output q; + input d, clear, preset, clock; + logic q; + + always @(clear or preset) + if (!clear) + assign q = 0; + else if (!preset) + assign q = 1; + else + deassign q; + + always @(posedge clock) + q = d; + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module test; + logic a, b, c, d; + wire e; + + and and1 (e, a, b, c); + + initial begin + $monitor("%d d=%b,e=%b", $stime, d, e); + assign d = a & b & c; + a = 1; + b = 0; + c = 1; + #10; + force d = (a | b | c); + force e = (a | b | c); + #10; + release d; + release e; + #10 $finish; + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"logic [5:0] a; + logic signed [4:0] b; + + initial begin + a = 8'hff; // After the assignment, a = 6'h3f + b = 8'hff; // After the assignment, b = 5'h1f + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"logic [0:5] a; + logic signed [0:4] b, c; + + initial begin + a = 8'sh8f; // After the assignment, a = 6'h0f + b = 8'sh8f; // After the assignment, b = 5'h0f + c = -113; // After the assignment, c = 15 + // 1000_1111 = (-'h71 = -113) truncates to ('h0F = 15) + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"logic [7:0] a; + logic signed [7:0] b; + logic signed [5:0] c, d; + + initial begin + a = 8'hff; + c = a; // After the assignment, c = 6'h3f + b = -113; + d = b; // After the assignment, d = 6'h0f + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + var int A[N] = '{default:1}; + var integer i = '{31:1, 23:1, 15:1, 8:1, default:0}; + + typedef struct {real r, th;} C; + var C x = '{th:PI/2.0, r:1.0}; + var real y [0:1] = '{0.0, 1.1}, z [0:9] = '{default: 3.1416}; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + var int B[4] = '{a, b, c, d}; + var C y = '{1.0, PI/2.0}; + '{a, b, c, d} = B; + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // typedef logic [1:0] [3:0] T; + // shortint'({T'{1,2}, T'{3,4}}) // yields 16'sh1234 + // end"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"initial begin + // typedef byte U[3]; + // var U A = '{1, 2, 3}; + // var byte a, b, c; + // U'{a, b, c} = A; + // U'{c, a, b} = '{a+1, b+1, c+1}; + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + bit unpackedbits [1:0] = '{1,1}; // no size warning required as + // bit can be set to 1 + int unpackedints [1:0] = '{1'b1, 1'b1}; // no size warning required as + // int can be set to 1'b1 + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + unpackedbits = '{2 {y}} ; // same as '{y, y} + int n[1:2][1:3] = '{2{'{3{y}}}}; // same as '{'{y,y,y},'{y,y,y}} + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial unpackedints = '{default:2}; // sets elements to 2"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + struct {int a; time b;} abkey[1:0]; + abkey = '{'{a:1, b:2ns}, '{int:5, time:$time}}; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module mod1; + + typedef struct { + int x; + int y; + } st; + + st s1; + int k = 1; + + initial begin + #1 s1 = '{1, 2+k}; // by position + #1 $display( s1.x, s1.y); + #1 s1 = '{x:2, y:3+k}; // by name + #1 $display( s1.x, s1.y); + #1 $finish; + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial s1 = '{default:2}; // sets x and y to 2"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"ab abkey[1:0] = '{'{a:1, b:1.0}, '{int:2, shortreal:2.0}};"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + struct { + int A; + struct { + int B, C; + } BC1, BC2; + } ABC, DEF; + + ABC = '{A:1, BC1:'{B:2, C:3}, BC2:'{B:4,C:5}}; + DEF = '{default:10}; + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"typedef struct { + // logic [7:0] a; + // bit b; + // bit signed [31:0] c; + // string s; + // } sa; + + // sa s2; + // initial s2 = '{int:1, default:0, string:""}; // set all to 0 except the + // // array of bits to 1 and + // // string to """##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial #10 s2 = '{default:'1, s : ""}; // set all to 1 except s to """##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + int A3[1:3]; + A3 = {1, 2, 3}; // unpacked array concatenation: A3[1]=1, A3[2]=2, A3[3]=3 + A3 = '{1, 2, 3}; // array assignment pattern: A3[1]=1, A3[2]=2, A3[3]=3 + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + typedef int AI3[1:3]; + AI3 A3; + int A9[1:9]; + + A3 = '{1, 2, 3}; + A9 = '{3{A3}}; // illegal, A3 is wrong element type + A9 = '{A3, 4, 5, 6, 7, 8, 9}; // illegal, A3 is wrong element type + A9 = {A3, 4, 5, A3, 6}; // legal, gives A9='{1,2,3,4,5,1,2,3,6} + A9 = '{9{1}}; // legal, gives A9='{1,1,1,1,1,1,1,1,1} + A9 = {9{1}}; // illegal, no replication in unpacked + // array concatenation + A9 = {A3, {4,5,6,7,8,9} }; // illegal, {...} is not self-determined here + A9 = {A3, '{4,5,6,7,8,9} }; // illegal, '{...} is not self-determined + A9 = {A3, 4, AI3'{5, 6, 7}, 8, 9}; // legal, A9='{1,2,3,4,5,6,7,8,9} + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + string S, hello; + string SA[2]; + byte B; + byte BA[2]; + + hello = "hello"; + + S = {hello, " world"}; // string concatenation: "hello world" + SA = {hello, " world"}; // array concatenation: + // SA[0]="hello", SA[1]=" world" + + B = {4'h6, 4'hf}; // vector concatenation: B=8'h6f + BA = {4'h6, 4'hf}; // array concatenation: BA[0]=8'h06, BA[1]=8'h0f + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + string S1, S2; + typedef string T_SQ[$]; + T_SQ SQ; + + S1 = "S1"; + S2 = "S2"; + SQ = '{"element 0", "element 1"}; // assignment pattern, two strings + SQ = {S1, SQ, {"element 3 is ", S2} }; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + SQ = {S1, SQ, T_SQ'{"element 3 is ", S2} }; + // result: '{"S1", "element 0", "element 1", "element 3 is ", "S2"} + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + typedef int T_QI[$]; + T_QI jagged_array[$] = '{ {1}, T_QI'{2,3,4}, {5,6} }; + // jagged_array[0][0] = 1 -- jagged_array[0] is a queue of 1 int + // jagged_array[1][0] = 2 -- jagged_array[1] is a queue of 3 ints + // jagged_array[1][1] = 3 + // jagged_array[1][2] = 4 + // jagged_array[2][0] = 5 -- jagged_array[2] is a queue of 2 ints + // jagged_array[2][1] = 6 + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module byte_swap (inout wire [31:0] A, inout wire [31:0] B); + alias {A[7:0],A[15:8],A[23:16],A[31:24]} = B; + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module byte_rip (inout wire [31:0] W, inout wire [7:0] LSB, MSB); + alias W[7:0] = LSB; + alias W[31:24] = MSB; + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module overlap(inout wire [15:0] bus16, inout wire [11:0] low12, high12); + alias bus16[11:0] = low12; + alias bus16[15:4] = high12; + endmodule + + module overlap(inout wire [15:0] bus16, inout wire [11:0] low12, high12); + alias bus16 = {high12, low12[3:0]}; + alias high12[7:0] = low12[11:4]; + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"alias bus16 = {high12[11:8], low12}; + alias bus16 = {high12, low12[3:0]};"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"alias bus16 = {high12, bus16[3:0]} = {bus16[15:12], low12};"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module lib1_dff(Reset, Clk, Data, Q, Q_Bar); + endmodule + + module lib2_dff(reset, clock, data, q, qbar); + endmodule + + module lib3_dff(RST, CLK, D, Q, Q_); + endmodule + + module my_dff(rst, clk, d, q, q_bar); // wrapper cell + input rst, clk, d; + output q, q_bar; + alias rst = Reset = reset = RST; + alias clk = Clk = clock = CLK; + alias d = Data = data = D; + alias q = Q; + alias Q_ = q_bar = Q_Bar = qbar; + LIB_DFF my_dff (.*); // LIB_DFF is any of lib1_dff, lib2_dff or lib3_dff + endmodule"##, + Ok((_, _)) + ); + } + + #[test] + fn clause11() { + test!( + many1(module_item), + r##"initial begin + int IntA; + IntA = -12 / 3; // The result is -4 + + IntA = -'d 12 / 3; // The result is 1431655761 + + IntA = -'sd 12 / 3; // The result is -4 + + IntA = -4'sd 12 / 3; // -4'sd12 is the negative of the 4-bit + // quantity 1100, which is -4. -(-4) = 4 + // The result is 1 + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + int n = 8, zero = 0; + int res = 'b01xz | n; // res gets 'b11xz coerced to int, or 'b1100 + int sum = n + n; // sum gets 16 coerced to int, or 16 + int sumx = 'x + n; // sumx gets 'x coerced to int, or 0 + int div2 = n/zero + n; // div2 gets 'x coerced to int, or 0 + integer div4 = n/zero + n; // div4 gets 'x + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // logic regA, regB, regC, result ; + + // function logic myFunc(logic x); + // endfunction + + // result = regA & (regB | myFunc(regC)) ; + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + if ((a=b)) b = (a+=1); + + a = (b = (c = 5)); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + a[i]+=2; // same as a[i] = a[i] +2; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + i = 10; + j = i++ + (i = i - 1); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + integer intS; + var logic [15:0] U; + var logic signed [15:0] S; + + intS = -4'd12; + U = intS / 3; // expression result is -4, + // intS is an integer data type, U is 65532 + + U = -4'd12; // U is 65524 + intS = U / 3; // expression result is 21841, + // U is a logic data type + + intS = -4'd12 / 3; // expression result is 1431655761. + // -4'd12 is effectively a 32-bit logic data type + + U = -12 / 3; // expression result is -4, -12 is effectively + // an integer data type. U is 65532 + + S = -12 / 3; // expression result is -4. S is a signed logic + + S = -4'sd12 / 3; // expression result is 1. -4'sd12 is actually 4. + // The rules for integer division yield 4/3==1 + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + regA = alpha && beta; // regA is set to 0 + regB = alpha || beta; // regB is set to 1 + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module shift; + logic [3:0] start, result; + initial begin + start = 1; + result = (start << 2); + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module ashift; + logic signed [3:0] start, result; + initial begin + start = 4'b1000; + result = (start >>> 2); + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"wire [15:0] busa = drive_busa ? data : 16'bz;"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + logic log1, log2, log3; + {log1, log2, log3} = 3'b111; + {log1, log2, log3} = {1'b1, 1'b1, 1'b1}; // same effect as 3'b111 + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // byte a, b ; + // bit [1:0] c ; + // c = {a + b}[1:0]; // 2 lsb's of sum of a and b + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"parameter P = 32; + + // The following is legal for all P from 1 to 32 + + assign b[31:0] = { {32-P{1'b1}}, a[P-1:0] } ; + + // The following is illegal for P=32 because the zero + // replication appears alone within a concatenation + + assign c[31:0] = { {{32-P{1'b1}}}, a[P-1:0] }; + + // The following is illegal for P=32 + + initial + $displayb({32-P{1'b1}}, a[P-1:0]);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + result = {4{func(w)}} ; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + y = func(w) ; + result = {y, y, y, y} ; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + string hello = "hello"; + string s; + s = { hello, " ", "world" }; + $display( "%s\n", s ); // displays 'hello world' + s = { s, " and goodbye" }; + $display( "%s\n", s ); // displays 'hello world and goodbye' + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + int n = 3; + string s = {n { "boo " }}; + $display( "%s\n", s ); // displays 'boo boo boo ' + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // int a, b, c; + // if ( a inside {b, c} ); + // int array [$] = '{3,4,5}; + // if ( ex inside {1, 2, array} ); // same as { 1, 2, 3, 4, 5} + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + logic [2:0] val; + while ( val inside {3'b1?1} ) ; // matches 3'b101, 3'b111, 3'b1x1, 3'b1z1 + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // wire r; + // assign r=3'bz11 inside {3'b1?1, 3'b011}; // r = 1'bx + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + bit ba = a inside { [16:23], [32:47] }; + string I; + if (I inside {["a rock":"hard place"]}); + // I between "a rock" and a "hard place" + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // int a, b, c; + // logic [10:0] up [3:0]; + // logic [11:1] p1, p2, p3, p4; + // bit [96:1] y = {>>{ a, b, c }}; // OK: pack a, b, c + // int j = {>>{ a, b, c }}; // error: j is 32 bits < 96 bits + // bit [99:0] d = {>>{ a, b, c }}; // OK: d is padded with 4 bits + // {>>{ a, b, c }} = 23'b1; // error: too few bits in stream + // {>>{ a, b, c }} = 96'b1; // OK: unpack a = 0, b = 0, c = 1 + // {>>{ a, b, c }} = 100'b11111; // OK: unpack a = 0, b = 0, c = 1 + // // 96 MSBs unpacked, 4 LSBs truncated + // { >> {p1, p2, p3, p4}} = up; // OK: unpack p1 = up[3], p2 = up[2], + // // p3 = up[1], p4 = up[0] + // end"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"initial begin + // byte stream[$]; // byte stream + + // class Packet; + // rand int header; + // rand int len; + // rand byte payload[]; + // int crc; + + // constraint G { len > 1; payload.size == len ; } + + // function void post_randomize; crc = payload.sum; endfunction + // endclass + + // send: begin // Create random packet and transmit + // byte q[$]; + // Packet p = new; + // void'(p.randomize()); + // q = {<< byte{p.header, p.len, p.payload, p.crc}}; // pack + // stream = {stream, q}; // append to stream + // end + + // receive: begin // Receive packet, unpack, and remove + // byte q[$]; + // Packet p = new; + // {<< byte{ p.header, p.len, p.payload with [0 +: p.len], p.crc }} = stream; + // stream = stream[ $bits(p) / 8 : $ ]; // remove packet + // end + // end"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"initial begin + // q = {<> 1; // will not work properly + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + answer = (a + b + 0) >> 1; // will work correctly + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module bitlength(); + logic [3:0] a, b, c; + logic [4:0] d; + + initial begin + a = 9; + b = 8; + c = 1; + $display("answer = %b", c ? (a&b) : d); + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"logic [3:0] a; + logic [5:0] b; + logic [15:0] c; + + initial begin + a = 4'hF; + b = 6'hA; + $display("a*b=%h", a*b); // expression size is self-determined + c = {a**b}; // expression a**b is self-determined + // due to concatenation operator {} + $display("a**b=%h", c); + c = a**b; // expression size is determined by c + $display("c=%h", c); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + logic [7:0] regA, regB; + logic signed [7:0] regS; + + regA = $unsigned(-4); // regA = 8'b11111100 + regB = $unsigned(-4'sd4); // regB = 8'b00001100 + regS = $signed (4'b1100); // regS = -4 + + regA = unsigned'(-4); // regA = 8'b11111100 + regS = signed'(4'b1100); // regS = -4 + + regS = regA + regB; // will do unsigned addition + regS = byte'(regA) + byte'(regB); // will do signed addition + regS = signed'(regA) + signed'(regB); // will do signed addition + regS = $signed(regA) + $signed(regB); // will do signed addition + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"logic [15:0] a; + logic signed [7:0] b; + + initial + a = b[7:0]; // b[7:0] is unsigned and therefore zero-extended"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + typedef union tagged { + void Invalid; + int Valid; + } VInt; + + VInt vi1, vi2; + + vi1 = tagged Valid (23+34); // Create Valid int + vi2 = tagged Invalid; // Create an Invalid value + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // typedef union tagged { + // struct { + // bit [4:0] reg1, reg2, regd; + // } Add; + // union tagged { + // bit [9:0] JmpU; + // struct { + // bit [1:0] cc; + // bit [9:0] addr; + // } JmpC; + // } Jmp; + // } Instr; + + // Instr i1, i2; + + // // Create an Add instruction with its 3 register fields + // i1 = ( e + // ? tagged Add '{ e1, 4, ed }; // struct members by position + // : tagged Add '{ reg2:e2, regd:3, reg1:19 }); // by name (order irrelevant) + + // // Create a Jump instruction, with "unconditional" sub-opcode + // i1 = tagged Jmp (tagged JmpU 239); + + // // Create a Jump instruction, with "conditional" sub-opcode + // i2 = tagged Jmp (tagged JmpC '{ 2, 83 }); // inner struct by position + // i2 = tagged Jmp (tagged JmpC '{ cc:2, addr:83 }); // by name + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + x = i1.Add.reg1; + i1.Add = '{19, 4, 3}; + i1.Add.reg2 = 4; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module string_test; + bit [8*14:1] stringvar; + + initial begin + stringvar = "Hello world"; + $display("%s is stored as %h", stringvar, stringvar); + stringvar = {stringvar,"!!!"}; + $display("%s is stored as %h", stringvar, stringvar); + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"bit [8*10:1] s1, s2; + initial begin + s1 = "Hello"; + s2 = " world!"; + if ({s1,s2} == "Hello world!") + $display("strings are equal"); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + a = (a:b:c) + (d:e:f); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + a = val - (32'd 50: 32'd 75: 32'd 100); + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"package pex_gen9_common_expressions; + // let valid_arb(request, valid, override) = |(request & valid) || override; + // endpackage + + // module my_checker; + // import pex_gen9_common_expressions::*; + // logic a, b; + // wire [1:0] req; + // wire [1:0] vld; + // logic ovr; + // if (valid_arb(.request(req), .valid(vld), .override(ovr))) begin + // end + // endmodule"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"let mult(x, y) = ($bits(x) + $bits(y))'(x * y);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"let at_least_two(sig, rst = 1'b0) = rst || ($countones(sig) >= 2); + logic [15:0] sig1; + logic [3:0] sig2; + always_comb begin + q1: assert (at_least_two(sig1)); + q2: assert (at_least_two(~sig2)); + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // task write_value; + // input logic [31:0] addr; + // input logic [31:0] value; + // endtask + + // let addr = top.block1.unit1.base + top.block1.unit2.displ; + + // write_value(addr, 0); + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"module m; + logic clk, a, b; + logic p, q, r; + + // let with formal arguments and default value on y + let eq(x, y = b) = x == y; + + // without parameters, binds to a, b above + let tmp = a && b; + + a1: assert property (@(posedge clk) eq(p,q)); + always_comb begin + a2: assert (eq(r)); // use default for y + a3: assert (tmp); + end + endmodule : m"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module m; + bit clk, a, b; + logic p, q, r; + // let eq(x, y = b) = x == y; + // let tmp = a && b; + + a1: assert property (@(posedge clk) (m.p == m.q)); + always_comb begin + a2: assert ((m.r == m.b)); // use default for y + a3: assert ((m.a && m.b)); + end + endmodule : m"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module top; + logic x = 1'b1; + logic a, b; + let y = x; + + always_comb begin + // y binds to preceding definition of x + // in the declarative context of let + bit x = 1'b0; + b = a | y; + end + endmodule : top"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module top; + bit x = 1'b1; + bit a; + // let y = x; + + always_comb begin + // y binds to preceding definition of x + // in the declarative context of let + bit x = 1'b0; + b = a | (top.x); + end + endmodule : top"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module top; + logic a, b; + let x = a || b; + sequence s; + x ##1 b; + endsequence : s + endmodule : top"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module top; + logic a, b; + // let x = a || b; + sequence s; + (top.a || top.b) ##1 b; + endsequence : s + endmodule : top"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"module m(); + // wire a, b; + // wire [2:0] c; + // wire [2:0] d; + // wire e; + + // for (genvar i = 0; i < 3; i++) begin : L0 + // if (i !=1) begin : L1 + // let my_let(x) = !x || b && c[i]; + // s1: assign d[2 – i] = my_let(a)); // OK + // end : L1 + // end : L0 + // s2: assign e = L0[0].L1.my_let(a)); // Illegal + // endmodule : m"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"assign d[2] = (!m.a || m.b && m.c[0]);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"assign d[0] = (!m.a || m.b && m.c[2]);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module m(input clock); + logic [15:0] a, b; + logic c, d; + typedef bit [15:0] bits; + + let ones_match(bits x, y) = x == y; + let same(logic x, y) = x === y; + + always_comb + a1: assert(ones_match(a, b)); + + property toggles(bit x, y); + same(x, y) |=> !same(x, y); + endproperty + + a2: assert property (@(posedge clock) toggles(c, d)); + endmodule : m"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module m(input clock); + logic [15:0] a, b; + logic c, d; + typedef bit [15:0] bits; + + // let ones_match(bits x, y) = x == y; + // let same(logic x, y) = x === y; + + always_comb + a1:assert((bits'(a) == bits'(b))); + + property toggles(bit x, y); + (logic'(x) === logic'(y)) |=> ! (logic'(x) === logic'(y)); + endproperty + + a2: assert property (@(posedge clock) toggles(c, d)); + endmodule : m"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"module m(input clock); + // logic a; + // let p1(x) = $past(x); + // let p2(x) = $past(x,,,@(posedge clock)); + // let s(x) = $sampled(x); + // always_comb begin + // a1: assert(p1(a)); + // a2: assert(p2(a)); + // a3: assert(s(a)); + // end + // a4: assert property(@(posedge clock) p1(a)); + // endmodule : m"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"module m(input clock); + // logic a; + // let p1(x) = $past(x); + // let p2(x) = $past(x,,,@(posedge clock)); + // let s(x) = $sampled(x); + // always_comb begin + // a1: assert(($past(a))); // Illegal: no clock can be inferred + // a2: assert(($past(a,,,@(posedge clock)))); + // a3: assert(($sampled (a))); + // end + // a4: assert property(@(posedge clock)($past(a))); // @(posedge clock) + // // is inferred + // endmodule : m"##, + // Ok((_, _)) + //); + } + + #[test] + fn clause12() { + test!( + many1(module_item), + r##"initial begin + if (index > 0) + if (rega > regb) + result = rega; + else // else applies to preceding if + result = regb; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + if (index > 0) + begin + if (rega > regb) + result = rega; + end + else result = regb; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + // declare variables and parameters + logic [31:0] instruction, + segment_area[255:0]; + logic [7:0] index; + logic [5:0] modify_seg1, + modify_seg2, + modify_seg3; + parameter + segment1 = 0, inc_seg1 = 1, + segment2 = 20, inc_seg2 = 2, + segment3 = 64, inc_seg3 = 4, + data = 128; + + // test the index variable + if (index < segment2) begin + instruction = segment_area [index + modify_seg1]; + index = index + inc_seg1; + end + else if (index < segment3) begin + instruction = segment_area [index + modify_seg2]; + index = index + inc_seg2; + end + else if (index < data) begin + instruction = segment_area [index + modify_seg3]; + index = index + inc_seg3; + end + else + instruction = segment_area [index]; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + unique if ((a==0) || (a==1)) $display("0 or 1"); + else if (a == 2) $display("2"); + else if (a == 4) $display("4"); // values 3,5,6,7 cause a violation report + + priority if (a[2:1]==0) $display("0 or 1"); + else if (a[2] == 0) $display("2 or 3"); + else $display("4 to 7"); // covers all other possible values, + // so no violation report + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + unique0 if ((a==0) || (a==1)) $display("0 or 1"); + else if (a == 2) $display("2"); + else if (a == 4) $display("4"); // values 3,5,6,7 + // cause no violation report + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always_comb begin + not_a = !a; + end + + always_comb begin : a1 + u1: unique if (a) + z = a | b; + else if (not_a) + z = a | c; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always_comb begin + for (int j = 0; j < 3; j++) + not_a[j] = !a[j]; + end + + always_comb begin : a1 + for (int j = 0; j < 3; j++) + unique if (a[j]) + z[j] = a[j] | b[j]; + else if (not_a[j]) + z[j] = a[j] | c[j]; + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"module fsm(); + // function bit f1(bit a, bit not_a) + // a1: unique if (a) + // else if (not_a) + // endfunction + + // always_comb begin : b1 + // some_stuff = f1(c, d); + // end + + // always_comb begin : b2 + // other_stuff = f1(e, f); + // end + // endmodule"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + logic [15:0] data; + logic [9:0] result; + case (data) + 16'd0: result = 10'b0111111111; + 16'd1: result = 10'b1011111111; + 16'd2: result = 10'b1101111111; + 16'd3: result = 10'b1110111111; + 16'd4: result = 10'b1111011111; + 16'd5: result = 10'b1111101111; + 16'd6: result = 10'b1111110111; + 16'd7: result = 10'b1111111011; + 16'd8: result = 10'b1111111101; + 16'd9: result = 10'b1111111110; + default result = 'x; + endcase + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + case (select[1:2]) + 2'b00: result = 0; + 2'b01: result = flaga; + 2'b0x, + 2'b0z: result = flaga ? 'x : 0; + 2'b10: result = flagb; + 2'bx0, + 2'bz0: result = flagb ? 'x : 0; + default result = 'x; + endcase + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + case (sig) + 1'bz: $display("signal is floating"); + 1'bx: $display("signal is unknown"); + default: $display("signal is %b", sig); + endcase + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + logic [7:0] ir; + + casez (ir) + 8'b1???????: instruction1(ir); + 8'b01??????: instruction2(ir); + 8'b00010???: instruction3(ir); + 8'b000001??: instruction4(ir); + endcase + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + logic [7:0] r, mask; + + mask = 8'bx0x0x0x0; + casex (r ^ mask) + 8'b001100xx: stat1; + 8'b1100xx00: stat2; + 8'b00xx0011: stat3; + 8'bxx010100: stat4; + endcase + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + logic [2:0] encode ; + + case (1) + encode[2] : $display("Select Line 2") ; + encode[1] : $display("Select Line 1") ; + encode[0] : $display("Select Line 0") ; + default $display("Error: One of the bits expected ON"); + endcase + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + bit [2:0] a; + unique case(a) // values 3,5,6,7 cause a violation report + 0,1: $display("0 or 1"); + 2: $display("2"); + 4: $display("4"); + endcase + + priority casez(a) // values 4,5,6,7 cause a violation report + 3'b00?: $display("0 or 1"); + 3'b0??: $display("2 or 3"); + endcase + + unique0 case(a) // values 3,5,6,7 do not cause a violation report + 0,1: $display("0 or 1"); + 2: $display("2"); + 4: $display("4"); + endcase + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always_comb begin + not_a = !a; + end + + always_comb begin : a1 + unique case (1'b1) + a : z = b; + not_a : z = c; + endcase + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"logic [2:0] status; + always @(posedge clock) + priority case (status) inside + 1, 3 : task1; // matches 'b001 and 'b011 + 3'b0?0, [4:7]: task2; // matches 'b000 'b010 'b0x0 'b0z0 + // 'b100 'b101 'b110 'b111 + endcase // priority case fails all other values including + // 'b00x 'b01x 'bxxx"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + typedef union tagged { + void Invalid; + int Valid; + } VInt; + + VInt v; + + case (v) matches + tagged Invalid : $display ("v is Invalid"); + tagged Valid .n : $display ("v is Valid with value %d", n); + endcase + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + typedef union tagged { + struct { + bit [4:0] reg1, reg2, regd; + } Add; + union tagged { + bit [9:0] JmpU; + struct { + bit [1:0] cc; + bit [9:0] addr; + } JmpC; + } Jmp; + } Instr; + + Instr instr; + + case (instr) matches + tagged Add '{.r1, .r2, .rd} &&& (rd != 0) : rf[rd] = rf[r1] + rf[r2]; + tagged Jmp .j : case (j) matches + tagged JmpU .a : pc = pc + a; + tagged JmpC '{.c, .a}: if (rf[c]) pc = a; + endcase + endcase + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + case (instr) matches + tagged Add '{.*, .*, 0} : ; // no op + tagged Add '{.r1, .r2, .rd} : rf[rd] = rf[r1] + rf[r2]; + tagged Jmp .j : case (j) matches + tagged JmpU .a : pc = pc + a; + tagged JmpC '{.c, .a} : if (rf[c]) pc = a; + endcase + endcase + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + case (instr) matches + tagged Add s: case (s) matches + '{.*, .*, 0} : ; // no op + '{.r1, .r2, .rd} : rf[rd] = rf[r1] + rf[r2]; + endcase + tagged Jmp .j: case (j) matches + tagged JmpU .a : pc = pc + a; + tagged JmpC '{.c, .a} : if (rf[c]) pc = a; + endcase + endcase + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // case (instr) matches + // tagged Add '{.r1, .r2, .rd} &&& (rd != 0) : rf[rd] = rf[r1] + rf[r2]; + // tagged Jmp (tagged JmpU .a) : pc = pc + a; + // tagged Jmp (tagged JmpC '{.c, .a}) : if (rf[c]) pc = a; + // endcase + // end"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"initial begin + // case (instr) matches + // tagged Add '{reg2:.r2,regd:.rd,reg1:.r1} &&& (rd != 0): + // rf[rd] = rf[r1] + rf[r2]; + // tagged Jmp (tagged JmpU .a) : pc = pc + a; + // tagged Jmp (tagged JmpC '{addr:.a,cc:.c}) : if (rf[c]) pc = a; + // endcase + // end"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"initial begin + // if (e matches (tagged Jmp (tagged JmpC '{cc:.c,addr:.a}))) + // ; // c and a can be used here + // else + // ; + // end"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"initial begin + // if (e matches (tagged Jmp .j) &&& + // j matches (tagged JmpC '{cc:.c,addr:.a})) + // ; // c and a can be used here + // else + // ; + // end"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"initial begin + // if (e matches (tagged Jmp (tagged JmpC '{cc:.c,addr:.a})) + // &&& (rf[c] != 0)) + // ; // c and a can be used here + // else + // ; + // end"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"module m; + // initial begin + // for (int i = 0; i <= 255; i++) + // end + + // initial begin + // loop2: for (int i = 15; i >= 0; i--) + // end + // endmodule"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"module m; + // initial begin + // begin + // automatic int i; + // for (i = 0; i <= 255; i++) + // end + // end + + // initial begin + // begin : loop2 + // automatic int i; + // for (i = 15; i >= 0; i--) + // end + // end + // endmodule"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + for ( int count = 0; count < 3; count++ ) + value = value +((a[count]) * (count+1)); + + for ( int count = 0, done = 0, j = 0; j * count < 125; j++, count++) + $display("Value j = %d\n", j ); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + parameter size = 8, longsize = 16; + logic [size:1] opa, opb; + logic [longsize:1] result; + + begin : mult + logic [longsize:1] shift_opa, shift_opb; + shift_opa = opa; + shift_opb = opb; + result = 0; + repeat (size) begin + if (shift_opb[1]) + result = result + shift_opa; + shift_opa = shift_opa << 1; + shift_opb = shift_opb >> 1; + end + end + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + string words [2] = '{ "hello", "world" }; + int prod [1:8] [1:3]; + + foreach( words [ j ] ) + $display( j , words[j] ); // print each index and value + + foreach( prod[ k, m ] ) + prod[k][m] = k * m; // initialize + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + begin : count1s + logic [7:0] tempreg; + count = 0; + tempreg = data; + while (tempreg) begin + if (tempreg[0]) + count++; + tempreg >>= 1; + end + end + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + string s; + if ( map.first( s ) ) + do + $display( "%s : %d\n", s, map[ s ] ); + while ( map.next( s ) ); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + clock1 <= 0; + clock2 <= 0; + fork + forever #10 clock1 = ~clock1; + #5 forever #10 clock2 = ~clock2; + join + end"##, + Ok((_, _)) + ); + } + + #[test] + fn clause13() { + test!( + many1(module_item), + r##"initial begin + switch_bytes (old_word, new_word); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + new_word = switch_bytes (old_word); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"task mytask1 (output int x, input logic y); + endtask + + task mytask2; + output x; + input y; + int x; + logic y; + endtask"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"task mytask3(a, b, output logic [15:0] u, v); + endtask"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"task mytask4(input [3:0][7:0] a, b[3:0], output [3:0][7:0] y[1:0]); + endtask"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"task my_task; + input a, b; + inout c; + output d, e; + c = a; // the assignments that initialize result outputs + d = b; + e = c; + endtask"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"task my_task (input a, b, inout c, output d, e); + c = a; // the assignments that initialize result variables + d = b; + e = c; + endtask"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial + my_task (v, w, x, y, z);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + a = v; + b = w; + c = x; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + x = c; + y = d; + z = e; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module traffic_lights; + logic clock, red, amber, green; + parameter on = 1, off = 0, red_tics = 350, + amber_tics = 30, green_tics = 200; + + // initialize colors + initial red = off; + initial amber = off; + initial green = off; + + always begin // sequence to control the lights + red = on; // turn red light on + light(red, red_tics); // and wait. + green = on; // turn green light on + light(green, green_tics); // and wait. + amber = on; // turn amber light on + light(amber, amber_tics); // and wait. + end + + // task to wait for 'tics' positive edge clocks + // before turning 'color' light off + task light (output color, input [31:0] tics); + repeat (tics) @ (posedge clock); + color = off; // turn light off. + endtask: light + + always begin // waveform for the clock + #100 clock = 0; + #100 clock = 1; + end + endmodule: traffic_lights"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"function logic [15:0] myfunc1(int x, int y); + endfunction + + function logic [15:0] myfunc2; + input int x; + input int y; + endfunction"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"function logic [15:0] myfunc3(int a, int b, output logic [15:0] u, v); + endfunction"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"function [3:0][7:0] myfunc4(input [3:0][7:0] a, b[3:0]); + endfunction"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"function [15:0] myfunc1 (input [7:0] x,y); + myfunc1 = x * y - 1; // return value assigned to function name + endfunction + + function [15:0] myfunc2 (input [7:0] x,y); + return x * y - 1; //return value is specified using return statement + endfunction"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // a = b + myfunc1(c, d); // call myfunc1 (defined above) as an expression + + // myprint(a); // call myprint (defined below) as a statement + + // function void myprint (int a); + // endfunction + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + void'(some_function()); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module tryfact; + // define the function + function automatic integer factorial (input [31:0] operand); + if (operand >= 2) + factorial = factorial (operand - 1) * operand; + else + factorial = 1; + endfunction: factorial + + // test the function + integer result; + initial begin + for (int n = 0; n <= 7; n++) begin + result = factorial(n); + $display("%0d factorial=%0d", n, result); + end + end + endmodule: tryfact"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"module ram_model (address, write, chip_select, data); + // parameter data_width = 8; + // parameter ram_depth = 256; + // localparam addr_width = clogb2(ram_depth); + // input [addr_width - 1:0] address; + // input write, chip_select; + // inout [data_width - 1:0] data; + + // //define the clogb2 function + // function integer clogb2 (input [31:0] value); + // value = value - 1; + // for (clogb2 = 0; value > 0; clogb2 = clogb2 + 1) + // value = value >> 1; + // endfunction + + // logic [data_width - 1:0] data_store[0:ram_depth - 1]; + // //the rest of the ram model + // endmodule: ram_model"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"ram_model #(32,421) ram_a0(a_addr,a_wr,a_cs,a_data);"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"class IntClass; + // int a; + // endclass + + // IntClass address=new(), stack=new(); + + // function automatic bit watch_for_zero( IntClass p ); + // fork + // forever @p.a begin + // if ( p.a == 0 ) $display (“Unexpected zero”); + // end + // join_none + // return ( p.a == 0 ); + // endfunction + + // function bit start_check(); + // return ( watch_for_zero( address ) | watch_for_zero( stack ) ); + // endfunction + + // bit y = watch_for_zero( stack ); // illegal + + // initial if ( start_check() ) $display ( “OK”); // legal + + // initial fork + // if (start_check() ) $display( “OK too”); // legal + // join_none"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"function automatic int crc( byte packet [1000:1] ); + for( int j= 1; j <= 1000; j++ ) begin + crc ^= packet[j]; + end + endfunction"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // subroutine( ref type argument ); + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"function automatic int crc( ref byte packet [1000:1] ); + for( int j= 1; j <= 1000; j++ ) begin + crc ^= packet[j]; + end + endfunction"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + byte packet1[1000:1]; + int k = crc( packet1 ); // pass by value or by reference: call is the same + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"task automatic incr( ref input int a );// incorrect: ref cannot be qualified"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"task automatic show ( const ref byte data [] ); + for ( int j = 0; j < data.size ; j++ ) + $display( data[j] ); // data can be read but not written + endtask"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"task read(int j = 0, int k, int data = 1 ); + // endtask"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + read( , 5 ); // is equivalent to read( 0, 5, 1 ); + read( 2, 5 ); // is equivalent to read( 2, 5, 1 ); + read( , 5, ); // is equivalent to read( 0, 5, 1 ); + read( , 5, 7 ); // is equivalent to read( 0, 5, 7 ); + read( 1, 5, 2 ); // is equivalent to read( 1, 5, 2 ); + read( ); // error; k has no default value + read( 1, , 7 ); // error; k has no default value + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"module m; + // logic a, w; + + // task t1 (output o = a) ; // default binds to m.a + // endtask :t1 + + // task t2 (output o = b) ; // illegal, b cannot be resolved + // endtask :t2 + + // task t3 (inout io = w) ; // default binds to m.w + // endtask :t1 + // endmodule :m + + // module n; + // logic a; + + // initial begin + // m.t1(); // same as m.t1(m.a), not m.t1(n.a); + // // at end of task, value of t1.o is copied to m.a + // m.t3(); // same as m.t3(m.w) + // // value of m.w is copied to t3.io at start of task and + // // value of t3.io is copied to m.w at end of task + // end + // endmodule :n"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"function int fun( int j = 1, string s = "no" ); + // endfunction"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + fun( .j(2), .s("yes") ); // fun( 2, "yes" ); + fun( .s("yes") ); // fun( 1, "yes" ); + fun( , "yes" ); // fun( 1, "yes" ); + fun( .j(2) ); // fun( 2, "no" ); + fun( .s("yes"), .j(2) ); // fun( 2, "yes" ); + fun( .s(), .j() ); // fun( 1, "no" ); + fun( 2 ); // fun( 2, "no" ); + fun( ); // fun( 1, "no" ); + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // fun( .s("yes"), 2 ); // illegal + // fun( 2, .s("yes") ); // OK + // end"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"virtual class C#(parameter DECODE_W, parameter ENCODE_W = $clog2(DECODE_W)); + // static function logic [ENCODE_W-1:0] ENCODER_f + // (input logic [DECODE_W-1:0] DecodeIn); + // ENCODER_f = '0; + // for (int i=0; i (posedge clk1) + // end + // endmodule + // endmodule"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"clocking cb @(negedge clk); + input v; + endclocking + + always @(cb) $display(cb.v); + + always @(negedge clk) $display(cb.v);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module top; + logic clk1, clk2; + global clocking sys @(clk1 or clk2); endclocking + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module top; + subsystem1 sub1(); + subsystem2 sub2(); + endmodule + + module subsystem1; + logic subclk1; + global clocking sub_sys1 @(subclk1); endclocking + common_sub common(); + endmodule + + module subsystem2; + logic subclk2; + global clocking sub_sys2 @(subclk2); endclocking + common_sub common(); + endmodule + + module common_sub; + always @($global_clock) begin + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module top; + subsystem1 sub1(); + subsystem2 sub2(); + endmodule + + module subsystem1; + logic subclk1, req, ack; + global clocking sub_sys1 @(subclk1); endclocking + common_checks checks(req, ack); + endmodule + + module subsystem2; + logic subclk2, req, ack; + global clocking sub_sys2 @(subclk2); endclocking + common_checks checks(req, ack); + endmodule + + module another_module; + logic another_clk; + global clocking another_clocking @(another_clk); endclocking + property p(req, ack); + @($global_clock) req |=> ack; + endproperty + endmodule + + checker common_checks(logic req, logic ack); + assert property (another_module.p(req, ack)); + endchecker"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module top; + subsystem1 sub1(); + subsystem2 sub2(); + endmodule + + module subsystem1; + logic subclk1, req, ack; + global clocking sub_sys1 @(subclk1); endclocking + always another_module.t(req, ack); + endmodule + + module subsystem2; + logic subclk2, req, ack; + global clocking sub_sys2 @(subclk2); endclocking + always another_module.t(req, ack); + endmodule + + module another_module; + logic another_clk; + global clocking another_clocking @(another_clk); endclocking + task t(input req, input ack); + @($global_clock); + endtask + endmodule"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"module top; + // logic a, b, c, clk; + // global clocking top_clocking @(clk); endclocking + + // property p1(req, ack); + // @($global_clock) req |=> ack; + // endproperty + + // property p2(req, ack, interrupt); + // @($global_clock) accept_on(interrupt) p1(req, ack); + // endproperty + + // my_checker check( + // p2(a, b, c), + // @$global_clock a[*1:$] ##1 b); + // endmodule + + // checker my_checker(property p, sequence s); + // logic checker_clk; + // global clocking checker_clocking @(checker_clk); endclocking + // assert property (p); + // cover property (s); + // endchecker"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + @(ram_bus.ack_l); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + @(ram_bus); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + @(posedge ram_bus.enable); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + @(negedge dom.sign[a]); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + @(posedge dom.sig1 or dom.sig2); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + @(negedge dom.sig1 or posedge dom.sig2); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + @(edge dom.sig1); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + @(negedge dom.sig1 or posedge dom.sig1); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + bus.data[3:0] <= 4'h5; // drive data in Re-NBA region of the current cycle + + ##1 bus.data <= 8'hz; // wait 1 default clocking cycle, then drive data + + ##2; bus.data <= 2; // wait 2 default clocking cycles, then drive data + + bus.data <= ##2 r; // remember the value of r and then drive + // data 2 (bus) cycles later + + bus.data <= #4 r; // error: regular intra-assignment delay not allowed + // in synchronous drives + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"default clocking cb @(posedge clk); // Assume clk has a period of #10 units + output v; + endclocking + + initial begin + #3 cb.v <= expr1; // Matures in cycle 1; equivalent to ##1 cb.v <= expr1 + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"clocking cb @(posedge clk); + inout a; + output b; + endclocking + + initial begin + cb.a <= c; // The value of a will change in the Re-NBA region + cb.b <= cb.a; // b is assigned the value of a before the change + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"default clocking pe @(posedge clk); + output nibble; // four bit output + endclocking + + initial begin + ##2; + pe.nibble <= 4'b0101; + pe.nibble <= 4'b0011; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module m; + bit a = 1'b1; + default clocking cb @(posedge clk); + output a; + endclocking + + initial begin + ## 1; + cb.a <= 1'b0; + @(x); // x is triggered by reactive stimulus running in same time step + cb.a <= 1'b1; + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"bit v; + default clocking cb @(posedge clk); + output v; + endclocking + + initial begin + ##1; // Wait until cycle 1 + cb.v <= expr1; // Matures in cycle 1, v is assigned expr1 + cb.v <= ##2 expr2; // Matures in cycle 3 + #1 cb.v <= ##2 expr3; // Matures in cycle 3 + ##1 cb.v <= ##1 expr4; // Matures in cycle 3, v is assigned expr4 + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"reg j; + + clocking pe @(posedge clk); + output j; + endclocking + + clocking ne @(negedge clk); + output j; + endclocking"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"reg j; + clocking e @(edge clk); + output j; + endclocking"##, + Ok((_, _)) + ); + } + + #[test] + fn clause15() { + test!( + many1(module_item), + r##"initial begin + semaphore smTx; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + mailbox mbxRcv; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + typedef mailbox #(string) s_mbox; + + s_mbox sm = new; + string s; + + sm.put( "hello" ); + sm.get( s ); // s <- "hello" + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + @ hierarchical_event_identifier; + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + wait ( hierarchical_event_identifier.triggered ); + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // event done, blast; // declare two new events + // event done_too = done; // declare done_too as alias to done + + // task trigger( event ev ); + // -> ev; + // endtask + + // fork + // @ done_too; // wait for done through done_too + // #1 trigger( done ); // trigger done through task trigger + // join + + // fork + // -> blast; + // wait ( blast.triggered ); + // join + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + wait_order( a, b, c); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + wait_order( a, b, c ) else $display( "Error: events out of order" ); + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // bit success; + // wait_order( a, b, c ) success = 1; else success = 0; + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"initial begin + event a, b, c; + a = b; + -> c; + -> a; // also triggers b + -> b; // also triggers a + a = c; + b = a; + -> a; // also triggers b and c + -> b; // also triggers a and c + -> c; // also triggers a and b + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + fork + T1: forever @ E2; + T2: forever @ E1; + T3: begin + E2 = E1; + forever -> E2; + end + join + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + event E1 = null; + @ E1; // undefined: might block forever or not at all + wait( E1.triggered ); // undefined + -> E1; // no effect + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + event E1, E2; + if ( E1 ) // same as if ( E1 != null ) + E1 = E2; + if ( E1 == E2 ) + $display( "E1 and E2 are the same event" ); + end"##, + Ok((_, _)) + ); + } + + #[test] + fn clause16() { + //test!( + // many1(module_item), + // r##"initial begin + // assert_f: assert(f) $info("passed"); else $error("failed"); + // assume_inputs: assume (in_a || in_b) $info("assumption holds"); + // else $error("assumption does not hold"); + // cover_a_and_b: cover (in_a && in_b) $info("in_a && in_b == 1 covered"); + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"time t; + + always @(posedge clk) + if (state == REQ) + assert (req1 || req2) + else begin + t = $time; + #5 $error("assert failed at time %0t",t); + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"initial begin + // assert (myfunc(a,b)) count1 = count + 1; else ->event1; + // assert (y == 0) else flag = 1; + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"assign not_a = !a; + always_comb begin : b1 + a1: assert (not_a != a); + a2: assert #0 (not_a != a); // Should pass once values have settled + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"always @(a or b) begin : b1 + // a3: assert #0 (a == b) rptobj.success(0); else rptobj.error(0, a, b); + // #1; + // a4: assert #0 (a == b) rptobj.success(1); else rptobj.error(1, a, b); + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"always_comb begin : b1 + c1: cover (b != a); + c2: cover #0 (b != a); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"function f(bit v); + p: assert #0 (v); + endfunction + always_comb begin: myblk + a = b || f(c); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"function int error_type (int opcode); + func_assert: assert (opcode < 64) else $display("Opcode error."); + if (opcode < 32) + return (0); + else + return (1); + endfunction + + always_comb begin : b1 + a1: assert #0 (my_cond) else + $error("Error on operation of type %d\n", error_type(opcode)); + a2: assert #0 (my_cond) else + error_type(opcode); + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"module dut(input logic clk, input logic a, input logic b); + // logic c; + // always_ff @(posedge clk) + // c <= b; + // a1: assert #0 (!(a & c)) $display("Pass"); else $display("Fail"); + // a2: assert final (!(a & c)) $display("Pass"); else $display("Fail"); + // endmodule + + // program tb(input logic clk, output logic a, output logic b); + // default clocking m @(posedge clk); + // default input #0; + // default output #0; + // output a; + // output b; + // endclocking + + // initial begin + // a = 1; + // b = 0; + // ##10; + // b = 1; + // ##1; + // a = 0; + // end + // endprogram + + // module sva_svtb; + // bit clk; + // logic a, b; + // dut dut (.*); + // tb tb (.*); + // endmodule"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"module m (input a, b); + a1: assert #0 (a == b); + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module m (input a, b); + always_comb begin + a1: assert #0 (a == b); + end + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @(bad_val or bad_val_ok) begin : b1 + a1: assert #0 (bad_val) else $fatal(1, "Sorry"); + if (bad_val_ok) begin + disable a1; + end + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @(a or b or c) begin : b2 + if (c == 8'hff) begin + a2: assert #0 (a && b); + end else begin + a3: assert #0 (a || b); + end + end + + always @(clear_b2) begin : b3 + disable b2; + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"module fsm(); + // function bit f (int a, int b) + // a1: assert #0 (a == b); + // endfunction + + // always_comb begin : b1 + // some_stuff = f(x,y); + // end + + // always_comb begin : b2 + // other_stuff = f(z,w); + // end + // endmodule"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"global clocking @clk; endclocking + // assert property(@$global_clock a);"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"assert property(@clk a);"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"base_rule1: assert property (cont_prop(rst,in1,in2)) $display("%m, passing"); + // else $display("%m, failed");"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"bit a; + integer b; + byte q[$]; + + property p1; + $rose(a) |-> q[0]; + endproperty + + property p2; + integer l_b; + ($rose(a), l_b = b) |-> ##[3:10] q[l_b]; + endproperty"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"bit [2:0] count; + // realtime t; + + // initial count = 0; + // always @(posedge clk) begin + // if (count == 0) t = $realtime; //capture t in a procedural context + // count++; + // end + + // property p1; + // @(posedge clk) + // count == 7 |-> $realtime – t < 50.5; + // endproperty + + // property p2; + // realtime l_t; + // @(posedge clk) + // (count == 0, l_t = $realtime) ##1 (count == 7)[->1] |-> + // $realtime – l_t < 50.5; + // endproperty"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"sequence delay_example(x, y, min, max, delay1); + x ##delay1 y[*min:max]; + endsequence + + // Legal + a1: assert property (@(posedge clk) delay_example(x, y, 3, $, 2)); + + int z, d; + + // Illegal: z and d are not elaboration-time constants + a2_illegal: assert property (@(posedge clk) delay_example(x, y, z, $, d));"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence s1; + @(posedge clk) a ##1 b ##1 c; + endsequence + sequence s2; + @(posedge clk) d ##1 e ##1 f; + endsequence + sequence s3; + @(negedge clk) g ##1 h ##1 i; + endsequence + sequence s4; + @(edge clk) j ##1 k ##1 l; + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence s20_1(data,en); + (!frame && (data==data_bus)) ##1 (c_be[0:3] == en); + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence s; + a ##1 b ##1 c; + endsequence + sequence rule; + @(posedge sysclk) + trans ##1 start_trans ##1 s ##1 end_trans; + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence rule; + @(posedge sysclk) + trans ##1 start_trans ##1 (a ##1 b ##1 c) ##1 end_trans ; + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence s1; + @(posedge sysclk) (x ##1 s2); + endsequence + sequence s2; + @(posedge sysclk) (y ##1 s1); + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence s1(w, x, y); + w ##1 x ##[2:10] y; + endsequence + sequence s2(w, y, bit x); + w ##1 x ##[2:10] y; + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence delay_arg_example (max, shortint delay1, delay2, min); + x ##delay1 y[*min:max] ##delay2 z; + endsequence + + parameter my_delay=2; + cover property (delay_arg_example($, my_delay, my_delay-1, 3));"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"cover property (x ##2 y[*3:$] ##1 z);"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"sequence event_arg_example (event ev); + // @(ev) x ##1 y; + // endsequence + + // cover property (event_arg_example(posedge clk));"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"cover property (@(posedge clk) x ##1 y));"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"sequence event_arg_example2 (reg sig); + @(posedge sig) x ##1 y; + endsequence + + cover property (event_arg_example2(clk));"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"cover property (@(posedge clk) x ##1 y));"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"sequence s(bit a, bit b); + bit loc_a; + (1'b1, loc_a = a) ##0 + (t == loc_a) [*0:$] ##1 b; + endsequence"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"logic b_d, d_d; + // sequence legal_loc_var_formal ( + // local inout logic a, + // local logic b = b_d, // input inferred, default actual argument b_d + // c, // local input logic inferred, no default + // // actual argument + // d = d_d, // local input logic inferred, default actual + // // argument d_d + // logic e, f // e and f are not local variable formal arguments + // ); + // logic g = c, h = g || d; + // endsequence"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"sequence illegal_loc_var_formal ( + // output logic a, // illegal: local must be specified with + // // direction + // local inout logic b, + // c = 1'b0,// default actual argument illegal for inout + // local d = expr, // illegal: type must be specified explicitly + // local event e, // illegal: event is a type disallowed in + // // 16.6 + // local logic f = g // g shall not refer to the local variable + // // below and must be resolved upward from + // // this declaration + // ); + // logic g = b; + // endsequence"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"sequence sub_seq2(local inout int lv); + // (a ##1 !a, lv += data_in) + // ##1 !b[*0:$] ##1 b && (data_out == lv); + // endsequence + // sequence seq2; + // int v1; + // (c, v1 = data) + // ##1 sub_seq2(v1) // lv is initialized by assigning it the value of v1; + // // when the instance sub_seq2(v1) matches, v1 is + // // assigned the value of lv + // ##1 (do1 == v1); + // endsequence"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"sequence seq2_inlined; + int v1, lv; + (c, v1 = data) ##1 + ( + (1, lv = v1) ##0 + (a ##1 !a, lv += data_in) + ##1 (!b[*0:$] ##1 b && (data_out == lv), v1 = lv) + ) + ##1 (do1 == v1); + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"logic a, b, clk; + // ... + a1_bad: assert property (@clk a == b) + else $error("Different values: a = %b, b = %b", a, b); + a2_ok: assert property (@clk a == b) + else $error("Different values: a = %b, b = %b", + $sampled(a), $sampled(b));"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @(posedge clk) + reg1 <= a & $rose(b);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial begin + $past(in1, , enable); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @(posedge clk) + reg1 <= a & $past(b);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @(posedge clk) + for (int i = 0; i < 4; i ++) + if (cond[i]) + reg1[i] <= $past(b[i]);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @(posedge clk) + if (enable) q <= d; + + always @(posedge clk) + assert property (done |=> (out == $past(q, 2,enable)) );"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"bit clk, fclk, req, gnt, en; + + // a1: assert property + // (@(posedge clk) en && $rose(req) |=> gnt); + // a2: assert property + // (@(posedge clk) en && $rose(req, @(posedge fclk)) |=> gnt);"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"always_ff @(posedge clk1) + // reg1 <= $rose(b, @(posedge clk2));"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"always @(posedge clk) begin + @(negedge clk2); + x = $past(y, 5); // illegal if not within default clocking + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"a1: assert property (@clk $future_gclk(a || $rising_gclk(b)); + // sequence s; + // bit v; + // (a, v = a) ##1 (b == v)[->1]; + // endsequence : s + + // // Illegal: a global clocking future sampled value function shall not + // // be used in an assertion containing sequence match items + // a2: assert property (@clk s |=> $future_gclk(c));"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"a1: assert property (@$global_clock $changing_gclk(sig) + // |-> $falling_gclk(clk)) + // else $error(”sig is not stable”);"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"a2: assume property(@$global_clock + // $falling_gclk(clk) ##1 (!$falling_gclk(clk)[*1:$]) |-> + // $steady_gclk(sig));"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"a3: assert property (@$global_clock disable iff (rst) $changing_gclk(sig) + // |-> $falling_gclk(clk)) + // else $error(”sig is not stable”);"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"a4: assert property (##1 $stable_gclk(sig)); + // In a5, there is no issue at cycle 0 + a5: assert property ($steady_gclk(sig));"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence t1; + te1 ## [2:5] te2; + endsequence + sequence ts1; + first_match(te1 ## [2:5] te2); + endsequence"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"sequence t2; + // (a ##[2:3] b) or (c ##[1:2] d); + // endsequence + // sequence ts2; + // first_match(t2); + // endsequence"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"sequence burst_rule1; + // @(posedge mclk) + // $fell(burst_mode) ##0 + // ((!burst_mode) throughout (##2 ((trdy==0)&&(irdy==0)) [*7])); + // endsequence"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"sequence s; + a ##1 b ##1 c; + endsequence + sequence rule; + @(posedge sysclk) + trans ##1 start_trans ##1 s ##1 end_trans; + endsequence"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"sequence e1; + // @(posedge sysclk) $rose(ready) ##1 proc1 ##1 proc2 ; + // endsequence + // sequence rule; + // @(posedge sysclk) reset ##1 inst ##1 e1.triggered ##1 branch_back; + // endsequence"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"sequence e2(a,b,c); + // @(posedge sysclk) $rose(a) ##1 b ##1 c; + // endsequence + // sequence rule2; + // @(posedge sysclk) reset ##1 inst ##1 e2(ready,proc1,proc2).triggered + // ##1 branch_back; + // endsequence"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"sequence e2_instantiated; + e2(ready,proc1,proc2); + endsequence + sequence rule2a; + @(posedge sysclk) reset ##1 inst ##1 e2_instantiated.triggered ##1 + branch_back; + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence e3(sequence a, untyped b); + @(posedge sysclk) a.triggered ##1 b; + endsequence + + sequence rule3; + @(posedge sysclk) reset ##1 e3(ready ##1 proc1, proc2) ##1 branch_back; + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence zero_or_one_req; + (req==1'b1)[*0:1]; + endsequence"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"sequence s; + // logic u, v = a, w = v || b; + // endsequence"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"property e; + int x; + (valid_in, x = pipe_in) |-> ##5 (pipe_out1 == (x+1)); + endproperty"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"sequence data_check; + // int x; + // a ##1 (!a, x = data_in) ##1 !b[*0:$] ##1 b && (data_out == x); + // endsequence + // property data_check_p + // int x; + // a ##1 (!a, x = data_in) |=> !b[*0:$] ##1 b && (data_out == x); + // endproperty"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"sequence rep_v; + int x = 0; + (a[->1], x += data)[*4] ##1 b ##1 c && (data_out == x); + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence count_a_cycles; + int x; + ($rose(a), x = 1) + ##1 (a, x++)[*0:$] + ##1 !a && (x <= MAX); + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence sub_seq1; + int v1; + (a ##1 !a, v1 = data_in) ##1 !b[*0:$] ##1 b && (data_out == v1); + endsequence + sequence seq1; + c ##1 sub_seq1 ##1 (do1 == v1); // error because v1 is not visible + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence sub_seq2(lv); + (a ##1 !a, lv = data_in) ##1 !b[*0:$] ##1 b && (data_out == lv); + endsequence + sequence seq2; + int v1; + c ##1 sub_seq2(v1) // v1 is bound to lv + ##1 (do1 == v1); // v1 holds the value that was assigned to lv + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence seq2a; + int v1; c ##1 sub_seq2(v1).triggered ##1 (do1 == v1); + // v1 is now bound to lv + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence seq2b; + int v1; c ##1 !sub_seq2(v1).triggered ##1 (do1 == v1); // v1 unassigned + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence sub_seq3(lv); + int lv; // illegal because lv is a formal argument + (a ##1 !a, lv = data_in) ##1 !b[*0:$] ##1 b && (data_out == lv); + endsequence"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"sequence s4; + // int x; + // (a ##1 (b, x = data) ##1 c) or (d ##1 (e==x)); // illegal + // endsequence"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"sequence s5; + // int x,y; + // ((a ##1 (b, x = data, y = data1) ##1 c) + // or (d ##1 (`true, x = data) ##0 (e==x))) ##1 (y==data2); + // // illegal because y is not in the intersection + // endsequence + // sequence s6; + // int x,y; + // ((a ##1 (b, x = data, y = data1) ##1 c) + // or (d ##1 (`true, x = data) ##0 (e==x))) ##1 (x==data2); + // // legal because x is in the intersection + // endsequence"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"sequence s7; + // int x,y; + // ((a ##1 (b, x = data, y = data1) ##1 c) + // and (d ##1 (`true, x = data) ##0 (e==x))) ##1 (x==data2); + // // illegal because x is common to both threads + // endsequence + // sequence s8; + // int x,y; + // ((a ##1 (b, x = data, y = data1) ##1 c) + // and (d ##1 (`true, x = data) ##0 (e==x))) ##1 (y==data2); + // // legal because y is in the difference + // endsequence"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"sequence s1; + logic v, w; + (a, v = e) ##1 + (b[->1], w = f, $display("b after a with v = %h, w = %h\n", v, w)); + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property p3; + b ##1 c; + endproperty + + c1: cover property (@(posedge clk) a #-# p3); + a1: assert property (@(posedge clk) a |-> p3);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"a1: assert property (@clk not a ##1 b);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"a2: assert property (@clk not strong(a ##1 b));"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"let ready_exp = (irdy == 0) && ($fell(trdy) || $fell(stop)); + property data_end; + @(posedge mclk) + $rose(data_phase) |-> ##[1:5] ready_exp; + endproperty + a1: assert property(data_end);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"let data_end_exp = data_phase && ready_exp; + property data_end_rule1; + @(posedge mclk) + data_end_exp |-> ##[1:2] $rose(frame) ##1 $rose(irdy); + endproperty + a2: assert property(data_end_rule1);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property data_end_rule2; + @(posedge mclk) ##[1:2] $rose(frame) ##1 $rose(irdy); + endproperty + a3: assert property(data_end_rule2);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property write_to_addr; + (write_en & data_valid) ##0 + (write_en && (retire_address[0:4]==addr)) [*2] |-> + ##[3:8] write_en && !data_valid &&(write_address[0:4]==addr); + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property write_to_addr_nested; + (write_en & data_valid) |-> + (write_en && (retire_address[0:4]==addr)) [*2] |-> + ##[3:8] write_en && !data_valid && (write_address[0:4]==addr); + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property p1; + ##[0:5] done #-# always !rst; + endproperty + + property p2; + ##[0:5] done #=# always !rst; + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property p1; + nexttime a; + endproperty + + // the clock shall tick once more and a shall be true at the next clock tick. + property p2; + s_nexttime a; + endproperty + + // as long as the clock ticks, a shall be true at each future clock tick + // starting from the next clock tick + property p3; + nexttime always a; + endproperty + + // the clock shall tick at least once more and as long as it ticks, a shall + // be true at every clock tick starting from the next one + property p4; + s_nexttime always a; + endproperty + + // if the clock ticks at least once more, it shall tick enough times for a to + // be true at some point in the future starting from the next clock tick + property p5; + nexttime s_eventually a; + endproperty + + // a shall be true sometime in the strict future + property p6; + s_nexttime s_eventually a; + endproperty + + // if there are at least two more clock ticks, a shall be true at the second + // future clock tick + property p7; + nexttime[2] a; + endproperty + + // there shall be at least two more clock ticks, and a shall be true at the + // second future clock tick + property p8; + s_nexttime[2] a; + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"implicit_always: assert property(p);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial explicit_always: assert property(always p);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"initial a1: assume property( @(posedge clk) reset[*5] #=# always !reset); + + property p1; + a ##1 b |=> always c; + endproperty + + property p2; + always [2:5] a; + endproperty + + property p3; + s_always [2:5] a; + endproperty + + property p4; + always [2:$] a; + endproperty + + property p5; + s_always [2:$] a; // Illegal + endproperty"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"property p1; + // a until b; + // endproperty + + // property p2; + // a s_until b; + // endproperty + + // property p3; + // a until_with b; + // endproperty + + // property p4; + // a s_until_with b; + // endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property p1; + // s_eventually a; + // endproperty + + // property p2; + // s_eventually always a; + // endproperty + + // property p3; + // always s_eventually a; + // endproperty + + // property p4; + // eventually [2:5] a; + // endproperty + + // property p5; + // s_eventually [2:5] a; + // endproperty + + // property p6; + // eventually [2:$] a; // Illegal + // endproperty + + // property p7; + // s_eventually [2:$] a; + // endproperty"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"assert property (@(clk) go ##1 get[*2] |-> reject_on(stop) put[->2]);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"assert property (@(clk) go ##1 get[*2] |-> sync_reject_on(stop) put[->2]);"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"assert property (@(clk) go ##1 get[*2] |-> !stop throughout put[->2]);"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property p; (accept_on(a) p1) and (reject_on(b) p2); endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property p; (accept_on(a) p1) or (reject_on(b) p2); endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property p; not (accept_on(a) p1); endproperty"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"property p; accept_on(a) reject_on(b) p1; endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property p_delay(logic [1:0] delay); + case (delay) + 2'd0 : a && b; + 2'd1 : a ##2 b; + 2'd2 : a ##4 b; + 2'd3 : a ##8 b; + default: 0; // cause a failure if delay has x or z values + endcase + endproperty"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"property prop_always(p); + // p and (1'b1 |=> prop_always(p)); + // endproperty"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"property p1(s,p); + s |=> prop_always(p); + endproperty"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"property prop_weak_until(p,q); + // q or (p and (1'b1 |=> prop_weak_until(p,q))); + // endproperty"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"property p2(s,p,q); + s |=> prop_weak_until(p,q); + endproperty"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"property check_phase1; + // s1 |-> (phase1_prop and (1'b1 |=> check_phase2)); + // endproperty + // property check_phase2; + // s2 |-> (phase2_prop and (1'b1 |=> check_phase1)); + // endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property illegal_recursion_1(p); + // not prop_always(not p); + // endproperty + + // property illegal_recursion_2(p); + // p and (1'b1 |=> not illegal_recursion_2(p)); + // endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property illegal_recursion_3(p); + // disable iff (b) + // p and (1'b1 |=> illegal_recursion_3(p)); + // endproperty"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"property legal_3(p); + disable iff (b) prop_always(p); + endproperty"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"property illegal_recursion_4(p); + // p and (1'b1 |-> illegal_recursion_4(p)); + // endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property fibonacci1 (local input int a, b, n, int fib_sig); + // (n > 0) + // |-> + // ( + // (fib_sig == a) + // and + // (1'b1 |=> fibonacci1(b, a + b, n - 1, fib_sig)) + // ); + // endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property fibonacci2 (int a, b, n, fib_sig); + // (n > 0) + // |-> + // ( + // (fib_sig == a) + // and + // (1'b1 |=> fibonacci2(b, a + b, n - 1, fib_sig)) + // ); + // endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property p3(p, bit b, abort); + // (p and (1'b1 |=> p4(p, b, abort))); + // endproperty + + // property p4(p, bit b, abort); + // accept_on(b) reject_on(abort) p3(p, b, abort); + // endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property check_write; + // logic [0:127] expected_data; // local variable to sample model data + // logic [3:0] tag; // local variable to sample tag + + // disable iff (reset) + // ( + // write_request && write_request_ack, + // expected_data = model_data, + // tag = write_request_ack_tag + // ) + // |=> + // check_write_data_beat(expected_data, tag, 4'h0); + // endproperty + + // property check_write_data_beat + // ( + // local input logic [0:127] expected_data, + // local input logic [3:0] tag, i + // ); + // ( + // (data_valid && (data_valid_tag == tag)) + // || + // (retry && (retry_tag == tag)) + // )[->1] + // |-> + // ( + // ( + // (data_valid && (data_valid_tag == tag)) + // |-> + // (data == expected_data[i*8+:8]) + // ) + // and + // ( + // if (retry && (retry_tag == tag)) + // ( + // 1'b1 |=> check_write_data_beat(expected_data, tag, 4'h0) + // ) + // else if (!last_data_valid) + // ( + // 1'b1 |=> check_write_data_beat(expected_data, tag, i+4'h1) + // ) + // else + // ( + // ##1 (retry && (retry_tag == tag)) + // |=> + // check_write_data_beat(expected_data, tag, 4'h0) + // ) + // ) + // ); + // endproperty"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"property rule1; + @(posedge clk) a |-> b ##1 c ##1 d; + endproperty + property rule2; + @(clkev) disable iff (e) a |-> not(b ##1 c ##1 d); + endproperty"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"property rule3; + // @(posedge clk) a[*2] |-> ((##[1:3] c) or (d |=> e)); + // endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property rule4; + // @(posedge clk) a[*2] |-> ((##[1:3] c) and (d |=> e)); + // endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property rule5; + // @(posedge clk) + // a ##1 (b || c)[->1] |-> + // if (b) + // (##1 d |-> e) + // else // c + // f ; + // endproperty"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"property rule6(x,y); + ##1 x |-> y; + endproperty + property rule5a; + @(posedge clk) + a ##1 (b || c)[->1] |-> + if (b) + rule6(d,e) + else // c + f ; + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence s1; + a ##1 b; // unclocked sequence + endsequence + sequence s2; + c ##1 d; // unclocked sequence + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence mult_s; + @(posedge clk) a ##1 @(posedge clk1) s1 ##1 @(posedge clk2) s2; + endsequence"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property mult_p1; + @(posedge clk) a ##1 @(posedge clk1) s1 ##1 @(posedge clk2) s2; + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property mult_p2; + mult_s; + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property mult_p3; + @(posedge clk) a ##1 @(posedge clk1) s1 |=> @(posedge clk2) s2; + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property mult_p6; + mult_s |=> mult_s; + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property mult_p7; + @(posedge clk) a ##1 b |-> c ##1 @(posedge clk1) d; + endproperty"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"property mult_p8; + // @(posedge clk) a ##1 b |-> + // if (c) + // (1 |=> @(posedge clk1) d) + // else + // e ##1 @(posedge clk2) f ; + // endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"sequence e1(a,b,c); + // @(posedge clk) $rose(a) ##1 b ##1 c ; + // endsequence + // sequence e2; + // @(posedge sysclk) reset ##1 inst ##1 e1(ready,proc1,proc2).matched [->1] + // ##1 branch_back; + // endsequence"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"sequence e1; + // @(posedge sysclk) $rose(a) ##1 b ##1 c; + // endsequence + + // sequence e2; + // @(posedge sysclk) reset ##1 inst ##1 e1.triggered ##1 branch_back; + // endsequence + + // sequence e3; + // @(posedge clk) reset1 ##1 e1.matched ##1 branch_back1; + // endsequence + + // sequence e2_with_arg(sequence subseq); + // @(posedge sysclk) reset ##1 inst ##1 subseq.triggered ##1 branch_back; + // endsequence + + // sequence e4; + // e2_with_arg(@(posedge sysclk) $rose(a) ##1 b ##1 c); + // endsequence + + // program check; + // initial begin + // wait (e1.triggered || e2.triggered); + // if (e1.triggered) + // $display("e1 passed"); + // if (e2.triggered) + // $display("e2 passed"); + // end + // endprogram"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"module mod_sva_checks; + logic a, b, c, d; + logic clk_a, clk_d, clk_e1, clk_e2; + logic clk_c, clk_p; + + clocking cb_prog @(posedge clk_p); endclocking + clocking cb_checker @(posedge clk_c); endclocking + + default clocking cb @(posedge clk_d); endclocking + + sequence e4; + $rose(b) ##1 c; + endsequence + + // e4 infers posedge clk_a as per clock flow rules + a1: assert property (@(posedge clk_a) a |=> e4.triggered); + + sequence e5; + // e4 will infer posedge clk_e1 as per clock flow rules + // wherever e5 is instantiated (with/without a method) + @(posedge clk_e1) a ##[1:3] e4.triggered ##1 c; + endsequence + + // e4, used in e5, infers posedge clk_e1 from e5 + a2: assert property (@(posedge clk_a) a |=> e5.matched); + + sequence e6(f); + @(posedge clk_e2) f; + endsequence + + // e4 infers posedge clk_e2 as per clock flow rules + a3: assert property (@(posedge clk_a) a |=> e6(e4.triggered)); + + sequence e7; + e4 ##1 e6(d); + endsequence + + // Leading clock of e7 is posedge clk_a as per clock flow rules + a4: assert property (@(posedge clk_a) a |=> e7.triggered); + + // Illegal use in a disable condition, e4 is not explicitly clocked + a5_illegal: assert property ( + @(posedge clk_a) disable iff (e4.triggered) a |=> b); + + always @(posedge clk_a) begin + // e4 infers default clocking cb and not posedge clk_a as there is + // more than one event control in this procedure (16.14.6) + @(e4); + d = a; + end + + program prog_e4; + default clocking cb_prog; + initial begin + // e4 infers default clocking cb_prog + wait (e4.triggered); + $display("e4 passed"); + end + endprogram : prog_e4 + + checker check(input in1, input sequence s_f); + default clocking cb_checker; + always @(s_f) + $display("sequence triggered"); + a4: assert property (a |=> in1); + endchecker : check + + // e4 infers checker's default clocking cb_checker + check c1(e4.triggered, e4); + + // e4 connected to port of a module instance infers default clocking cb + mod_adder ai1(e4.triggered); + + endmodule : mod_sva_checks"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"property p; + // logic v = e; + // (@(posedge clk1) (a == v)[*1:$] |-> b) + // and + // (@(posedge clk2) c[*1:$] |-> d == v) + // ; + // endproperty + // a1: assert property (@(posedge clk) f |=> p);"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property p; + // logic v; + // (@(posedge clk1) (1, v = e) ##0 (a == v)[*1:$] |-> b) + // and + // (@(posedge clk2) (1, v = e) ##0 c[*1:$] |-> d == v) + // ; + // endproperty"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property abc(a, b, c); + // disable iff (a==2) @(posedge clk) not (b ##1 c); + // endproperty + // env_prop: assert property (abc(rst, in1, in2)) + // $display("env_prop passed."); else $display("env_prop failed.");"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"property abc(a, b, c); + // disable iff (c) @(posedge clk) a |=> b; + // endproperty + // env_prop: + // assume property (abc(req, gnt, rst)) else $error(”Assumption failed.”);"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"a1:assume property ( @(posedge clk) req dist {0:=40, 1:=60} ) ; + property proto ; + @(posedge clk) req |-> req[*1:$] ##0 ack; + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"a1_assertion:assert property ( @(posedge clk) req inside {0, 1} ) ; + property proto_assertion ; + @(posedge clk) req |-> req[*1:$] ##0 ack; + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property pr1; + @(posedge clk) !reset_n |-> !req; // when reset_n is asserted (0), + // keep req 0 + endproperty + property pr2; + @(posedge clk) ack |=> !req; // one cycle after ack, req + // must be deasserted + endproperty + property pr3; + @(posedge clk) req |-> req[*1:$] ##0 ack; // hold req asserted until + // and including ack asserted + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property pa1; + @(posedge clk) !reset_n || !req |-> !ack; + endproperty + property pa2; + @(posedge clk) ack |=> !ack; + endproperty"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"a1:assume property (@(posedge clk) req dist {0:=40, 1:=60} ); + assume_req1:assume property (pr1); + assume_req2:assume property (pr2); + assume_req3:assume property (pr3); + + assert_ack1:assert property (pa1) + else $error("ack asserted while req is still deasserted"); + assert_ack2:assert property (pa2) + else $error("ack is extended over more than one cycle");"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"restrict property (@(posedge clk) ctr == '0);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module top(input logic clk); + logic a,b,c; + property rule3; + @(posedge clk) a |-> b ##1 c; + endproperty + a1: assert property (rule3); + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module top(input logic clk); + logic a,b,c; + sequence seq3; + @(posedge clk) b ##1 c; + endsequence + c1: cover property (seq3); + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property rule; + a ##1 b ##1 c; + endproperty + always @(posedge clk) begin + assert property (rule); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property r1; + q != d; + endproperty + always @(posedge mclk) begin + q <= d1; + r1_p1: assert property (r1); + r1_p2: assert property (@(posedge scanclk)r1); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property r2; + q != d; + endproperty + always_ff @(posedge clock iff reset == 0 or posedge reset) begin + cnt <= reset ? 0 : cnt + 1; + q <= $past(d1); + r2_p: assert property (r2); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property r3; + q != d; + endproperty + always_ff @(clock iff reset == 0 or posedge reset) begin + cnt <= reset ? 0 : cnt + 1; + q <= $past(d1); // no inferred clock + r3_p: assert property (r3); // no inferred clock + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property r4; + q != d; + endproperty + always @(posedge mclk) begin + #10 q <= d1; // delay prevents clock inference + @(negedge mclk) // event control prevents clock inference + #10 q1 <= !d1; + r4_p: assert property (r4); // no inferred clock + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @(posedge clk) begin + int i = 10; + for (i=0; i<10; i++) begin + a1: assert property (foo[i] && bar[i]); + a2: assert property (foo[const'(i)] && bar[i]); + a3: assert property (foo[const'(i)] && bar[const'(i)]); + end + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"default clocking @(posedge clk); endclocking + generate for (genvar i=0; i<10; i++) begin + a1: assert property (foo[10] && bar[10]); + a2: assert property (foo[i] && bar[10]); + a3: assert property (foo[i] && bar[i]); + end + endgenerate"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @(posedge clk) begin + // variable declared in for statement is automatic (see 12.7.1) + for (int i=0; i<10; i++) begin + a4: assert property (foo[i] && bar[i]); + a5: assert property (foo[const'(i)] && bar[i]); + a6: assert property (foo[const'(i)] && bar[const'(i)]); + end + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"wire w; + always @(posedge clk) begin : procedural_block_1 + if (my_activation_condition == 1) begin + for (int i=0; i<2; i++) begin + a7: assume property (foo[i] |=> bar[i] ##1 (w==1'b1)); + end + end + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @(posedge clk) begin + int i = 10; + for (i=0; i<10; i++) begin + a8: assert property (foo[const'(i)] && bar[i]) else + $error("a8 failed for const i=%d and i=%d", + const'(i), $sampled(i)); + end + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"always @(posedge clk) begin + // if (en) begin + // a9: assert property p1(a,b,c); + // end + // if ($sampled(en)) begin + // a10: assert property p1(a,b,c); + // end + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"assign not_a = !a; + default clocking @(posedge clk); endclocking + always_comb begin : b1 + // Probably better to not use consts in this example + // ...but using them to illustrate effects of flushing method + a1: assert property (const'(not_a) != const'(a)); + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"default clocking @(posedge clk); endclocking + // always @(a or b) begin : b1 + // a2: assert property (a == b) r.success(0) else r.error(0, a, b); + // #1; + // a3: assert property (a == b) r.success(1) else r.error(1, a, b); + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"default clocking @(posedge clk); endclocking + always_comb begin : b1 + c1: cover property (const'(b) != const'(a)); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always_comb begin : procedural_block_1 + if (en) + foo = bar; + end + + always_comb begin : procedural_block_2 + p1: assert property ( @(posedge clk) (const'(foo) == const'(bar)) ); + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"default clocking @(posedge clk); endclocking + always @(bad_val or bad_val_ok) begin : b1 + a1: assert property (bad_val) else $fatal(1, "Sorry"); + if (bad_val_ok) begin + disable a1; + end + end"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"default clocking @(posedge clk); endclocking + always @(a or b or c) begin : b2 + if (c == 8'hff) begin + a2: assert property (a && b); + end else begin + a3: assert property (a || b); + end + end + + always @(clear_b2) begin : b3 + disable b2; + end"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"module m(logic a, b, c, d, rst1, clk1, clk2); + // logic rst; + + // default clocking @(negedge clk1); endclocking + // default disable iff rst1; + + // property p_triggers(start_event, end_event, form, clk = $inferred_clock, + // rst = $inferred_disable); + // @clk disable iff (rst) + // (start_event ##0 end_event[->1]) |=> form; + // endproperty + + // property p_multiclock(clkw, clkx = $inferred_clock, clky, w, x, y, z); + // @clkw w ##1 @clkx x |=> @clky y ##1 z; + // endproperty + + // a1: assert property (p_triggers(a, b, c)); + // a2: assert property (p_triggers(a, b, c, posedge clk1, 1'b0) ); + + // always @(posedge clk2 or posedge rst) begin + // end + + // a4: assert property(p_multiclock(negedge clk2, , posedge clk1, + // a, b, c, d) ); + // endmodule"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"module m(logic a, b, c, d, rst1, clk1, clk2); + logic rst; + + a1: assert property (@(negedge clk1) disable iff (rst1) + a ##0 b[->1] |=> c); + + a2: assert property (@(posedge clk1) disable iff (1'b0) + a ##0 b[->1] |=> c); + + always @(posedge clk2 or posedge rst) begin + end + + a3: assert property + ( + @(posedge clk2) disable iff (rst1) + (a ##0 b[->1]) |=> c + ); + + a4: assert property (@(negedge clk2) a ##1 @(negedge clk1) b |=> + @(posedge clk1) c ##1 d); + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module m1; + bit clk, rst1; + default disable iff rst1; + a1: assert property (@(posedge clk) p1); // property p1 is + // defined elsewhere + module m2; + bit rst2; + a2: assert property (@(posedge clk) p2); // property p2 is + // defined elsewhere + endmodule + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module m1; + bit clk, rst1; + default disable iff rst1; + a1: assert property (@(posedge clk) p1); // property p1 is + // defined elsewhere + module m2; + bit rst2; + default disable iff rst2; + a2: assert property (@(posedge clk) p2); // property p2 is + // defined elsewhere + endmodule + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"module examples_with_default (input logic a, b, clk, rst, rst1); + default disable iff rst; + property p1; + disable iff (rst1) a |=> b; + endproperty + + // Disable condition is rst1 - explicitly specified within a1 + a1 : assert property (@(posedge clk) disable iff (rst1) a |=> b); + + // Disable condition is rst1 - explicitly specified within p1 + a2 : assert property (@(posedge clk) p1); + + // Disable condition is rst - no explicit specification, inferred from + // default disable iff declaration + a3 : assert property (@(posedge clk) a |=> b); + + // Disable condition is 1'b0. This is the only way to + // cancel the effect of default disable. + a4 : assert property (@(posedge clk) disable iff (1'b0) a |=> b); + endmodule + + module examples_without_default (input logic a, b, clk, rst); + property p2; + disable iff (rst) a |=> b; + endproperty + + // Disable condition is rst - explicitly specified within a5 + a5 : assert property (@(posedge clk) disable iff (rst) a |=> b); + + // Disable condition is rst - explicitly specified within p2 + a6 : assert property (@ (posedge clk) p2); + + // No disable condition + a7 : assert property (@ (posedge clk) a |=> b); + endmodule"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"sequence s2; @(posedge clk) a ##2 b; endsequence + property p2; not s2; endproperty + assert property (p2);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"property p3; @(posedge clk) not (a ##2 b); endproperty + assert property (p3);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"always @(posedge clk) assert property (not (a ##2 b));"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"clocking master_clk @(posedge clk); + property p3; not (a ##2 b); endproperty + endclocking + assert property (master_clk.p3);"##, + Ok((_, _)) + ); + test!( + many1(module_item), + r##"default clocking master_clk ; // master clock as defined above + property p4; (a ##2 b); endproperty + assert property (p4);"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"module examples_with_default (input logic a, b, c, clk); + // property q1; + // $rose(a) |-> ##[1:5] b; + // endproperty + + // property q2; + // @(posedge clk) q1; + // endproperty + + // default clocking posedge_clk @(posedge clk); + // property q3; + // $fell(c) |=> q1; + // // legal: q1 has no clocking event + // endproperty + + // property q4; + // $fell(c) |=> q2; + // // legal: q2 has clocking event identical to that of + // // the clocking block + // endproperty + + // sequence s1; + // @(posedge clk) b[*3]; + // // illegal: explicit clocking event in clocking block + // endsequence + // endclocking + + // property q5; + // @(negedge clk) b[*3] |=> !b; + // endproperty + + // always @(negedge clk) + // begin + // a1: assert property ($fell(c) |=> q1); + // // legal: contextually inferred leading clocking event, + // // @(negedge clk) + // a2: assert property (posedge_clk.q4); + // // legal: will be queued (pending) on negedge clk, then + // // (if matured) checked at next posedge clk (see 16.14.6) + // a3: assert property ($fell(c) |=> q2); + // // illegal: multiclocked property with contextually + // // inferred leading clocking event + // a4: assert property (q5); + // // legal: contextually inferred leading clocking event, + // // @(negedge clk) + // end + + // property q6; + // q1 and q5; + // endproperty + + // a5: assert property (q6); + // // illegal: default leading clocking event, @(posedge clk), + // // but semantic leading clock is not unique + // a6: assert property ($fell(c) |=> q6); + // // legal: default leading clocking event, @(posedge clk), + // // is the unique semantic leading clock + + // sequence s2; + // $rose(a) ##[1:5] b; + // endsequence + + // c1: cover property (s2); + // // legal: default leading clocking event, @(posedge clk) + // c2: cover property (@(negedge clk) s2); + // // legal: explicit leading clocking event, @(negedge clk) + // endmodule + + // module examples_without_default (input logic a, b, c, clk); + // property q1; + // $rose(a) |-> ##[1:5] b; + // endproperty + + // property q5; + // @(negedge clk) b[*3] |=> !b; + // endproperty + + // property q6; + // q1 and q5; + // endproperty + + // a5: assert property (q6); + // // illegal: no leading clocking event + // a6: assert property ($fell(c) |=> q6); + // // illegal: no leading clocking event + + // sequence s2; + // $rose(a) ##[1:5] b; + // endsequence + + // c1: cover property (s2); + // // illegal: no leading clocking event + // c2: cover property (@(negedge clk) s2); + // // legal: explicit leading clocking event, @(negedge clk) + + // sequence s3; + // @(negedge clk) s2; + // endsequence + + // c3: cover property (s3); + // // legal: leading clocking event, @(negedge clk), + // // determined from declaration of s3 + // c4: cover property (s3 ##1 b); + // // illegal: no default, inferred, or explicit leading + // // clocking event and maximal property is not an instance + // endmodule"##, + // Ok((_, _)) + //); + //test!( + // many1(module_item), + // r##"wire clk1, clk2; + // logic a, b; + // assign clk2 = clk1; + // a1: assert property (@(clk1) a and @(clk2) b); // Illegal + // a2: assert property (@(clk1) a and @(clk1) b); // OK + // always @(posedge clk1) begin + // a3: assert property(a and @(posedge clk2)); //Illegal + // a4: assert property(a and @(posedge clk1)); // OK + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"program tst; + initial begin + # 200ms; + expect( @(posedge clk) a ##1 b ##1 c ) else $error( "expect failed" ); + end + endprogram"##, + Ok((_, _)) + ); + //test!( + // many1(module_item), + // r##"integer data; + // task automatic wait_for( integer value, output bit success ); + // expect( @(posedge clk) ##[1:10] data == value ) success = 1; + // else success = 0; + // endtask + + // initial begin + // bit ok; + // wait_for( 23, ok ); // wait for the value 23 + // end"##, + // Ok((_, _)) + //); + test!( + many1(module_item), + r##"module A; + logic a, clk; + + clocking cb_with_input @(posedge clk); + input a; + property p1; + a; + endproperty + endclocking + + clocking cb_without_input @(posedge clk); + property p1; + a; + endproperty + endclocking + + property p1; + @(posedge clk) a; + endproperty + + property p2; + @(posedge clk) cb_with_input.a; + endproperty + + a1: assert property (p1); + a2: assert property (cb_with_input.p1); + a3: assert property (p2); + a4: assert property (cb_without_input.p1); + endmodule"##, + Ok((_, _)) + ); + } } #[test] -fn debug() {} +fn debug() { + //nom_tracable::statistics(Span::new_extra("", SpanInfo::default())); +} diff --git a/sv-parser-parser/src/udp_declaration_and_instantiation/udp_body.rs b/sv-parser-parser/src/udp_declaration_and_instantiation/udp_body.rs index 8590017..0415a35 100644 --- a/sv-parser-parser/src/udp_declaration_and_instantiation/udp_body.rs +++ b/sv-parser-parser/src/udp_declaration_and_instantiation/udp_body.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_body(s: Span) -> IResult { alt(( map(combinational_body, |x| { @@ -13,6 +14,7 @@ pub(crate) fn udp_body(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn combinational_body(s: Span) -> IResult { let (s, a) = keyword("table")(s)?; let (s, b) = combinational_entry(s)?; @@ -27,6 +29,7 @@ pub(crate) fn combinational_body(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn combinational_entry(s: Span) -> IResult { let (s, a) = level_input_list(s)?; let (s, b) = symbol(":")(s)?; @@ -41,6 +44,7 @@ pub(crate) fn combinational_entry(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequential_body(s: Span) -> IResult { let (s, a) = opt(udp_initial_statement)(s)?; let (s, b) = keyword("table")(s)?; @@ -56,6 +60,7 @@ pub(crate) fn sequential_body(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_initial_statement(s: Span) -> IResult { let (s, a) = keyword("initial")(s)?; let (s, b) = output_port_identifier(s)?; @@ -71,6 +76,7 @@ pub(crate) fn udp_initial_statement(s: Span) -> IResult IResult { alt(( map(keyword("1'b0"), |x| InitVal { nodes: (x,) }), @@ -87,6 +93,7 @@ pub(crate) fn init_val(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn sequential_entry(s: Span) -> IResult { let (s, a) = seq_input_list(s)?; let (s, b) = symbol(":")(s)?; @@ -103,6 +110,7 @@ pub(crate) fn sequential_entry(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn seq_input_list(s: Span) -> IResult { alt(( map(level_input_list, |x| { @@ -115,6 +123,7 @@ pub(crate) fn seq_input_list(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn level_input_list(s: Span) -> IResult { let (s, a) = level_symbol(s)?; let (s, b) = many0(level_symbol)(s)?; @@ -122,6 +131,7 @@ pub(crate) fn level_input_list(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn edge_input_list(s: Span) -> IResult { let (s, a) = many0(level_symbol)(s)?; let (s, b) = edge_indicator(s)?; @@ -130,6 +140,7 @@ pub(crate) fn edge_input_list(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn edge_indicator(s: Span) -> IResult { alt(( edge_indicator_paren, @@ -138,6 +149,7 @@ pub(crate) fn edge_indicator(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn edge_indicator_paren(s: Span) -> IResult { let (s, a) = paren(pair(level_symbol, level_symbol))(s)?; Ok(( @@ -147,12 +159,14 @@ pub(crate) fn edge_indicator_paren(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn current_state(s: Span) -> IResult { let (s, a) = level_symbol(s)?; Ok((s, CurrentState { nodes: (a,) })) } #[tracable_parser] +#[packrat_parser] pub(crate) fn next_state(s: Span) -> IResult { alt(( map(output_symbol, |x| NextState::OutputSymbol(Box::new(x))), @@ -161,6 +175,7 @@ pub(crate) fn next_state(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn output_symbol(s: Span) -> IResult { alt(( map(keyword("0"), |x| OutputSymbol { nodes: (x,) }), @@ -171,6 +186,7 @@ pub(crate) fn output_symbol(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn level_symbol(s: Span) -> IResult { alt(( map(keyword("0"), |x| LevelSymbol { nodes: (x,) }), @@ -184,6 +200,7 @@ pub(crate) fn level_symbol(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn edge_symbol(s: Span) -> IResult { alt(( map(keyword("r"), |x| EdgeSymbol { nodes: (x,) }), diff --git a/sv-parser-parser/src/udp_declaration_and_instantiation/udp_declaration.rs b/sv-parser-parser/src/udp_declaration_and_instantiation/udp_declaration.rs index e022fb9..1d782b8 100644 --- a/sv-parser-parser/src/udp_declaration_and_instantiation/udp_declaration.rs +++ b/sv-parser-parser/src/udp_declaration_and_instantiation/udp_declaration.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_nonansi_declaration(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("primitive")(s)?; @@ -18,6 +19,7 @@ pub(crate) fn udp_nonansi_declaration(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("primitive")(s)?; @@ -33,6 +35,7 @@ pub(crate) fn udp_ansi_declaration(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_declaration(s: Span) -> IResult { alt(( udp_declaration_nonansi, @@ -44,6 +47,7 @@ pub(crate) fn udp_declaration(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_declaration_nonansi(s: Span) -> IResult { let (s, a) = udp_nonansi_declaration(s)?; let (s, b) = udp_port_declaration(s)?; @@ -60,6 +64,7 @@ pub(crate) fn udp_declaration_nonansi(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_declaration_ansi(s: Span) -> IResult { let (s, a) = udp_ansi_declaration(s)?; let (s, b) = udp_body(s)?; @@ -74,6 +79,7 @@ pub(crate) fn udp_declaration_ansi(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_declaration_extern_nonansi(s: Span) -> IResult { let (s, a) = keyword("extern")(s)?; let (s, b) = udp_nonansi_declaration(s)?; @@ -84,6 +90,7 @@ pub(crate) fn udp_declaration_extern_nonansi(s: Span) -> IResult IResult { let (s, a) = keyword("extern")(s)?; let (s, b) = udp_ansi_declaration(s)?; @@ -94,6 +101,7 @@ pub(crate) fn udp_declaration_extern_ansi(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("primitive")(s)?; diff --git a/sv-parser-parser/src/udp_declaration_and_instantiation/udp_instantiation.rs b/sv-parser-parser/src/udp_declaration_and_instantiation/udp_instantiation.rs index 86e1275..da32d99 100644 --- a/sv-parser-parser/src/udp_declaration_and_instantiation/udp_instantiation.rs +++ b/sv-parser-parser/src/udp_declaration_and_instantiation/udp_instantiation.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_instantiation(s: Span) -> IResult { let (s, a) = udp_identifier(s)?; let (s, b) = opt(drive_strength)(s)?; @@ -18,6 +19,7 @@ pub(crate) fn udp_instantiation(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_instance(s: Span) -> IResult { let (s, a) = opt(name_of_instance)(s)?; let (s, b) = paren(tuple(( diff --git a/sv-parser-parser/src/udp_declaration_and_instantiation/udp_ports.rs b/sv-parser-parser/src/udp_declaration_and_instantiation/udp_ports.rs index 23daf7d..3fb622d 100644 --- a/sv-parser-parser/src/udp_declaration_and_instantiation/udp_ports.rs +++ b/sv-parser-parser/src/udp_declaration_and_instantiation/udp_ports.rs @@ -3,6 +3,7 @@ use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_port_list(s: Span) -> IResult { let (s, a) = output_port_identifier(s)?; let (s, b) = symbol(",")(s)?; @@ -11,6 +12,7 @@ pub(crate) fn udp_port_list(s: Span) -> IResult { } #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_declaration_port_list(s: Span) -> IResult { let (s, a) = udp_output_declaration(s)?; let (s, b) = symbol(",")(s)?; @@ -19,6 +21,7 @@ pub(crate) fn udp_declaration_port_list(s: Span) -> IResult IResult { alt(( map(pair(udp_output_declaration, symbol(";")), |x| { @@ -34,11 +37,13 @@ pub(crate) fn udp_port_declaration(s: Span) -> IResult } #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_output_declaration(s: Span) -> IResult { alt((udp_output_declaration_nonreg, udp_output_declaration_reg))(s) } #[tracable_parser] +#[packrat_parser] pub(crate) fn udp_output_declaration_nonreg(s: Span) -> IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("output")(s)?; @@ -50,6 +55,7 @@ pub(crate) fn udp_output_declaration_nonreg(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("output")(s)?; @@ -65,6 +71,7 @@ pub(crate) fn udp_output_declaration_reg(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("input")(s)?; @@ -73,6 +80,7 @@ pub(crate) fn udp_input_declaration(s: Span) -> IResult IResult { let (s, a) = many0(attribute_instance)(s)?; let (s, b) = keyword("reg")(s)?; diff --git a/sv-parser-parser/src/utils.rs b/sv-parser-parser/src/utils.rs index d124225..e36ea5d 100644 --- a/sv-parser-parser/src/utils.rs +++ b/sv-parser-parser/src/utils.rs @@ -507,6 +507,7 @@ where // ----------------------------------------------------------------------------- #[tracable_parser] +#[packrat_parser] pub(crate) fn white_space(s: Span) -> IResult { alt(( map(multispace1, |x: Span| {