in4lio
Re:Ask HN: Have you created a programming language and why?
on Tuesday March 07, 2017 @11:21AM (#13811608)
Yes, I have written a few)) Because this is the most interesting area of programming for me.
Many years ago, I wrote BNF-like language to translate text into syntactic tree, it was part of my graduation project.
I also wrote a Lisp-like lexical preprocessor as an alternative to the standard C preprocessor, it can be used with other languages, for example, with Python.
Fine! To generate the C code using Lisp syntax - it's not such bad idea, the C preprocessor is awful. A few years ago, for this purpose, I wrote the yupp preprocessor which use similar syntax, but yupp allows to inject the code in functional style into the source code on C.
Re:Show HN: Yupp, yet another C preprocessor
on Tuesday September 15, 2015 @07:18PM (#10223728)
This is a matter of taste, in this case, IMHO. Thanks for advice)
Re:Show HN: Yupp, yet another C preprocessor
on Tuesday September 15, 2015 @07:15PM (#10223717)
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
on Tuesday September 15, 2015 @07:00PM (#10223665)
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
on Tuesday September 15, 2015 @06:36PM (#10223583)
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)