From cccc042f21a9c90cbd78cbad28288160a5899a33 Mon Sep 17 00:00:00 2001 From: David Kerkeslager Date: Sat, 30 Dec 2017 04:04:48 -0500 Subject: [PATCH] Added two more compiler passes --- conversion.py | 13 +++++++++++++ desugaring.py | 13 +++++++++++++ main.py | 8 ++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 conversion.py create mode 100644 desugaring.py diff --git a/conversion.py b/conversion.py new file mode 100644 index 0000000..8c47a4d --- /dev/null +++ b/conversion.py @@ -0,0 +1,13 @@ +import collections + +CPSProgram = collections.namedtuple( + 'CPSProgram', + ( + 'statement_list', + ), +) + +def convert(program): + return CPSProgram( + statement_list=program.statement_list, + ) diff --git a/desugaring.py b/desugaring.py new file mode 100644 index 0000000..ef51639 --- /dev/null +++ b/desugaring.py @@ -0,0 +1,13 @@ +import collections + +DesugaredProgram = collections.namedtuple( + 'DesugaredProgram', + ( + 'statement_list', + ), +) + +def desugar(program): + return DesugaredProgram( + statement_list=program.statement_list, + ) diff --git a/main.py b/main.py index be48e78..c649a0b 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,7 @@ import sys +import conversion +import desugaring import generation import normalization import parsing @@ -13,8 +15,10 @@ with open(source_path, 'r') as f: tokens = tokenization.tokenize(source) parsed = parsing.parse(tokens) -normalized = normalization.normalize(parsed) -transformed = transformation.transform(normalized) +desugared = desugaring.desugar(parsed) +normalized = normalization.normalize(desugared) +converted = conversion.convert(normalized) +transformed = transformation.transform(converted) generated = generation.generate(transformed) assert source_path.endswith('.fur') -- 2.20.1