Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable comments in preprocessor #5

Closed
zarubaf opened this issue Mar 11, 2020 · 1 comment · Fixed by #6
Closed

Enable comments in preprocessor #5

zarubaf opened this issue Mar 11, 2020 · 1 comment · Fixed by #6
Assignees

Comments

@zarubaf
Copy link
Contributor

zarubaf commented Mar 11, 2020

Thanks for this really nice parser. I know that a complete SV parser is a huge undertaking.

I would be interested in similar behavior to #4. I can see that the preprocessor strips comments so they don't appear in the AST later.

When adding (preprocessor.rs:258):

NodeEvent::Enter(RefNode::Comment(x)) => {
                let locate: Locate = x.try_into().unwrap();
                let range = Range::new(locate.offset, locate.offset + locate.len);
                ret.push(locate.str(&s), Some((path.as_ref(), range)));
            }

I see comments after preprocessing, but I get weird behaviour after a macro expansion:
Input:

`define IMPORT(__pkg)  \
    import __pkg::*;
    
module lala;
    // pragma translate_off
    // Test run
    `IMPORT(body2_import_pkg) // this is a macro
    always_comb begin
        a <= b;
    end
    // pragma translate_on
endmodule

Expected:

    
module lala;
    // pragma translate_off
    // Test run
    import body2_import_pkg::*;  // this is a macro
    always_comb begin
        a <= b;
    end
    // pragma translate_on
endmodule

Observed:

 
    
module lala;
    // pragma translate_off
    // Test run
    import body2_import_pkg::*; // this is a macroalways_comb begin
        a <= b;
    end
    // pragma translate_on
endmodule

Even without comments, the indentation becomes strange after macro expansion but it never triggers any illegal behavior, only when line comments (//) are enabled this becomes problematic.

@zarubaf
Copy link
Contributor Author

zarubaf commented Mar 19, 2020

Is there any comment or update on this? Even a won't fix would be fine somehow. I appreciate your input on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants