<div dir="ltr">Hi Pedro,<div><br></div><div>What's happening is that the comma operator can only take two expressions. When more than two expressions are joined with commas, the first two are joined by the comma operator, then that result is joined with expression, then that result is joined to the next expression and so on. So something like:</div>
<div><br></div><div>a, b, c, d;</div><div><br></div><div>is structurally similiar to:</div><div><br></div><div>(((a, b), c), d);</div><div><br></div><div>Instead of processing every sub-statement, you only need to process sub-statements when the current statement is the comma operator (that is, the statement is a BinaryOperator with comma opcode). If it is, the right Expr* is the last statement and the left Expr* is either the first statement, or another comma operator which you need to recurse on.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Hope that helps.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Richard<br><br><div class="gmail_quote">On Thu, Feb 27, 2014 at 3:36 AM, Pedro Delgado Perez <span dir="ltr"><<a href="mailto:pedro.delgadoperez@mail.uca.es" target="_blank">pedro.delgadoperez@mail.uca.es</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<p>Hi,</p>
<p>I have a sentence like this:</p>
<p>method( b ) , a = 3 , b++;</p>
<p>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:</p>
<p>Statement 1 -> method( b )<br>
Statement 2-> a = 3<br>
Statement 3 -> b++</p>
<p>So I tried using the "child_iterator" in the class Stmt, which I though it would be easy. <br>
In the first iteration, the statement is subdivided in:</p>
<p>[method( b ) , a = 3] and [b++;]</p>
<p>The first sentence is then subdivided again in:</p>
<p>[method( b )] and [a = 3]</p>
<p>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.</p>
<p>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. </p>
<p>Thanks in advance,</p>
<p>Pedro.</p>
</div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>