From: David Kerkeslager Date: Sat, 30 Dec 2017 09:04:48 +0000 (-0500) Subject: Added two more compiler passes X-Git-Url: https://code.kerkeslager.com/?a=commitdiff_plain;h=cccc042f21a9c90cbd78cbad28288160a5899a33;p=fur Added two more compiler passes --- 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')