language.c: support for statements in MonadTrav

Alexander Bernauer bernauer at
Tue Feb 1 08:31:04 GMT 2011


On Mon, Jan 31, 2011 at 10:56:19PM +0100, Benedikt Huber wrote:
> MonadTrav was and is, AFAIK, mostly used to collect
> declarations and build an intermediate representation of the program.

So, MonadTrav and especially AstAnalysis peform a convertion from
Syntax.AST to Analysis.SemRep, right? Is there also a way to go back?
Or can you pretty print the SemRep objects? 

In either case (if existant), if I go C-code --parser--> Syntax.AST
--astAnalysis--> Analysis.SemRep --"inverting"--> C-code, how much does
the output differ from the input?

> library client does not have to deal with all the difficult aspects of
> the C language itself (otherwise, where is the benefit in having
> traversal callbacks?).  

I am not sure if I get this. What I would like to have is a visitor for
ASTs. For example I want to determine the call graph of a program. So I
have to traverse all function definitions looking for function calls.

For this and many other similar tasks having a generic implementation of
the visitor pattern on ASTs would help. CIL provides this by means of
the cilVisitor class [1].

Maybe this differs from the scope of MonadTrav. In that case I would go
on and try to implement a visitor framework. 

> One important aspect is taking care of declarations (which are quite
> difficult to handle in C), and provide the info from type checking.
> I'm not sure what else you would need; especially whether you really
> need a full IR for statements and expressions (that's what CIL does,
> right?).

CIL has only one family of types that represent C programs. Whether it
is closer to Syntax.AST or to Analysis.SemRep I can't say currently.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <>

More information about the Language-c mailing list