diff --git a/CHANGELOG.md b/CHANGELOG.md index f2bc428..0b45add 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.10.0...Unreleased) - ReleaseDate +* [Fixed] Use many_till instead of many0 for accurate error position + ## [v0.10.0](https://github.com/dalance/sv-parser/compare/v0.9.0...v0.10.0) - 2020-12-24 * [Fixed] wrong error position diff --git a/sv-parser-parser/src/behavioral_statements/case_statements.rs b/sv-parser-parser/src/behavioral_statements/case_statements.rs index 13e2ef2..a999c43 100644 --- a/sv-parser-parser/src/behavioral_statements/case_statements.rs +++ b/sv-parser-parser/src/behavioral_statements/case_statements.rs @@ -19,8 +19,7 @@ pub(crate) fn case_statement_normal(s: Span) -> IResult { let (s, b) = case_keyword(s)?; let (s, c) = paren(case_expression)(s)?; let (s, d) = case_item(s)?; - let (s, e) = many0(case_item)(s)?; - let (s, f) = keyword("endcase")(s)?; + let (s, (e, f)) = many_till(case_item, keyword("endcase"))(s)?; Ok(( s, CaseStatement::Normal(Box::new(CaseStatementNormal { @@ -37,8 +36,7 @@ pub(crate) fn case_statement_matches(s: Span) -> IResult { let (s, c) = paren(case_expression)(s)?; let (s, d) = keyword("matches")(s)?; let (s, e) = case_pattern_item(s)?; - let (s, f) = many0(case_pattern_item)(s)?; - let (s, g) = keyword("endcase")(s)?; + let (s, (f, g)) = many_till(case_pattern_item, keyword("endcase"))(s)?; Ok(( s, CaseStatement::Matches(Box::new(CaseStatementMatches { @@ -55,8 +53,7 @@ pub(crate) fn case_statement_inside(s: Span) -> IResult { let (s, c) = paren(case_expression)(s)?; let (s, d) = keyword("inside")(s)?; let (s, e) = case_inside_item(s)?; - let (s, f) = many0(case_inside_item)(s)?; - let (s, g) = keyword("endcase")(s)?; + let (s, (f, g)) = many_till(case_inside_item, keyword("endcase"))(s)?; Ok(( s, CaseStatement::Inside(Box::new(CaseStatementInside { @@ -172,8 +169,7 @@ pub(crate) fn case_item_expression(s: Span) -> IResult pub(crate) fn randcase_statement(s: Span) -> IResult { let (s, a) = keyword("randcase")(s)?; let (s, b) = randcase_item(s)?; - let (s, c) = many0(randcase_item)(s)?; - let (s, d) = keyword("endcase")(s)?; + let (s, (c, d)) = many_till(randcase_item, keyword("endcase"))(s)?; Ok(( s, RandcaseStatement { diff --git a/sv-parser-parser/src/behavioral_statements/clocking_block.rs b/sv-parser-parser/src/behavioral_statements/clocking_block.rs index 4a65729..ed43f62 100644 --- a/sv-parser-parser/src/behavioral_statements/clocking_block.rs +++ b/sv-parser-parser/src/behavioral_statements/clocking_block.rs @@ -16,8 +16,7 @@ pub(crate) fn clocking_declaration_local(s: Span) -> IResult IResult { let (s, a) = keyword("begin")(s)?; let (s, b) = opt(pair(symbol(":"), block_identifier))(s)?; let (s, c) = many0(block_item_declaration)(s)?; - let (s, d) = many0(statement_or_null)(s)?; - let (s, e) = keyword("end")(s)?; + let (s, (d, e)) = many_till(statement_or_null, keyword("end"))(s)?; let (s, f) = opt(pair(symbol(":"), block_identifier))(s)?; Ok(( s, @@ -48,8 +47,7 @@ pub(crate) fn par_block(s: Span) -> IResult { let (s, a) = keyword("fork")(s)?; let (s, b) = opt(pair(symbol(":"), block_identifier))(s)?; let (s, c) = many0(block_item_declaration)(s)?; - let (s, d) = many0(statement_or_null)(s)?; - let (s, e) = join_keyword(s)?; + let (s, (d, e)) = many_till(statement_or_null, join_keyword)(s)?; let (s, f) = opt(pair(symbol(":"), block_identifier))(s)?; Ok(( s, diff --git a/sv-parser-parser/src/behavioral_statements/randsequence.rs b/sv-parser-parser/src/behavioral_statements/randsequence.rs index 80a7589..deb6fbc 100644 --- a/sv-parser-parser/src/behavioral_statements/randsequence.rs +++ b/sv-parser-parser/src/behavioral_statements/randsequence.rs @@ -8,8 +8,7 @@ pub(crate) fn randsequence_statement(s: Span) -> IResult IResult { let (s, a) = keyword("case")(s)?; let (s, b) = paren(case_expression)(s)?; let (s, c) = rs_case_item(s)?; - let (s, d) = many0(rs_case_item)(s)?; - let (s, e) = keyword("endcase")(s)?; + let (s, (d, e)) = many_till(rs_case_item, keyword("endcase"))(s)?; Ok(( s, RsCase { diff --git a/sv-parser-parser/src/behavioral_statements/statements.rs b/sv-parser-parser/src/behavioral_statements/statements.rs index ca3df2e..3ebcf9e 100644 --- a/sv-parser-parser/src/behavioral_statements/statements.rs +++ b/sv-parser-parser/src/behavioral_statements/statements.rs @@ -14,8 +14,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)?; + let (s, (a, b)) = many_till(attribute_instance, symbol(";"))(s)?; Ok(( s, StatementOrNull::Attribute(Box::new(StatementOrNullAttribute { nodes: (a, b) })), @@ -119,8 +118,7 @@ pub(crate) fn function_statement_or_null(s: Span) -> IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = symbol(";")(s)?; + let (s, (a, b)) = many_till(attribute_instance, symbol(";"))(s)?; Ok(( s, FunctionStatementOrNull::Attribute(Box::new(FunctionStatementOrNullAttribute { diff --git a/sv-parser-parser/src/declarations/assertion_declarations.rs b/sv-parser-parser/src/declarations/assertion_declarations.rs index b1cb7f2..d7594fc 100644 --- a/sv-parser-parser/src/declarations/assertion_declarations.rs +++ b/sv-parser-parser/src/declarations/assertion_declarations.rs @@ -437,8 +437,7 @@ pub(crate) fn property_expr_case(s: Span) -> IResult { let (s, a) = keyword("case")(s)?; let (s, b) = paren(expression_or_dist)(s)?; let (s, c) = property_case_item(s)?; - let (s, d) = many0(property_case_item)(s)?; - let (s, e) = keyword("endcase")(s)?; + let (s, (d, e)) = many_till(property_case_item, keyword("endcase"))(s)?; Ok(( s, PropertyExpr::Case(Box::new(PropertyExprCase { diff --git a/sv-parser-parser/src/declarations/covergroup_declarations.rs b/sv-parser-parser/src/declarations/covergroup_declarations.rs index 6d3d1fa..71488f3 100644 --- a/sv-parser-parser/src/declarations/covergroup_declarations.rs +++ b/sv-parser-parser/src/declarations/covergroup_declarations.rs @@ -10,8 +10,7 @@ pub(crate) fn covergroup_declaration(s: Span) -> IResult IResult IResult IResult IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = symbol(".")(s)?; + let (s, (a, b)) = many_till(attribute_instance, symbol("."))(s)?; let (s, c) = formal_port_identifier(s)?; let (s, d) = opt(paren(opt(property_actual_arg)))(s)?; Ok(( @@ -99,8 +98,7 @@ pub(crate) fn named_checker_port_connection_identifier( pub(crate) fn named_checker_port_connection_asterisk( s: Span, ) -> IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = symbol(".*")(s)?; + let (s, (a, b)) = many_till(attribute_instance, symbol(".*"))(s)?; Ok(( s, NamedCheckerPortConnection::Asterisk(Box::new(NamedCheckerPortConnectionAsterisk { diff --git a/sv-parser-parser/src/instantiations/generated_instantiation.rs b/sv-parser-parser/src/instantiations/generated_instantiation.rs index 59c0634..e300038 100644 --- a/sv-parser-parser/src/instantiations/generated_instantiation.rs +++ b/sv-parser-parser/src/instantiations/generated_instantiation.rs @@ -6,8 +6,7 @@ use crate::*; #[packrat_parser] pub(crate) fn generate_region(s: Span) -> IResult { let (s, a) = keyword("generate")(s)?; - let (s, b) = many0(generate_item)(s)?; - let (s, c) = keyword("endgenerate")(s)?; + let (s, (b, c)) = many_till(generate_item, keyword("endgenerate"))(s)?; Ok((s, GenerateRegion { nodes: (a, b, c) })) } @@ -176,8 +175,7 @@ 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)?; let (s, c) = opt(pair(symbol(":"), generate_block_identifier))(s)?; - let (s, d) = many0(generate_item)(s)?; - let (s, e) = keyword("end")(s)?; + let (s, (d, e)) = many_till(generate_item, keyword("end"))(s)?; let (s, f) = opt(pair(symbol(":"), generate_block_identifier))(s)?; Ok(( s, diff --git a/sv-parser-parser/src/instantiations/module_instantiation.rs b/sv-parser-parser/src/instantiations/module_instantiation.rs index fff26f6..b60a99f 100644 --- a/sv-parser-parser/src/instantiations/module_instantiation.rs +++ b/sv-parser-parser/src/instantiations/module_instantiation.rs @@ -146,8 +146,7 @@ pub(crate) fn named_port_connection(s: Span) -> IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = symbol(".")(s)?; + let (s, (a, b)) = many_till(attribute_instance, symbol("."))(s)?; let (s, c) = port_identifier(s)?; let (s, d) = opt(paren(opt(expression)))(s)?; Ok(( @@ -161,8 +160,7 @@ pub(crate) fn named_port_connection_identifier(s: Span) -> IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = symbol(".*")(s)?; + let (s, (a, b)) = many_till(attribute_instance, symbol(".*"))(s)?; Ok(( s, NamedPortConnection::Asterisk(Box::new(NamedPortConnectionAsterisk { nodes: (a, b) })), diff --git a/sv-parser-parser/src/source_text/class_items.rs b/sv-parser-parser/src/source_text/class_items.rs index 47a77f4..f59c864 100644 --- a/sv-parser-parser/src/source_text/class_items.rs +++ b/sv-parser-parser/src/source_text/class_items.rs @@ -325,8 +325,7 @@ pub(crate) fn class_constructor_declaration(s: Span) -> IResult IResult { let (s, c) = symbol(";")(s)?; let (s, d) = many0(pair(local_parameter_declaration, symbol(";")))(s)?; let (s, e) = design_statement(s)?; - let (s, f) = many0(config_rule_statement)(s)?; - let (s, g) = keyword("endconfig")(s)?; + let (s, (f, g)) = many_till(config_rule_statement, keyword("endconfig"))(s)?; let (s, h) = opt(pair(symbol(":"), config_identifier))(s)?; Ok(( s, @@ -25,11 +24,10 @@ pub(crate) fn config_declaration(s: Span) -> IResult { #[packrat_parser] pub(crate) fn design_statement(s: Span) -> IResult { let (s, a) = keyword("design")(s)?; - let (s, b) = many0(pair( - opt(pair(library_identifier, symbol("."))), - cell_identifier, - ))(s)?; - let (s, c) = symbol(";")(s)?; + let (s, (b, c)) = many_till( + pair(opt(pair(library_identifier, symbol("."))), cell_identifier), + symbol(";"), + )(s)?; Ok((s, DesignStatement { nodes: (a, b, c) })) } diff --git a/sv-parser-parser/src/source_text/package_items.rs b/sv-parser-parser/src/source_text/package_items.rs index 76647db..829d299 100644 --- a/sv-parser-parser/src/source_text/package_items.rs +++ b/sv-parser-parser/src/source_text/package_items.rs @@ -80,8 +80,7 @@ pub(crate) fn package_or_generate_item_declaration( pub(crate) fn anonymous_program(s: Span) -> IResult { let (s, a) = keyword("program")(s)?; let (s, b) = symbol(";")(s)?; - let (s, c) = many0(anonymous_program_item)(s)?; - let (s, d) = keyword("endprogram")(s)?; + let (s, (c, d)) = many_till(anonymous_program_item, keyword("endprogram"))(s)?; Ok(( s, AnonymousProgram { 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 b0b45e1..ec1bf4d 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 @@ -79,8 +79,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)?; + let (s, (a, b)) = many_till(attribute_instance, module_keyword)(s)?; let (s, c) = opt(lifetime)(s)?; let (s, d) = module_identifier(s)?; let (s, e) = many0(package_import_declaration)(s)?; @@ -98,8 +97,7 @@ pub(crate) fn module_nonansi_header(s: Span) -> IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = module_keyword(s)?; + let (s, (a, b)) = many_till(attribute_instance, module_keyword)(s)?; let (s, c) = opt(lifetime)(s)?; let (s, d) = module_identifier(s)?; let (s, e) = many0(package_import_declaration)(s)?; @@ -131,8 +129,7 @@ pub(crate) fn module_declaration(s: Span) -> IResult { pub(crate) fn module_declaration_nonansi(s: Span) -> IResult { let (s, a) = module_nonansi_header(s)?; let (s, b) = opt(timeunits_declaration)(s)?; - let (s, c) = many0(module_item)(s)?; - let (s, d) = keyword("endmodule")(s)?; + let (s, (c, d)) = many_till(module_item, keyword("endmodule"))(s)?; let (s, e) = opt(pair(symbol(":"), module_identifier))(s)?; Ok(( s, @@ -147,8 +144,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)?; - let (s, c) = many0(non_port_module_item)(s)?; - let (s, d) = keyword("endmodule")(s)?; + let (s, (c, d)) = many_till(non_port_module_item, keyword("endmodule"))(s)?; let (s, e) = opt(pair(symbol(":"), module_identifier))(s)?; Ok(( s, @@ -161,15 +157,13 @@ pub(crate) fn module_declaration_ansi(s: Span) -> IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = module_keyword(s)?; + let (s, (a, b)) = many_till(attribute_instance, module_keyword)(s)?; let (s, c) = opt(lifetime)(s)?; let (s, d) = module_identifier(s)?; let (s, e) = paren(symbol(".*"))(s)?; let (s, f) = symbol(";")(s)?; let (s, g) = opt(timeunits_declaration)(s)?; - let (s, h) = many0(module_item)(s)?; - let (s, i) = keyword("endmodule")(s)?; + let (s, (h, i)) = many_till(module_item, keyword("endmodule"))(s)?; let (s, j) = opt(pair(symbol(":"), module_identifier))(s)?; Ok(( s, @@ -231,8 +225,7 @@ pub(crate) fn interface_declaration(s: Span) -> IResult IResult { let (s, a) = interface_nonansi_header(s)?; let (s, b) = opt(timeunits_declaration)(s)?; - let (s, c) = many0(interface_item)(s)?; - let (s, d) = keyword("endinterface")(s)?; + let (s, (c, d)) = many_till(interface_item, keyword("endinterface"))(s)?; let (s, e) = opt(pair(symbol(":"), interface_identifier))(s)?; Ok(( s, @@ -247,8 +240,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)?; - let (s, c) = many0(non_port_interface_item)(s)?; - let (s, d) = keyword("endinterface")(s)?; + let (s, (c, d)) = many_till(non_port_interface_item, keyword("endinterface"))(s)?; let (s, e) = opt(pair(symbol(":"), interface_identifier))(s)?; Ok(( s, @@ -261,15 +253,13 @@ pub(crate) fn interface_declaration_ansi(s: Span) -> IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = keyword("interface")(s)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("interface"))(s)?; let (s, c) = opt(lifetime)(s)?; let (s, d) = interface_identifier(s)?; let (s, e) = paren(symbol(".*"))(s)?; let (s, f) = symbol(";")(s)?; let (s, g) = opt(timeunits_declaration)(s)?; - let (s, h) = many0(interface_item)(s)?; - let (s, i) = keyword("endinterface")(s)?; + let (s, (h, i)) = many_till(interface_item, keyword("endinterface"))(s)?; let (s, j) = opt(pair(symbol(":"), interface_identifier))(s)?; Ok(( s, @@ -308,8 +298,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)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("interface"))(s)?; let (s, c) = opt(lifetime)(s)?; let (s, d) = interface_identifier(s)?; let (s, e) = many0(package_import_declaration)(s)?; @@ -327,8 +316,7 @@ pub(crate) fn interface_nonansi_header(s: Span) -> IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = keyword("interface")(s)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("interface"))(s)?; let (s, c) = opt(lifetime)(s)?; let (s, d) = interface_identifier(s)?; let (s, e) = many0(package_import_declaration)(s)?; @@ -360,8 +348,7 @@ pub(crate) fn program_declaration(s: Span) -> IResult pub(crate) fn program_declaration_nonansi(s: Span) -> IResult { let (s, a) = program_nonansi_header(s)?; let (s, b) = opt(timeunits_declaration)(s)?; - let (s, c) = many0(program_item)(s)?; - let (s, d) = keyword("endprogram")(s)?; + let (s, (c, d)) = many_till(program_item, keyword("endprogram"))(s)?; let (s, e) = opt(pair(symbol(":"), program_identifier))(s)?; Ok(( s, @@ -376,8 +363,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)?; - let (s, c) = many0(non_port_program_item)(s)?; - let (s, d) = keyword("endprogram")(s)?; + let (s, (c, d)) = many_till(non_port_program_item, keyword("endprogram"))(s)?; let (s, e) = opt(pair(symbol(":"), program_identifier))(s)?; Ok(( s, @@ -390,14 +376,12 @@ pub(crate) fn program_declaration_ansi(s: Span) -> IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = keyword("program")(s)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("program"))(s)?; let (s, c) = program_identifier(s)?; let (s, d) = paren(symbol(".*"))(s)?; let (s, e) = symbol(";")(s)?; let (s, f) = opt(timeunits_declaration)(s)?; - let (s, g) = many0(program_item)(s)?; - let (s, h) = keyword("endprogram")(s)?; + let (s, (g, h)) = many_till(program_item, keyword("endprogram"))(s)?; let (s, i) = opt(pair(symbol(":"), program_identifier))(s)?; Ok(( s, @@ -434,8 +418,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)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("prgogram"))(s)?; let (s, c) = opt(lifetime)(s)?; let (s, d) = program_identifier(s)?; let (s, e) = many0(package_import_declaration)(s)?; @@ -453,8 +436,7 @@ pub(crate) fn program_nonansi_header(s: Span) -> IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = keyword("program")(s)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("program"))(s)?; let (s, c) = opt(lifetime)(s)?; let (s, d) = program_identifier(s)?; let (s, e) = many0(package_import_declaration)(s)?; @@ -476,8 +458,10 @@ pub(crate) fn checker_declaration(s: Span) -> IResult let (s, b) = checker_identifier(s)?; let (s, c) = opt(paren(opt(checker_port_list)))(s)?; let (s, d) = symbol(";")(s)?; - let (s, e) = many0(pair(many0(attribute_instance), checker_or_generate_item))(s)?; - let (s, f) = keyword("endchecker")(s)?; + let (s, (e, f)) = many_till( + pair(many0(attribute_instance), checker_or_generate_item), + keyword("endchecker"), + )(s)?; let (s, g) = opt(pair(symbol(":"), checker_identifier))(s)?; Ok(( s, @@ -505,8 +489,7 @@ pub(crate) fn class_declaration(s: Span) -> IResult { list(symbol(","), interface_class_type), ))(s)?; let (s, h) = symbol(";")(s)?; - let (s, i) = many0(class_item)(s)?; - let (s, j) = keyword("endclass")(s)?; + let (s, (i, j)) = many_till(class_item, keyword("endclass"))(s)?; let (s, k) = opt(pair(symbol(":"), class_identifier))(s)?; Ok(( s, @@ -536,8 +519,7 @@ pub(crate) fn interface_class_declaration(s: Span) -> IResult IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = keyword("package")(s)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("package"))(s)?; let (s, c) = opt(lifetime)(s)?; let (s, d) = package_identifier(s)?; let (s, e) = symbol(";")(s)?; let (s, f) = opt(timeunits_declaration)(s)?; - let (s, g) = many0(pair(many0(attribute_instance), package_item))(s)?; - let (s, h) = keyword("endpackage")(s)?; + let (s, (g, h)) = many_till( + pair(many0(attribute_instance), package_item), + keyword("endpackage"), + )(s)?; let (s, i) = opt(pair(symbol(":"), package_identifier))(s)?; Ok(( s, 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 fe7ab0e..b7c90cd 100644 --- a/sv-parser-parser/src/specify_section/specify_block_declaration.rs +++ b/sv-parser-parser/src/specify_section/specify_block_declaration.rs @@ -6,8 +6,7 @@ use crate::*; #[packrat_parser] pub(crate) fn specify_block(s: Span) -> IResult { let (s, a) = keyword("specify")(s)?; - let (s, b) = many0(specify_item)(s)?; - let (s, c) = keyword("endspecify")(s)?; + let (s, (b, c)) = many_till(specify_item, keyword("endspecify"))(s)?; Ok((s, SpecifyBlock { nodes: (a, b, c) })) } diff --git a/sv-parser-parser/src/tests.rs b/sv-parser-parser/src/tests.rs index 09e5935..d8308df 100644 --- a/sv-parser-parser/src/tests.rs +++ b/sv-parser-parser/src/tests.rs @@ -15921,7 +15921,7 @@ mod error { error_test!( source_text, r##"module A(); parameter A = 1 endmodule"##, - Some(12) + Some(28) ); } } 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 c85f03d..34e8a17 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 @@ -18,8 +18,7 @@ pub(crate) fn udp_body(s: Span) -> IResult { pub(crate) fn combinational_body(s: Span) -> IResult { let (s, a) = keyword("table")(s)?; let (s, b) = combinational_entry(s)?; - let (s, c) = many0(combinational_entry)(s)?; - let (s, d) = keyword("endtable")(s)?; + let (s, (c, d)) = many_till(combinational_entry, keyword("endtable"))(s)?; Ok(( s, CombinationalBody { @@ -49,8 +48,7 @@ pub(crate) fn sequential_body(s: Span) -> IResult { let (s, a) = opt(udp_initial_statement)(s)?; let (s, b) = keyword("table")(s)?; let (s, c) = sequential_entry(s)?; - let (s, d) = many0(sequential_entry)(s)?; - let (s, e) = keyword("endtable")(s)?; + let (s, (d, e)) = many_till(sequential_entry, keyword("endtable"))(s)?; Ok(( s, SequentialBody { 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 1d782b8..5738b57 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 @@ -5,8 +5,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)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("primitive"))(s)?; let (s, c) = udp_identifier(s)?; let (s, d) = paren(udp_port_list)(s)?; let (s, e) = symbol(";")(s)?; @@ -21,8 +20,7 @@ pub(crate) fn udp_nonansi_declaration(s: Span) -> IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = keyword("primitive")(s)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("primitive"))(s)?; let (s, c) = udp_identifier(s)?; let (s, d) = paren(udp_declaration_port_list)(s)?; let (s, e) = symbol(";")(s)?; @@ -103,8 +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)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("primitive"))(s)?; let (s, c) = udp_identifier(s)?; let (s, d) = paren(symbol(".*"))(s)?; let (s, e) = symbol(";")(s)?; 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 3fb622d..22c23f3 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 @@ -45,8 +45,7 @@ pub(crate) fn udp_output_declaration(s: Span) -> IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = keyword("output")(s)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("output"))(s)?; let (s, c) = port_identifier(s)?; Ok(( s, @@ -57,8 +56,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)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("output"))(s)?; let (s, c) = keyword("reg")(s)?; let (s, d) = port_identifier(s)?; let (s, e) = opt(pair(symbol("="), constant_expression))(s)?; @@ -73,8 +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)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("input"))(s)?; let (s, c) = list_of_udp_port_identifiers(s)?; Ok((s, UdpInputDeclaration { nodes: (a, b, c) })) } @@ -82,8 +79,7 @@ pub(crate) fn udp_input_declaration(s: Span) -> IResult IResult { - let (s, a) = many0(attribute_instance)(s)?; - let (s, b) = keyword("reg")(s)?; + let (s, (a, b)) = many_till(attribute_instance, keyword("reg"))(s)?; let (s, c) = variable_identifier(s)?; Ok((s, UdpRegDeclaration { nodes: (a, b, c) })) }