public SyntacticAnalyzer(LexicalAnalyzer la)
 {
     this.la = la;
 }
예제 #2
0
        static int Main(string[] args)
        {
            programFile = null;
            printLA     = false;
            printSA     = false;
            printIAM    = false;
            printIAG    = false;
            printIALE   = false;

            if (!ParseArguments(args))
            {
                PrintHelp();
                Console.ReadKey();
                return(-1);
            }

            LexicalAnalyzer   la = new LexicalAnalyzer(programFile, printLA);
            SyntacticAnalyzer sa = new SyntacticAnalyzer(la);
            ProgramAst        prg;

            if (!sa.GetAST(out prg))
            {
                Console.ReadKey();
                return(-1);
            }

            SemanticAnalyzer sea = new SemanticAnalyzer();

            if (!sea.CheckAST(prg))
            {
                Console.ReadKey();
                return(-1);
            }

            Console.WriteLine("Pocet promennych: {0}, pocet funkci: {1}", prg.VarsDecl.Count, prg.OrigFncs.Count);

            StatementConverter sc = new StatementConverter(printSA);

            sc.ConvertToIfGoto(prg);

            GraphGenerator gg = new GraphGenerator();

            gg.CreateGraph(prg);

            Stopwatch s = new Stopwatch();

            s.Start();

            int n = prg.VarsDecl.Count;
            InterproceduralAnalyzer ia = new InterproceduralAnalyzer(w, n, printIAM, printIAG, printIALE);

            ia.Analyze(prg);

            s.Stop();

            WriteProgram wp = new WriteProgram();

            wp.Write(prg, programFile);

            Console.WriteLine("Cas analyzy: {0:N3} s", s.ElapsedMilliseconds / 1000.0);
            Console.WriteLine("Stiskni klavesu...");
            Console.ReadKey();
            return(0);
        }