// *** You will need the following if you implement classes.

        //protected static ClassAttributes currentClass = null;

        //protected void SetCurrentClass(ClassAttributes c)
        //{
        //    currentClass = c;
        //}
        //protected ClassAttributes GetCurrentClass()
        //{
        //    return currentClass;
        //}

        // Call this method to begin the semantic checking process
        public void CheckSemantics(AbstractNode node)
        {
            if (node == null)
            {
                return;
            }
            TopDeclVisitor visitor = new TopDeclVisitor();

            node.Accept(visitor);
        }
示例#2
0
        public void DoSemantics()
        {
            Console.WriteLine("\nStarting declarations processing\n");
            SymbolTable    symbolTable    = new SymbolTable();
            TopDeclVisitor topDeclVisitor = new TopDeclVisitor(symbolTable);

            topDeclVisitor.CheckSemantics(CurrentSemanticValue);
            Console.WriteLine("\nErrors found:");
            ErrorList.Print();
        }
示例#3
0
        public virtual void VisitNode(AbstractNode node)
        {
            AbstractNode   child   = node.Child;
            TopDeclVisitor visitor = new TopDeclVisitor();

            while (child != null)
            {
                child.Accept(visitor);
                node.TypeRef = child.TypeRef;
                child        = child.Sib;
            }
            ;
        }
示例#4
0
        //Starting Node of an AST
        public void VisitNode(CompilationUnit node)
        {
            table.incrNestLevel();
            table.BuildTree();
            AbstractNode   child   = node.Child;
            TopDeclVisitor visitor = new TopDeclVisitor();

            while (child != null)
            {
                child.Accept(visitor);
                node.TypeRef = child.TypeRef;
                child        = child.Sib;
            }
            ;
        }
        //Starting Node of an AST
        public void VisitNode(CompilationUnit node)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("< In SemanticsVisitor.VisitNode for " + node.ClassName() + " >");
            Console.ResetColor();

            TopDeclVisitor visitor = new TopDeclVisitor();
            AbstractNode   child   = node.Child;

            while (child != null)
            {
                child.Accept(visitor);
                child = child.Sib;
            }
            ;
        }
示例#6
0
        public void VisitNode(Block node)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("< In TopDeclVisitor.VisitNode for " + node.ClassName() + " >");
            Console.ResetColor();

            TopDeclVisitor visitor = new TopDeclVisitor();

            table.incrNestLevel();
            AbstractNode child = node.Child;

            while (child != null)
            {
                child.Accept(visitor);
                child = child.Sib;
            }
            ;
            table.decrNestLevel();
        }