forked from CoolCows/cool-compiler-2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
114afa4
commit 669cab4
Showing
17 changed files
with
1,388 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,51 @@ | ||
def run_pipeline(): | ||
pass | ||
import os | ||
from parsing import parser | ||
from semantics import type_collector, type_builder, autotype_collector | ||
|
||
def format_errors(errors, s = ""): | ||
count = 1 | ||
for error in errors: | ||
s += str(count) + ". " + error + "\n" | ||
count += 1 | ||
return s | ||
|
||
def run_pipeline(program): | ||
ast = parser.parse(program) | ||
|
||
collector = type_collector.TypeCollector() | ||
collector.visit(ast) | ||
context = collector.context | ||
print('Context\n', context) | ||
|
||
builder = type_builder.TypeBuilder(context) | ||
builder.visit(ast) | ||
print('Context\n', context) | ||
|
||
auto_collector = autotype_collector.AutotypeCollector(context) | ||
auto_collector.visit(ast) | ||
|
||
s = "Type Collector Errors:\n" | ||
s = format_errors(collector.errors, s) | ||
s += "Type Builder Errors:\n" | ||
s = format_errors(builder.errors, s) | ||
s += "Inference Gatherer Errors:\n" | ||
s = format_errors(auto_collector.errors, s) | ||
|
||
print(s) | ||
|
||
folder_path = r'./zTests/Misc' | ||
filenames = os.listdir(folder_path) | ||
filenames.sort() | ||
|
||
for filename in filenames: | ||
path = os.path.join(folder_path, filename) | ||
file = open(path, "r") | ||
program = file.read() | ||
file.close() | ||
|
||
print(f"Running {filename}") | ||
run_pipeline(program) | ||
input() | ||
|
||
print("EndOfFiles") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.