Lambosaurus / py-c-preprocessor

Tools for preprocessing C files in python
MIT License
15 stars 3 forks source link

Recursive macro expansions fails when a token without arguments expands into token with arguments. #10

Closed Lambosaurus closed 7 months ago

Lambosaurus commented 7 months ago

The following tests produces the issue.

    p.define("MACRO_B", "(a + 1)", ["a"])
    p.define("MACRO_C", "MACRO_B")

    # A non arg macro that expands into an argument macro
    test_assert(p.evaluate("MACRO_C(1)"), 2)

This is because the parser attempts to recursively evaluate MACRO_C without considering the arguments.