% $Id: ReducerPrinting.oz,v 1.4 2012/01/11 22:24:24 leavens Exp $ \insert 'Reducer.oz' declare %% Constants SpacingBeforeConfig = ' ' Arrow = '-->' %% Testing helpers proc {PrintConfig C} %% ENSURES: C has been printed using System.showInfo {System.showInfo SpacingBeforeConfig # {StringForConfig C}} end fun {By RN} %% ENSURES: Result is a virtual string showing the rule RN ' {by [' # RN # ']}' end proc {TestRed Config1 RuleExpected ConfigExpected} %% ENSURES: Config1 has been printed, followed by information about %% what Reduce1 does to it, %% and printing error output if it doesn't match %% the expected rule and configuration {System.showInfo ' '} {PrintConfig Config1} local RuleName#Res = {Reduce1 Config1} in {System.showInfo Arrow # {By RuleName }} {PrintConfig Res} % {System.showInfo 'testing against expected ...'} if RuleName \= RuleExpected orelse {Not {EqualConfig Res ConfigExpected}} then {System.showInfo 'EXPECTED ' # Arrow # {By RuleExpected} } {PrintConfig ConfigExpected} else skip % {System.showInfo 'ok'} end end end proc {ShowReductionsForMaker ReductionsForMaker Title StmtAST} %% ENSURES: the title and then all the reductions for StmtAST are shown _#InitConfig|Reductions = {ReductionsForMaker StmtAST} in {System.showInfo ' '} {System.showInfo Title} {PrintConfig InitConfig} for RuleName#Config in Reductions do {System.showInfo Arrow # {By RuleName}} {PrintConfig Config} end end proc {ShowReductionsFor Title StmtAST} %% ENSURES: the title and then all the reductions for StmtAST are shown {ShowReductionsForMaker ReductionsFor Title StmtAST} end proc {ShowStdReductionsFor Title StmtAST} %% ENSURES: the title and then all the reductions for StmtAST are shown {ShowReductionsForMaker MakeStdReductions Title StmtAST} end