I have been rather excited about this project and have been keeping an
eye on it for several months,myself been some what of a PL
aficionado.I have tinkered around with the driver ,writing simple
programs such as building a AST from scratch.But I was wondering: how do
I add custom language features to the AST as if I was building another C
language variant? Is it possible to make a class inherit from the 'Stmt'
class and function properly without modifying the 'StmtNodes.def' and
If I understand right, the clang project is meant to be a highly
flexible collection of libraries to be used with c/c++/obj-c/obj-c++.But
has it been designed as to be extended for other languages in this
closely related family?
thanks in advance for your time.
The ASTs have been designed to be extendable by defining subclasses of Stmt or Expr. You do need to add an extra entry to StmtNodes.def, however, because that is used by the internal RTTI of Clang (all the cast<> and dyn_cast<> magic works using the values defined in StmtNodes.def). If you look at subclasses of Stmt and Expr respectively, you will see that they pass up a value defined in StmtNodes.def to the ctor of Stmt.