ned14 / pcpp

A C99 preprocessor written in pure Python
Other
220 stars 41 forks source link

Support #line in input #23

Closed Sei-Lisa closed 5 years ago

Sei-Lisa commented 5 years ago

This directive should be easy to support:

  1. expand macros;
  2. if the first token is a number, set __LINE__ and eat it, otherwise emit an error;
  3. if the next token is a string, set __FILE__ and eat it;
  4. if anything remains, give an error.

I think I can come up with a PR, if interested, but I haven't looked into it yet so I don't know if I'll be able to.

Sei-Lisa commented 5 years ago

After looking into the implementation of __LINE__, I've realized that it's not trivial.

ned14 commented 5 years ago

The only reason I never implemented these is because I personally didn't need them. And I still don't. But I'm happy to accept a donation of an implementation if with a rigorous test suite, and if the code is maintainable.