From e6f0710e4154e0df35e89d4322ab2122a80e755e Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 11 May 2018 02:58:14 -0700 Subject: [PATCH] Debug ast rewrite --- schala-lang/src/ast_reducing.rs | 6 ++++++ schala-lang/src/lib.rs | 1 + schala-repl/src/language.rs | 1 + 3 files changed, 8 insertions(+) diff --git a/schala-lang/src/ast_reducing.rs b/schala-lang/src/ast_reducing.rs index c63f4e2..b32d69b 100644 --- a/schala-lang/src/ast_reducing.rs +++ b/schala-lang/src/ast_reducing.rs @@ -72,6 +72,12 @@ impl Expression { &BinExp(ref binop, ref lhs, ref rhs) => binop.reduce(lhs, rhs), &PrefixExp(ref op, ref arg) => op.reduce(arg), &Value(ref name) => Expr::Val(name.clone()), + /* + &Call { ref f, ref arguments } => Expr::Call { + f: Box, + arguments: Vec, + }, + */ e => Expr::UnimplementedSigilValue, } } diff --git a/schala-lang/src/lib.rs b/schala-lang/src/lib.rs index 689c648..763d8f6 100644 --- a/schala-lang/src/lib.rs +++ b/schala-lang/src/lib.rs @@ -96,6 +96,7 @@ fn typechecking(handle: &mut Schala, input: parsing::AST, comp: Option<&mut Unfi type TempASTReduction = (ast_reducing::ReducedAST, parsing::AST); fn ast_reducing(handle: &mut Schala, input: parsing::AST, comp: Option<&mut UnfinishedComputation>) -> Result { let output = input.reduce(); + comp.map(|comp| comp.add_artifact(TraceArtifact::new("ast_reducing", format!("{:?}", output)))); Ok((output, input)) } diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index 5f55ad5..84cd046 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -95,6 +95,7 @@ impl TraceArtifact { pub fn new(stage: &str, debug: String) -> TraceArtifact { let color = match stage { "parse_trace" | "ast" => "red", + "ast_reducing" => "red", "tokens" => "green", "type_check" => "magenta", _ => "blue",