Semantical checks that involve flow of execution of the program

Lujop <lujoplujop@gmail.com>
17 Oct 2004 16:09:46 -0400

          From comp.compilers

Related articles
Semantical checks that involve flow of execution of the program lujoplujop@gmail.com (Lujop) (2004-10-17)
Re: Semantical checks that involve flow of execution of the program skaller@nospam.com.au (John Max Skaller) (2004-10-21)
Re: Semantical checks that involve flow of execution of the program choksheak@yahoo.com (ChokSheak Lau) (2004-10-21)
| List of all articles for this month |

From: Lujop <lujoplujop@gmail.com>
Newsgroups: comp.compilers
Date: 17 Oct 2004 16:09:46 -0400
Organization: Compilers Central
Keywords: analysis
Posted-Date: 17 Oct 2004 16:09:46 EDT

Hi,


I'm writting a compiler for a pseudocode language similar to Java. I
use a pred-LL(1) parser (with ANTLR) and I construct an AST that I
walk several times (currently twice) to do the semantical checking.
Well my question is that I want to do some intelligent checks for
program flow like Java does.


For example in variable initialization:


//var a is not inicialized
...
if codition1 then
              a <- 1
else if codition2 then
              b <-2
else
              a <- 1


With this example Java says that 'a' is possibly not initialized
because branch 2 don't assign any value in a.
The problem, is that I don't know how to do this checks (also I want
to do this checks for return of methods).
I have an AST and a symbol table but I have been thinking a little
about it and I can't find a solution.
Can one can give me a solution, or point me to some readings to solve
this problem and say if this is difficult or easy.


A lot of thanks in advance,
--
Joan Jesús Pujol Espinar


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.