Skip to content

Commit

Permalink
Modify compiler to filter out error patterns and add reserved words
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisthedev committed Jul 28, 2022
1 parent 06d06a7 commit 44b30ed
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,5 @@ dmypy.json

# Local Folder to Store Possible Bugs
possible_bugs/
patterns.txt

24 changes: 7 additions & 17 deletions src/compilers/typescript.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ class TypeScriptCompiler(BaseCompiler):

CRASH_REGEX = re.compile(r'(.+)(\n(\s+at .+))+')

def __init__(self, input_name):
super().__init__(input_name)
self.crash_msg = None
def __init__(self, input_name, filter_patterns=None):
super().__init__(input_name, filter_patterns)

@classmethod
def get_compiler_version(cls):
Expand All @@ -23,17 +22,8 @@ def get_compiler_cmd(self):
return ['tsc --target es2020 --pretty false', os.path.join(
self.input_name, '**', '*.ts')]

def analyze_compiler_output(self, output):
self.crashed = None
failed = defaultdict(list)
matches = re.findall(self.ERROR_REGEX, output)
for match in matches:
filename = match[0]
error_msg = match[2]
failed[filename].append(error_msg)

crash_match = re.search(self.CRASH_REGEX, output)
if crash_match and not matches:
self.crash_msg = output
return None
return failed
def get_filename(self, match):
return match[0]

def get_error_msg(self, match):
return f"{match[1]}{match[2]}"
4 changes: 3 additions & 1 deletion src/resources/typescript_keywords
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ undefined
delete
Delete
debugger
arguments
arguments
let
export
4 changes: 3 additions & 1 deletion src/translators/typescript.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def get_incorrect_filename():

def type_arg2str(self, t_arg):
# TypeScript does not have a Wildcard type
return self.get_type_name(t_arg)
if not t_arg.is_wildcard():
return self.get_type_name(t_arg)
return "unknown"

def get_type_name(self, t):
t_constructor = getattr(t, 't_constructor', None)
Expand Down

0 comments on commit 44b30ed

Please sign in to comment.