Use many_till
This commit is contained in:
parent
b1c3f41dea
commit
3c5ce3c596
@ -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
|
||||
|
@ -19,8 +19,7 @@ pub(crate) fn case_statement_normal(s: Span) -> IResult<Span, CaseStatement> {
|
||||
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<Span, CaseStatement> {
|
||||
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<Span, CaseStatement> {
|
||||
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<Span, CaseItemExpression>
|
||||
pub(crate) fn randcase_statement(s: Span) -> IResult<Span, RandcaseStatement> {
|
||||
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 {
|
||||
|
@ -16,8 +16,7 @@ pub(crate) fn clocking_declaration_local(s: Span) -> IResult<Span, ClockingDecla
|
||||
let (s, c) = opt(clocking_identifier)(s)?;
|
||||
let (s, d) = clocking_event(s)?;
|
||||
let (s, e) = symbol(";")(s)?;
|
||||
let (s, f) = many0(clocking_item)(s)?;
|
||||
let (s, g) = keyword("endclocking")(s)?;
|
||||
let (s, (f, g)) = many_till(clocking_item, keyword("endclocking"))(s)?;
|
||||
let (s, h) = opt(pair(symbol(":"), clocking_identifier))(s)?;
|
||||
Ok((
|
||||
s,
|
||||
|
@ -31,8 +31,7 @@ pub(crate) fn seq_block(s: Span) -> IResult<Span, SeqBlock> {
|
||||
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<Span, ParBlock> {
|
||||
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,
|
||||
|
@ -8,8 +8,7 @@ pub(crate) fn randsequence_statement(s: Span) -> IResult<Span, RandsequenceState
|
||||
let (s, a) = keyword("randsequence")(s)?;
|
||||
let (s, b) = paren(opt(production_identifier))(s)?;
|
||||
let (s, c) = production(s)?;
|
||||
let (s, d) = many0(production)(s)?;
|
||||
let (s, e) = keyword("endsequence")(s)?;
|
||||
let (s, (d, e)) = many_till(production, keyword("endsequence"))(s)?;
|
||||
Ok((
|
||||
s,
|
||||
RandsequenceStatement {
|
||||
@ -162,8 +161,7 @@ pub(crate) fn rs_case(s: Span) -> IResult<Span, RsCase> {
|
||||
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 {
|
||||
|
@ -14,8 +14,7 @@ pub(crate) fn statement_or_null(s: Span) -> IResult<Span, StatementOrNull> {
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn statement_or_null_attribute(s: Span) -> IResult<Span, StatementOrNull> {
|
||||
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<Span, FunctionState
|
||||
pub(crate) fn function_statement_or_null_attribute(
|
||||
s: Span,
|
||||
) -> IResult<Span, FunctionStatementOrNull> {
|
||||
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 {
|
||||
|
@ -437,8 +437,7 @@ pub(crate) fn property_expr_case(s: Span) -> IResult<Span, PropertyExpr> {
|
||||
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 {
|
||||
|
@ -10,8 +10,7 @@ pub(crate) fn covergroup_declaration(s: Span) -> IResult<Span, CovergroupDeclara
|
||||
let (s, c) = opt(paren(opt(tf_port_list)))(s)?;
|
||||
let (s, d) = opt(coverage_event)(s)?;
|
||||
let (s, e) = symbol(";")(s)?;
|
||||
let (s, f) = many0(coverage_spec_or_option)(s)?;
|
||||
let (s, g) = keyword("endgroup")(s)?;
|
||||
let (s, (f, g)) = many_till(coverage_spec_or_option, keyword("endgroup"))(s)?;
|
||||
let (s, h) = opt(pair(symbol(":"), covergroup_identifier))(s)?;
|
||||
Ok((
|
||||
s,
|
||||
|
@ -57,8 +57,7 @@ pub(crate) fn function_body_declaration_without_port(
|
||||
let (s, c) = function_identifier(s)?;
|
||||
let (s, d) = symbol(";")(s)?;
|
||||
let (s, e) = many0(tf_item_declaration)(s)?;
|
||||
let (s, f) = many0(function_statement_or_null)(s)?;
|
||||
let (s, g) = keyword("endfunction")(s)?;
|
||||
let (s, (f, g)) = many_till(function_statement_or_null, keyword("endfunction"))(s)?;
|
||||
let (s, h) = opt(pair(symbol(":"), function_identifier))(s)?;
|
||||
Ok((
|
||||
s,
|
||||
@ -79,8 +78,7 @@ pub(crate) fn function_body_declaration_with_port(
|
||||
let (s, d) = paren(opt(tf_port_list))(s)?;
|
||||
let (s, e) = symbol(";")(s)?;
|
||||
let (s, f) = many0(block_item_declaration)(s)?;
|
||||
let (s, g) = many0(function_statement_or_null)(s)?;
|
||||
let (s, h) = keyword("endfunction")(s)?;
|
||||
let (s, (g, h)) = many_till(function_statement_or_null, keyword("endfunction"))(s)?;
|
||||
let (s, i) = opt(pair(symbol(":"), function_identifier))(s)?;
|
||||
Ok((
|
||||
s,
|
||||
|
@ -27,8 +27,7 @@ pub(crate) fn task_body_declaration_without_port(s: Span) -> IResult<Span, TaskB
|
||||
let (s, b) = task_identifier(s)?;
|
||||
let (s, c) = symbol(";")(s)?;
|
||||
let (s, d) = many0(tf_item_declaration)(s)?;
|
||||
let (s, e) = many0(statement_or_null)(s)?;
|
||||
let (s, f) = keyword("endtask")(s)?;
|
||||
let (s, (e, f)) = many_till(statement_or_null, keyword("endtask"))(s)?;
|
||||
let (s, g) = opt(pair(symbol(":"), task_identifier))(s)?;
|
||||
Ok((
|
||||
s,
|
||||
@ -46,8 +45,7 @@ pub(crate) fn task_body_declaration_with_port(s: Span) -> IResult<Span, TaskBody
|
||||
let (s, c) = paren(opt(tf_port_list))(s)?;
|
||||
let (s, d) = symbol(";")(s)?;
|
||||
let (s, e) = many0(block_item_declaration)(s)?;
|
||||
let (s, f) = many0(statement_or_null)(s)?;
|
||||
let (s, g) = keyword("endtask")(s)?;
|
||||
let (s, (f, g)) = many_till(statement_or_null, keyword("endtask"))(s)?;
|
||||
let (s, h) = opt(pair(symbol(":"), task_identifier))(s)?;
|
||||
Ok((
|
||||
s,
|
||||
|
@ -263,8 +263,7 @@ pub(crate) fn type_declaration_data_type(s: Span) -> IResult<Span, TypeDeclarati
|
||||
let (s, a) = keyword("typedef")(s)?;
|
||||
let (s, b) = data_type(s)?;
|
||||
let (s, c) = type_identifier(s)?;
|
||||
let (s, d) = many0(variable_dimension)(s)?;
|
||||
let (s, e) = symbol(";")(s)?;
|
||||
let (s, (d, e)) = many_till(variable_dimension, symbol(";"))(s)?;
|
||||
Ok((
|
||||
s,
|
||||
TypeDeclaration::DataType(Box::new(TypeDeclarationDataType {
|
||||
|
@ -82,8 +82,7 @@ pub(crate) fn named_checker_port_connection(s: Span) -> IResult<Span, NamedCheck
|
||||
pub(crate) fn named_checker_port_connection_identifier(
|
||||
s: Span,
|
||||
) -> IResult<Span, NamedCheckerPortConnection> {
|
||||
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<Span, NamedCheckerPortConnection> {
|
||||
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 {
|
||||
|
@ -6,8 +6,7 @@ use crate::*;
|
||||
#[packrat_parser]
|
||||
pub(crate) fn generate_region(s: Span) -> IResult<Span, GenerateRegion> {
|
||||
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<Span, GenerateBlock> {
|
||||
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,
|
||||
|
@ -146,8 +146,7 @@ pub(crate) fn named_port_connection(s: Span) -> IResult<Span, NamedPortConnectio
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn named_port_connection_identifier(s: Span) -> IResult<Span, NamedPortConnection> {
|
||||
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<Span, NamedPo
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn named_port_connection_asterisk(s: Span) -> IResult<Span, NamedPortConnection> {
|
||||
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) })),
|
||||
|
@ -325,8 +325,7 @@ pub(crate) fn class_constructor_declaration(s: Span) -> IResult<Span, ClassConst
|
||||
opt(paren(list_of_arguments)),
|
||||
symbol(";"),
|
||||
)))(s)?;
|
||||
let (s, h) = many0(function_statement_or_null)(s)?;
|
||||
let (s, i) = keyword("endfunction")(s)?;
|
||||
let (s, (h, i)) = many_till(function_statement_or_null, keyword("endfunction"))(s)?;
|
||||
let (s, j) = opt(pair(symbol(":"), new))(s)?;
|
||||
Ok((
|
||||
s,
|
||||
|
@ -10,8 +10,7 @@ pub(crate) fn config_declaration(s: Span) -> IResult<Span, ConfigDeclaration> {
|
||||
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<Span, ConfigDeclaration> {
|
||||
#[packrat_parser]
|
||||
pub(crate) fn design_statement(s: Span) -> IResult<Span, DesignStatement> {
|
||||
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) }))
|
||||
}
|
||||
|
||||
|
@ -80,8 +80,7 @@ pub(crate) fn package_or_generate_item_declaration(
|
||||
pub(crate) fn anonymous_program(s: Span) -> IResult<Span, AnonymousProgram> {
|
||||
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 {
|
||||
|
@ -79,8 +79,7 @@ pub(crate) fn description_bind_directive(s: Span) -> IResult<Span, Description>
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn module_nonansi_header(s: Span) -> IResult<Span, ModuleNonansiHeader> {
|
||||
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<Span, ModuleNonansiHeade
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn module_ansi_header(s: Span) -> IResult<Span, ModuleAnsiHeader> {
|
||||
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<Span, ModuleDeclaration> {
|
||||
pub(crate) fn module_declaration_nonansi(s: Span) -> IResult<Span, ModuleDeclaration> {
|
||||
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<Span, ModuleDeclara
|
||||
pub(crate) fn module_declaration_ansi(s: Span) -> IResult<Span, ModuleDeclaration> {
|
||||
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<Span, ModuleDeclaratio
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn module_declaration_wildcard(s: Span) -> IResult<Span, ModuleDeclaration> {
|
||||
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<Span, InterfaceDeclarati
|
||||
pub(crate) fn interface_declaration_nonansi(s: Span) -> IResult<Span, InterfaceDeclaration> {
|
||||
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<Span, InterfaceD
|
||||
pub(crate) fn interface_declaration_ansi(s: Span) -> IResult<Span, InterfaceDeclaration> {
|
||||
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<Span, InterfaceDecl
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn interface_declaration_wildcard(s: Span) -> IResult<Span, InterfaceDeclaration> {
|
||||
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<Span, Interf
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn interface_nonansi_header(s: Span) -> IResult<Span, InterfaceNonansiHeader> {
|
||||
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<Span, InterfaceNonans
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn interface_ansi_header(s: Span) -> IResult<Span, InterfaceAnsiHeader> {
|
||||
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<Span, ProgramDeclaration>
|
||||
pub(crate) fn program_declaration_nonansi(s: Span) -> IResult<Span, ProgramDeclaration> {
|
||||
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<Span, ProgramDecla
|
||||
pub(crate) fn program_declaration_ansi(s: Span) -> IResult<Span, ProgramDeclaration> {
|
||||
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<Span, ProgramDeclarat
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn program_declaration_wildcard(s: Span) -> IResult<Span, ProgramDeclaration> {
|
||||
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<Span, ProgramD
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn program_nonansi_header(s: Span) -> IResult<Span, ProgramNonansiHeader> {
|
||||
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<Span, ProgramNonansiHea
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn program_ansi_header(s: Span) -> IResult<Span, ProgramAnsiHeader> {
|
||||
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<Span, CheckerDeclaration>
|
||||
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<Span, ClassDeclaration> {
|
||||
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<Span, InterfaceCla
|
||||
list(symbol(","), interface_class_type),
|
||||
))(s)?;
|
||||
let (s, f) = symbol(";")(s)?;
|
||||
let (s, g) = many0(interface_class_item)(s)?;
|
||||
let (s, h) = keyword("endclass")(s)?;
|
||||
let (s, (g, h)) = many_till(interface_class_item, keyword("endclass"))(s)?;
|
||||
let (s, i) = opt(pair(symbol(":"), class_identifier))(s)?;
|
||||
Ok((
|
||||
s,
|
||||
@ -594,14 +576,15 @@ pub(crate) fn interface_class_method(s: Span) -> IResult<Span, InterfaceClassMet
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn package_declaration(s: Span) -> IResult<Span, PackageDeclaration> {
|
||||
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,
|
||||
|
@ -6,8 +6,7 @@ use crate::*;
|
||||
#[packrat_parser]
|
||||
pub(crate) fn specify_block(s: Span) -> IResult<Span, SpecifyBlock> {
|
||||
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) }))
|
||||
}
|
||||
|
||||
|
@ -15921,7 +15921,7 @@ mod error {
|
||||
error_test!(
|
||||
source_text,
|
||||
r##"module A(); parameter A = 1 endmodule"##,
|
||||
Some(12)
|
||||
Some(28)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,7 @@ pub(crate) fn udp_body(s: Span) -> IResult<Span, UdpBody> {
|
||||
pub(crate) fn combinational_body(s: Span) -> IResult<Span, CombinationalBody> {
|
||||
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<Span, SequentialBody> {
|
||||
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 {
|
||||
|
@ -5,8 +5,7 @@ use crate::*;
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn udp_nonansi_declaration(s: Span) -> IResult<Span, UdpNonansiDeclaration> {
|
||||
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<Span, UdpNonansiDeclar
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn udp_ansi_declaration(s: Span) -> IResult<Span, UdpAnsiDeclaration> {
|
||||
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<Span, UdpDeclarati
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn udp_declaration_wildcard(s: Span) -> IResult<Span, UdpDeclaration> {
|
||||
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)?;
|
||||
|
@ -45,8 +45,7 @@ pub(crate) fn udp_output_declaration(s: Span) -> IResult<Span, UdpOutputDeclarat
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn udp_output_declaration_nonreg(s: Span) -> IResult<Span, UdpOutputDeclaration> {
|
||||
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<Span, UdpOutputD
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn udp_output_declaration_reg(s: Span) -> IResult<Span, UdpOutputDeclaration> {
|
||||
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<Span, UdpOutputDecl
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn udp_input_declaration(s: Span) -> IResult<Span, UdpInputDeclaration> {
|
||||
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<Span, UdpInputDeclaratio
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn udp_reg_declaration(s: Span) -> IResult<Span, UdpRegDeclaration> {
|
||||
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) }))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user