Exemple #1
0
    def compile_class_subroutines(self, jack_class):
        '''Compile the class subroutines'''
        
        token = self.tokenizer.current_token()
        while token is not None and token.type == 'keyword'\
                and token.value in ['constructor', 'function', 'method']:
            
            
            subroutine_type = self.tokenizer.advance().value
            #retorna tipo
            return_type = self.tokenizer.advance().value
            # nombre
            name = self.tokenizer.advance().value

            jack_subroutine = SymbolTable.JackSubroutine(
                    name, subroutine_type, return_type, jack_class
                )

            self.tokenizer.advance() # ( - open parameterList

            self.compile_parameter_list(jack_subroutine)

            self.tokenizer.advance() # ) - close parameterList

            self.compile_subroutine_body(jack_subroutine)

       
            token = self.tokenizer.current_token()