forked from facebookresearch/CodeGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlang_processor.py
executable file
·41 lines (31 loc) · 1.18 KB
/
lang_processor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from abc import ABC
class LangProcessor(ABC):
processors = {}
def __init__(self, language):
self.language = language
@classmethod
def __init_subclass__(cls):
super().__init_subclass__()
assert (
len(cls.__name__.lower().split("processor")) == 2
and cls.__name__.lower().split("processor")[1] == ""
), "language processors class name should be that format : YourlanguageProcessor"
cls.processors[cls.__name__.lower().split("processor")[0]] = cls
def tokenize_code(self, code, keep_comments=False, process_strings=True):
raise NotImplementedError
def detokenize_code(self, code):
raise NotImplementedError
def obfuscate_code(self, code):
raise NotImplementedError
def extract_functions(self, code):
raise NotImplementedError
def get_function_name(self, function):
raise NotImplementedError
def extract_arguments(self, function):
raise NotImplementedError