<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def category(self) -> Optional[str]:
        '''Determine the category of existing statement'''
        if self.statements:
            if self.statements[-1][0] == ':':
                # a hack. ... to avoid calling isValid recursively
                def validDirective():
                    if not self.values:
                        return True
                    if self.values[-1].strip().endswith(','):
                        return False
                    try:
                        compile(
                            'func(' + ''.join(self.values) + ')',
                            filename='<string>',
                            mode='eval')
                    except Exception:
                        return False
                    return True

                if validDirective() and self._action is not None:
                    return 'script'
                return 'directive'
            return 'statements'
        return None