Exemplo n.º 1
0
 //<elseif>//
 public string Visit(ElseIfList node)
 {
     elsifexit = lastIF;
     if (0 < CountChildren(node))
     {
         return(VisitChildren(node));
     }
     return("");
 }
Exemplo n.º 2
0
        public string Visit(ElseIfList node, string labelElse, string labelContinue)  
        {
            var result = "";

            foreach (var child in node)
            {
                result += Visit((ElseIf)child, labelContinue);
            }
            result += "\t\tbr " + labelElse + "\n";
            return(result);
        }
Exemplo n.º 3
0
        public Node If()
        {
            var n1 = new If();

            n1.AnchorToken = Expect(TokenType.IF);
            Expect(TokenType.PARENTHESIS_OPEN);
            n1.Add(Expression());
            Expect(TokenType.PARENTHESIS_CLOSE);
            Expect(TokenType.BLOCK_BEGIN);
            var n2 = new StatementList();

            while (firstOfStatement.Contains(CurrentToken))
            {
                n2.Add(Statement());
            }
            n1.Add(n2);
            var n3 = new ElseIfList();

            Expect(TokenType.BLOCK_END);
            while (CurrentToken == TokenType.ELSEIF)
            {
                var nelsif = new ElseIf();
                nelsif.AnchorToken = Expect(TokenType.ELSEIF);
                Expect(TokenType.PARENTHESIS_OPEN);
                nelsif.Add(Expression());
                Expect(TokenType.PARENTHESIS_CLOSE);
                Expect(TokenType.BLOCK_BEGIN);
                var stmtList = new StatementList();
                while (firstOfStatement.Contains(CurrentToken))
                {
                    stmtList.Add(Statement());
                }
                nelsif.Add(stmtList);
                n3.Add(nelsif);
                Expect(TokenType.BLOCK_END);
            }
            n1.Add(n3);
            var els = new Else();

            if (CurrentToken == TokenType.ELSE)
            {
                els.AnchorToken = Expect(TokenType.ELSE);
                Expect(TokenType.BLOCK_BEGIN);
                var stmtList = new StatementList();
                while (firstOfStatement.Contains(CurrentToken))
                {
                    stmtList.Add(Statement());
                }
                els.Add(stmtList);
                Expect(TokenType.BLOCK_END);
            }
            n1.Add(els);
            return(n1);
        }
Exemplo n.º 4
0
        public override bool Equals(object other)
        {
            var otherNode = other as IfStmtNode;

            if (null == otherNode)
            {
                return(false);
            }

            return(IfExprNode.Equals(otherNode.IfExprNode) &&
                   otherNode != null && IfBody.SequenceEqual(otherNode.IfBody) &&
                   ElseIfList != null && ElseIfList.SequenceEqual(otherNode.ElseIfList) &&
                   ElseBody != null && ElseBody.SequenceEqual(otherNode.ElseBody));
        }
Exemplo n.º 5
0
        //If side function//
        public Node If()
        {
            var result = new If()
            {
                AnchorToken = Expect(TokenCategory.IF)
            };

            Expect(TokenCategory.PARENTHESIS_OPEN);

            result.Add(Expression());

            Expect(TokenCategory.PARENTHESIS_CLOSE);

            Expect(TokenCategory.CURLY_BRACKET_OPEN);

            result.Add(StmtList());

            Expect(TokenCategory.CURLY_BRACKET_CLOSE);

            var elseIfListr = new ElseIfList();

            while (elsif.Contains(CurrentToken))
            {
                elseIfListr.Add(elseif());
            }

            result.Add(elseIfListr);

            var elser = new Else();

            if (CurrentToken == TokenCategory.ELSE)
            {
                elser = new Else()
                {
                    AnchorToken = Expect(TokenCategory.ELSE)
                };

                Expect(TokenCategory.CURLY_BRACKET_OPEN);

                elser.Add(StmtList());

                Expect(TokenCategory.CURLY_BRACKET_CLOSE);
            }
            result.Add(elser);

            return(result);
        }
Exemplo n.º 6
0
        public Node ElseIf()
        {
            var node = new ElseIfList();

            while (CurrentToken == TokenCategory.ELSEIF)
            {
                var node_elseif = new ElseIf();
                Expect(TokenCategory.ELSEIF);
                Expect(TokenCategory.OPENEDPAR);
                node_elseif.Add(Expr());
                Expect(TokenCategory.CLOSEDPAR);
                Expect(TokenCategory.OPENEDCURLY);
                node_elseif.Add(StmtList());
                Expect(TokenCategory.CLOSEDCURLY);
                node.Add(node_elseif);
            }
            return(node);
        }
Exemplo n.º 7
0
        public Node ElseIf()
        {
            //elseif(‹expr›){‹stmt-list›} *
            var n = new ElseIfList();

            while (CurrentToken == TokenCategory.ELSEIF)
            {
                var n1 = new ElseIf();
                Expect(TokenCategory.ELSEIF);
                Expect(TokenCategory.OPENEDPAR);
                n1.Add(Expr());
                Expect(TokenCategory.CLOSEDPAR);
                Expect(TokenCategory.OPENEDCURLY);
                n1.Add(StmtList());
                Expect(TokenCategory.CLOSEDCURLY);
                n.Add(n1);
            }
            return(n);
        }
