Exemple #1
0
        public ast.Program ParseProgram()
        {
            ast.Program program = new ast.Program {
            };
            program.Statements = new List <ast.Statement>();

            while (!curTokenIs(token.EOF))
            {
                ast.Statement stmt = parseStatement();
                if (stmt != null)
                {
                    program.Statements.Add(stmt);
                }
                nextToken();
            }

            return(program);
        }
Exemple #2
0
        static ast.BlockStatement parseBlockStatement()
        {
            ast.BlockStatement block = new ast.BlockStatement {
                Token = curToken
            };
            block.Statements = new List <ast.Statement>();

            nextToken();

            while (!curTokenIs(token.RBRACE) && !curTokenIs(token.EOF))
            {
                ast.Statement stmt = parseStatement();
                if (stmt != null)
                {
                    block.Statements.Add(stmt);
                }
                nextToken();
            }

            return(block);
        }