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)