Extending GNU C extensions

Amit Choudhary amit2030@yahoo.com
Mon Sep 25 17:44:00 GMT 2006


In my opinion, you can use macros for some of the things, and
then write a program in perl to pre-process the code, before
invoking gcc, to convert the rest of the new constructs to GNU C
constructs. But there may be other options.

Hope this helps.

Regards,
Amit 

--- Alpt <alpt@freaknet.org> wrote:

> 
> Hi there,
> 
> I'd like to extend the syntax of GNU C with few basic
> constructs.
> Their main purpose is to simplify the use of repetitive
> statements and to add
> some syntax sugar (but not to much).
> All the new constructs can be converted to normal GNU C.
> 
> The idea is to use a translator that converts the new syntax
> to the GNU C one,
> in this way, it can be compatible to gcc.
> 
> What is the best way to achieve this?
> Using flex&bison, M4, the sources of gcc, perl regexp, a
> specific tool?
> 
> What I'm looking for is a simple way to translate this new
> simple syntax to
> GNU C, without rewriting a compiler.
> 
> 
> These are some of the new syntax constructs:
> 
> -  Struct
> 
> element<-struct = value;	  ==>	struct->element = value;
> 
> element<`struct = value;	  ==>	struct.element = value;
> struct`>element = value;	  ==>	struct.element = value;
> 
> - High Level Boolean Logic
> 
> A &|| B	      ==>    (A && B) || (A || B)
> In english it's the same of: A and/or B
> 
> (A && |B, C, D, E|)     ==>   (A && B) || (A && C) || (A && D)
> || (A && E)
> (A || |B, C, D, E|)     ==>   (A || B) || (A || C) || (A || D)
> || (A || E)
> 					  ==>  A || B || C || D || E 
> 
> (A || &B, C, D, E&)     ==>   (A || B) && (A || C) && (A || D)


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Gcc-help mailing list