示例#1
0
        /// <summary>
        /// Interpret LetStatement
        /// </summary>
        /// <param name="statement">LetStatement to interpret</param>
        public override void Visit(LetStatement statement)
        {
            //Create SymbolTable's for each assignment to let referencing work properly
            foreach (Assignment asgn in statement.GetAssignments())
            {
                SymbolTable = new SymbolTable(SymbolTable);
                asgn.AcceptVisitor(this);
            }

            //If no root element, create one
            if (statement.GetStatements().Count > 1 && Root == null)
            {
                XHTMLElement newRoot = new XHTMLElement("html", null, true);
                Root    = newRoot;
                Current = Root;
            }

            //Interpret statements
            int depth = this.Depth;

            foreach (Statement stmt in statement.GetStatements())
            {
                stmt.AcceptVisitor(this);
                BackToParentXHTMLElement(depth);
            }

            //Go back to scope outside let statement
            foreach (Assignment asgn in statement.GetAssignments())
            {
                SymbolTable = SymbolTable.GetParentSymbolTable();
            }
        }
示例#2
0
        /// <summary>
        /// Visit LetStatement
        /// </summary>
        /// <param name="statement">LetStatement to check</param>
        public override void Visit(LetStatement statement)
        {
            foreach (Assignment assignment in statement.GetAssignments())
            {
                //Go level deeper in SymbolTable, to check using variables in other assignments
                CreateChildSymbolTable();

                //Visit Assignment
                assignment.AcceptVisitor(this);
            }


            //Visit statements
            foreach (Statement stmt in statement.GetStatements())
            {
                stmt.AcceptVisitor(this);
            }

            //Go back to level of statement in SymbolTable
            foreach (Assignment assignment in statement.GetAssignments())
            {
                MoveToParentSymbolTable();
            }
        }