Exemplo n.º 8
0
        public Node ElseIfList()
        {
            var elseIfList = new ElseIfList();

            while (CurrentToken == TokenCategory.ELSE)
            {
                var elseToken = Expect(TokenCategory.ELSE);
                if (CurrentToken == TokenCategory.IF)
                {
                    elseIfList.Add(ElseIf(elseToken));
                }
                else if (CurrentToken == TokenCategory.BRACKETS_OPEN)
                {
                    elseIfList.Add(Else(elseToken));
                }
            }

            return(elseIfList);
        }
Exemplo n.º 9
0
        public override void WriteToStream(IndentStream stream)
        {
            stream.Write("IF ");
            Condition.WriteToStream(stream);
            stream.WriteLine();

            Body.WriteToStream(stream);

            //stream.WriteLine("BEGIN");
            //stream.Indent++;
            //foreach (SqlCodeExpr expr in Body)
            //{
            //	expr.WriteToStream(stream);
            //	stream.WriteLine();
            //}
            //stream.Indent--;
            //stream.Write("END");

            if (ElseIfList != null && ElseIfList.Count > 0)
            {
                stream.WriteLine();
                ElseIfList.WriteToStream(stream);
            }

            //if( ElseExpr != null && ElseExpr.Count > 0)
            //{
            //	stream.WriteLine();
            //	stream.WriteLine("ELSE BEGIN");
            //	stream.Indent++;
            //	ElseExpr.WriteToStream(stream);
            //	stream.Indent--;
            //	stream.WriteLine();
            //	stream.Write("END");
            //}

            if (ElseExpr != null)
            {
                stream.WriteLine();
                stream.Write("ELSE ");
                ElseExpr.WriteToStream(stream);
            }
        }
        public Node ElseIfList()
        {
            var elseIfList = new ElseIfList();

            while (Current == TokenCategory.ELSEIF)
            {
                var elseIf = new ElseIf()
                {
                    AnchorToken = Expect(TokenCategory.ELSEIF)
                };
                Expect(TokenCategory.OPEN_PARENTHESIS);
                elseIf.Add(Expr());
                Expect(TokenCategory.CLOSE_PARENTHESIS);
                Expect(TokenCategory.OPEN_BRACKET);
                elseIf.Add(StmtList());
                Expect(TokenCategory.CLOSE_BRACKET);
                elseIfList.Add(elseIf);
            }
            return(elseIfList);
        }
Exemplo n.º 11
0
        public Node ElseIfList()
        {
            var result = new ElseIfList();

            while (CurrentToken == TokenCategory.ELIF)
            {
                var elifNode = new ElseIf();
                var elif     = Expect(TokenCategory.ELIF);
                Expect(TokenCategory.PARENTHESIS_OPEN);
                var expr = Expression();
                elifNode.Add(expr);
                Expect(TokenCategory.PARENTHESIS_CLOSE);
                Expect(TokenCategory.BRACKET_OPEN);
                var stmtList = StmtList();
                elifNode.Add(stmtList);
                Expect(TokenCategory.BRACKET_CLOSE);

                elifNode.AnchorToken = elif;
                result.Add(elifNode);
            }
            return(result);
        }
 public void Visit(ElseIfList node)
 {
     VisitChildren(node);
 }
Exemplo n.º 13
0
        public Node If()
        {
            var result = new If()
            {
                AnchorToken = Expect(TokenCategory.IF)
            };

            result.Add(Expression());
            Expect(TokenCategory.THEN);
            if (firstOfStatement.Contains(CurrentToken))
            {
                var statementList = new StatementList();
                while (firstOfStatement.Contains(CurrentToken))
                {
                    statementList.Add(Statement());
                }
                result.Add(statementList);
            }

            var elseIfList = new ElseIfList();

            if (CurrentToken == TokenCategory.ELSEIF)
            {
                while (CurrentToken == TokenCategory.ELSEIF)
                {
                    var elseIf = new ElseIf()
                    {
                        AnchorToken = Expect(TokenCategory.ELSEIF)
                    };

                    elseIf.Add(Expression());
                    Expect(TokenCategory.THEN);
                    if (firstOfStatement.Contains(CurrentToken))
                    {
                        var statementList = new StatementList();
                        while (firstOfStatement.Contains(CurrentToken))
                        {
                            statementList.Add(Statement());
                        }
                        elseIf.Add(statementList);
                    }
                    elseIfList.Add(elseIf);
                }
            }
            result.Add(elseIfList);

            var els = new Else();

            if (CurrentToken == TokenCategory.ELSE)
            {
                els.AnchorToken = Expect(TokenCategory.ELSE);
                if (firstOfStatement.Contains(CurrentToken))
                {
                    var statementList = new StatementList();
                    while (firstOfStatement.Contains(CurrentToken))
                    {
                        statementList.Add(Statement());
                    }
                    els.Add(statementList);
                }
            }
            result.Add(els);

            Expect(TokenCategory.END);
            Expect(TokenCategory.SEMICOLON);
            return(result);
        }
Exemplo n.º 14
0
 public void Visit(ElseIfList node)
 {
 }
Exemplo n.º 15
0
 public string Visit(ElseIfList node)
 {
     return(VisitChildren(node));
 }
Exemplo n.º 16
0
 public Type Visit(ElseIfList node)
 {
     VisitChildren(node);
     return(Type.VOID);
 }
Exemplo n.º 17
0
 //<elseif>//
 public void Visit(ElseIfList node, char i)
 {
     VisitChildren(node, i);
 }