Skip to content

Surprising parse error for define in else block #41

@Timmmm

Description

@Timmmm

Continuing with my annoying preprocessor parsing! (I'm trying to parse a file that is like 30% preprocessor directives unfortunately....)

This parses:

module foo;
    initial begin
        if (a)
            `FOO;
    end
endmodule

But surprisingly this doesn't:

module foo;
    initial begin
        if (a)
            `FOO;
        else
            b = c;
    end
endmodule

Again, if that's difficult to do, don't worry. Workaround is:

module foo;
    initial begin
        if (a) begin
            `FOO;
        end else
            b = c;
    end
endmodule

(Which IMO the code should be doing already - optional begin/end is a footgun.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions