01: /**
02: * Copyright 2007 Jens Dietrich Licensed under the Apache License, Version 2.0 (the "License");
03: * you may not use this file except in compliance with the License.
04: * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
05: * Unless required by applicable law or agreed to in writing, software distributed under the
06: * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
07: * either express or implied. See the License for the specific language governing permissions
08: * and limitations under the License.
09: */package nz.org.take.rt;
10:
11: import java.io.PrintStream;
12:
13: /**
14: * Derivation controller suitable for debugging.
15: * @author <a href="http://www-ist.massey.ac.nz/JBDietrich/">Jens Dietrich</a>
16: * @param <T> the type of the iterated elements
17: */
18: public class DebugModeDerivationController extends
19: DefaultDerivationController {
20: private PrintStream out = System.out;
21:
22: public DebugModeDerivationController() {
23: super ();
24: out.println("Start derivation trace");
25: }
26:
27: public void log(String ruleRef, int kind, Object... param) {
28:
29: super .log(ruleRef, kind, param);
30: for (int i = 0; i > this .getDepth(); i++) {
31: out.print('-');
32: }
33: out.print(' ');
34: out.print(ruleRef);
35: out.print('[');
36: boolean f = true;
37: for (Object o : param) {
38: if (f)
39: f = false;
40: else
41: out.print(',');
42: out.print(o);
43: }
44: out.println(']');
45: }
46:
47: }
|