Skip to content

Preprocessor - expose complete parser? #165

Description

@the-moog

I can see that the way hdlConverter works is that it first passes the code through a preprocessor.
Then produces and AST from the resulting text.

This preprocessor 'flattens' the code, replacing defines and ifdef/else blocks, etc.

I am finding a problem with this as I need to know what is inside those backtick blocks.

My use case is more complicated than this, but I can give a sort of practical example.
e.g.

I want to merge two code blocks programmatically.

Both code blocks include the same files.

I want to move that include to the top of the generated file so that it's not included twice as that would cause redefinition.

But in one file that include may (or may not) be inside an undefined `ifdef, in that case it should not be moved.
This might be because depending on that ifdef a different include is made.

So I need to know where the `ifdef starts and ends so that I can resolve the ifdef, but that parsing operation is not exposed to the user, it's transparent.

Is there a way to see the AST that the preprocessor uses, before flattening, rather than the output from hdlAst?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions