Live data from Hacker News

Show HN: Yupp, yet another C preprocessor

github.com

1–10 of 11 posts

Re: Show HN: Yupp, yet another C preprocessor

#4
Technically, this is not a C preprocessor, more like a general-purpose macro processor, since you're using it as a third layer (second being C macros, first being C itself) instead of replacing C macros.

Although it gives me an idea, a converter that takes a valid C program (with macros) and replaces the C macros with some other macros (in this case yupp macros) that perform the same task. e.g.,

replacing

#include

with something like:

($include "stdio.h")

Re: Show HN: Yupp, yet another C preprocessor

#5
post #4

Technically, this is not a C preprocessor, more like a general-purpose macro processor, since you're using it as a third layer (second being C macros, first being C itself) instead of replacing C macros. Although it gives me an idea, a converter that takes a valid C program (with macros) and replaces the C macros with some other macros (in this case yupp macros) that perform the same task. e.g., replacing #include wi…

My first thought as well. Why restrict to C? It could be useful for many other languages.

Re: Show HN: Yupp, yet another C preprocessor

#7
post #4

Technically, this is not a C preprocessor, more like a general-purpose macro processor, since you're using it as a third layer (second being C macros, first being C itself) instead of replacing C macros. Although it gives me an idea, a converter that takes a valid C program (with macros) and replaces the C macros with some other macros (in this case yupp macros) that perform the same task. e.g., replacing #include wi…

Yes, you are right. Since yupp is a third layer, yupp is able to generate C macros, for example:

  ($define,,assert_bit_mask( value, mask, op ),,($do ]
      bool test = ((( value ) & ( mask )) == ( mask ));
      if ( !test ) {
          ut_fault( "expected mask to be set", __FILE__,  __FUNCTION__, __LINE__ );
          op;
      }
  [ ))
will result in:

  #define assert_bit_mask( value, mask, op ) do { \
      bool test = ((( value ) & ( mask )) == ( mask )); \
      if ( !test ) { \
          ut_fault( "expected mask to be set", __FILE__,  __FUNCTION__, __LINE__ ); \
          op; \
      } \
  } while ( 0 )
but you don't need to think about backslashes)

Re: Show HN: Yupp, yet another C preprocessor

#8
post #5
post #4

Technically, this is not a C preprocessor, more like a general-purpose macro processor, since you're using it as a third layer (second being C macros, first being C itself) instead of replacing C macros. Although it gives me an idea, a converter that takes a valid C program (with macros) and replaces the C macros with some other macros (in this case yupp macros) that perform the same task. e.g., replacing #include wi…

My first thought as well. Why restrict to C? It could be useful for many other languages.

Just because C is my primary tool) and I have created yupp, to do things like X Macros simpler.

yupp can even be used with Python, as it allows to make the right indentation, e.g. https://github.com/in4lio/yupp/blob/master/eg/dict.yu-py

Re: Show HN: Yupp, yet another C preprocessor

#9

I've always thought it's a shame there isn't a better C (and C++) preprocessor -- people go to heroic lengths to do things with the terrible pre-processor they have by default (the lack of recursion, and dodgy comma handling are particularly painful).

Oh, yes, I agree. And when I was tired of writing macros like this: https://gist.github.com/in4lio/9102547, I wrote yupp)

Re: Show HN: Yupp, yet another C preprocessor

#10
post #3

yupp allows to generate a readable, well-formatted text. Special attention is paid to providing complete diagnostic information and navigational capabilities. so generate proper markdown for the github page...

This is a matter of taste, in this case, IMHO. Thanks for advice)
Post reply on HN