[cfe-dev] Dividing statements

Pedro Delgado Perez pedro.delgadoperez at mail.uca.es
Thu Feb 27 03:36:46 PST 2014


 
Hi,

I have a sentence like this:

method( b )   ,       a = 3    ,      b++;

This sentence is a statement composed of three substatements. What I need is to difference those three substatements which are between commas to save them in a list:

Statement 1 -> method( b )
Statement 2-> a = 3
Statement 3 -> b++

So I tried using the "child_iterator" in the class Stmt, which I though it would be easy. 
In the first iteration, the statement is subdivided in:

[method( b ) , a = 3]   and    [b++;]

The first sentence is then subdivided again in:

[method( b )]  and   [a = 3]

The problem is that I don't know when I should stop the division because, now, the first statement is divided again to my surprise, taking the argument "b" as a new statement. Thus, I'm getting more than three statements, what is a major issue in my case.

Is there any way to count the number of statements separated by commas? Why it doesn't exist the reverse iterator? In that way, I could compare when a statement processed in the child_iterator is the same as the first statement divided in the reverse iterator. 

Thanks in advance,

Pedro.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140227/b72f0db4/attachment.html>


More information about the cfe-dev mailing list