コード例 #1
0
        public Node ElseIfList()
        {
            var elseIfList = new ListElseIf();

            while (CurrentToken == TokenCategory.ELSEIF)
            {
                var elseIfToken = new ElseIf()
                {
                    AnchorToken = Expect(TokenCategory.ELSEIF)
                };
                Expect(TokenCategory.PARENTHESIS_OPEN);
                elseIfToken.Add(Expression());
                Expect(TokenCategory.PARENTHESIS_CLOSE);
                var n1 = new ListStatements();
                Expect(TokenCategory.BRACE_OPEN);
                while (firstOfStatement.Contains(CurrentToken))
                {
                    n1.Add(Statement());
                }
                elseIfToken.Add(n1);
                Expect(TokenCategory.BRACE_CLOSE);
                elseIfList.Add(elseIfToken);
            }
            return(elseIfList);
        }
コード例 #2
0
        public Node FunDef()
        {
            var n1 = new FunctionDef()
            {
                AnchorToken = Expect(TokenCategory.IDENTIFIER)
            };

            Expect(TokenCategory.PARENTHESIS_OPEN);
            if (CurrentToken == TokenCategory.IDENTIFIER)
            {
                n1.Add(IDList(new ParamList()));
            }
            else
            {
                n1.Add(new ParamList());
            }
            Expect(TokenCategory.PARENTHESIS_CLOSE);
            Expect(TokenCategory.BRACE_OPEN);
            while (CurrentToken == TokenCategory.VAR)
            {
                n1.Add(VarDef());
            }
            if (firstOfStatement.Contains(CurrentToken))
            {
                var listStmt = new ListStatements();
                while (firstOfStatement.Contains(CurrentToken))
                {
                    listStmt.Add(Statement());
                }
                n1.Add(listStmt);
            }
            Expect(TokenCategory.BRACE_CLOSE);
            return(n1);
        }
コード例 #3
0
        public Node Else()
        {
            var n1 = new ListStatements();

            if (CurrentToken == TokenCategory.ELSE)
            {
                Expect(TokenCategory.ELSE);
                Expect(TokenCategory.BRACE_OPEN);
                while (firstOfStatement.Contains(CurrentToken))
                {
                    n1.Add(Statement());
                }
                Expect(TokenCategory.BRACE_CLOSE);
            }
            return(n1);
        }
コード例 #4
0
        // ---------------- ALL MAKE SENSE   ----------------
        public Node StatementIf()
        {
            var n1 = new If()
            {
                AnchorToken = Expect(TokenCategory.IF)
            };

            Expect(TokenCategory.PARENTHESIS_OPEN);
            n1.Add(Expression());//Esta es la condición
            Expect(TokenCategory.PARENTHESIS_CLOSE);
            Expect(TokenCategory.BRACE_OPEN);
            var list = new ListStatements();

            while (firstOfStatement.Contains(CurrentToken))
            {
                list.Add(Statement());
            }
            n1.Add(list);         // Statements IF
            Expect(TokenCategory.BRACE_CLOSE);
            n1.Add(ElseIfList()); // Elseif list
            n1.Add(Else());       // Else
            return(n1);
        }