sysprog21 / shecc

A self-hosting and educational C optimizing compiler
BSD 2-Clause "Simplified" License
1.11k stars 118 forks source link

Implement #if defined(...) and #elif defined(...) and #else #62

Closed ChinYikMing closed 1 year ago

ChinYikMing commented 1 year ago

Now only support simple conditional expression which is defined(...) after #if and #elif. More complex conditional expression might be supported in the future.

Refactor 'lib/c.c' to improve readability.

Also, add a simple test case to 'tests/driver.sh'

jserv commented 1 year ago

Can you reuse the logic between #ifdef and #if defined?

ChinYikMing commented 1 year ago

Do you mean use #ifdef and #if defined at the same time?

jserv commented 1 year ago

Do you mean use #ifdef and #if defined at the same time?

I meant, to avoid code duplication for the same functionalities mentioned above.

ChinYikMing commented 1 year ago

I think some logic of #if and #elif can be refactored. Is it possible for next commit?

jserv commented 1 year ago

I think some logic of #if and #elif can be refactored. Is it possible for next commit?

You can submit multiple functional commits in this pull request.

jserv commented 1 year ago

Thank @ChinYikMing for contributing!