From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,48164bbe9063c117,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!diablo.voicenet.com!yellow.newsread.com!news-toy.newsread.com!netaxs.com!newsread.com!POSTED.newshog.newsread.com!not-for-mail Newsgroups: comp.lang.ada Subject: ASIS question: How to detect branches of if statments? From: "Peter C. Chapin" Message-ID: User-Agent: Xnews/5.04.25 Date: Wed, 06 Apr 2005 02:05:42 GMT NNTP-Posting-Host: 216.114.166.11 X-Complaints-To: Abuse Role , We Care X-Trace: newshog.newsread.com 1112753142 216.114.166.11 (Tue, 05 Apr 2005 22:05:42 EDT) NNTP-Posting-Date: Tue, 05 Apr 2005 22:05:42 EDT Organization: SoVerNet (sover.net) Xref: g2news1.google.com comp.lang.ada:10287 Date: 2005-04-06T02:05:42+00:00 List-Id: Hi! I'm attempting to build an ASIS application. In my application I need to construct a control flow graph (CFG) of, for example, a particular procedure. For now I'm restricting myself to procedures with if/else statements and simple loops without internal exit statements. This is a class project so complete coverage of Ada is definitely not necessary. I see how to create the CFG for the loops. I provide pre and post traversal procedures. For ordinary statements I attach a new node to a "working point" in my graph. When I encounter a while loop (say), I create a node for the predicate and push the node on a stack. When I come to the end of the loop (in my post traversal procedure), I pop the stack and connect the last node of the loop body to the header node, etc. I can do something similar to handle an if statement with a single clause. But I'm stuck on how to handle if/else statements: if X = Y then -- Stuff. else -- Other stuff. end if; I can see the beginning of the if statement and I can see the end of it ("end if") but the traversal returns "stuff" and "other stuff" in one continuous stream without any obvious indication where the else fits into things. Clearly I'm missing something, but I'm not sure what. I saw some things about "Statement Paths" in the Asis.Statements package spec, but there isn't a lot of explanation about what they are. Is that something I should be playing with? I've looked at a couple of ASIS tutorials and they were helpful in getting me started, but it seems like I'm going to need some more detailed information now. Does anyone have any suggestions for a good tutorial that might fit where I'm at? Thanks! Peter