Skip to content

Comments after string literals #11

@zarubaf

Description

@zarubaf

sv-parser gobbles comments after String literals into its whitespace vector. Consequently, they are not stripped from the sources. A minimal example:

// General comment
module comment_module #(
    parameter blub = "blub"    // "blub" or "blub1"
) (
    // In body comment.
);

endmodule

Produces:

module blub_comment_module #(
    parameter blub = "blub"    // "blub" or "blub1"
) (
    
);

endmodule

Expect:

module blub_comment_module #(
    parameter blub = "blub" 
) (
    
);

endmodule

Preprocessed syntax tree:

PreprocessorText { nodes: ([Comment(Comment { nodes: (Locate { offset: 0, line: 1, len: 18 },) }), NotDirective(SourceDescriptionNotDirective { nodes: (Locate { offset: 18, line: 1, len: 47 },) }), StringLiteral(StringLiteral { nodes: (Locate { offset: 65, line: 3, len: 6 }, [Space(Locate { offset: 71, line: 3, len: 4 }), Comment(Comment { nodes: (Locate { offset: 75, line: 3, len: 20 },) }), Space(Locate { offset: 95, line: 3, len: 1 })]) }), NotDirective(SourceDescriptionNotDirective { nodes: (Locate { offset: 96, line: 4, len: 8 },) }), Comment(Comment { nodes: (Locate { offset: 104, line: 5, len: 19 },) }), NotDirective(SourceDescriptionNotDirective { nodes: (Locate { offset: 123, line: 5, len: 43 },) })],) }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions