Working on a new front-end
Matthieu.Moy@imag.fr
Matthieu.Moy@imag.fr
Wed Oct 15 10:42:00 GMT 2003
"Jack, Paul" <pjack@sfaf.org> writes:
> The new language will be imperative and have C-like syntax, but I want to
> add LISP-like macros. The macros would be ordinary functions that take a
> pointer to a parse tree as the first parameter; the functions can modify
> those parse trees and actually modify the program before code generation.
Did you have a look at OpenC++ ? This is a preprocessor for C++ which
allows you to do this kind of thing.
For example, in C++, you have the `=' operator, taking a lvalue as a
left operator, and a value on the right. At the meta level, during
preprocessing, you can define an operator `=' taking a parse tree as a
right operand. The example given in the manual is the calculation of
expressions like
A = B + C - D;
where A, B, C and D are arrays, with only one for loop.
http://www.csg.is.titech.ac.jp/~chiba/openc++.html
--
Matthieu
More information about the Gcc
mailing list