# HG changeset patch # User one # Date 1283139323 -32400 # Node ID 563bcb96e4faa130ea9c5c8dd164280ecec35729 # Parent 29b5497fc942173bb8d99285d0363113f25d0a32 pretty printer diff -r 29b5497fc942 -r 563bcb96e4fa src/plparser/ArrayProperty.java --- a/src/plparser/ArrayProperty.java Sun Aug 29 20:28:00 2010 +0900 +++ b/src/plparser/ArrayProperty.java Mon Aug 30 12:35:23 2010 +0900 @@ -1,5 +1,6 @@ package plparser; +import java.io.PrintStream; import java.util.LinkedList; public class ArrayProperty extends Property { @@ -19,5 +20,19 @@ s += ")"; return s; } + + public void pp(PrintStream out, int indent, int flag) { + indent(out, indent,flag); + out.print("Array("); + flag = 0; + for(int i = 0;i1) indent(out,indent,1); + out.print(")"); + } + } + } } diff -r 29b5497fc942 -r 563bcb96e4fa src/plparser/BooleanProperty.java --- a/src/plparser/BooleanProperty.java Sun Aug 29 20:28:00 2010 +0900 +++ b/src/plparser/BooleanProperty.java Mon Aug 30 12:35:23 2010 +0900 @@ -1,5 +1,7 @@ package plparser; +import java.io.PrintStream; + public class BooleanProperty extends Property { boolean b; @@ -8,8 +10,12 @@ } public String toString() { - return b?"True":"Fasel"; + return b?"True":"False"; } + public void pp(PrintStream out, int indent,int flag) { + indent(out, indent,flag); + out.print(toString()); + } } diff -r 29b5497fc942 -r 563bcb96e4fa src/plparser/DictProperty.java --- a/src/plparser/DictProperty.java Sun Aug 29 20:28:00 2010 +0900 +++ b/src/plparser/DictProperty.java Mon Aug 30 12:35:23 2010 +0900 @@ -1,7 +1,9 @@ package plparser; +import java.io.PrintStream; import java.util.HashMap; import java.util.LinkedList; +import java.util.Set; public class DictProperty extends Property { HashMap map; @@ -28,4 +30,21 @@ return s; } + public void pp(PrintStream out, int indent,int flag) { + indent(out, indent,flag); out.print("Dict{"); + int i = 0; int size = map.size(); + flag = 0; + for(Property p:map.keySet()) { + p.pp(out,indent+indent_step,flag);out.print("->"); + flag = 1; + map.get(p).pp(out,indent+indent_step+2,0); + if (i1) indent(out,indent,1); + out.print("}"); + } + i++; + } + } + } diff -r 29b5497fc942 -r 563bcb96e4fa src/plparser/NumberNode.java --- a/src/plparser/NumberNode.java Sun Aug 29 20:28:00 2010 +0900 +++ b/src/plparser/NumberNode.java Mon Aug 30 12:35:23 2010 +0900 @@ -1,14 +1,14 @@ package plparser; public class NumberNode extends Property { - int value; + double value; - public NumberNode(int i) { + public NumberNode(double i) { value = i; } public String toString() { return "Number "+value; } - + } diff -r 29b5497fc942 -r 563bcb96e4fa src/plparser/Property.java --- a/src/plparser/Property.java Sun Aug 29 20:28:00 2010 +0900 +++ b/src/plparser/Property.java Mon Aug 30 12:35:23 2010 +0900 @@ -1,7 +1,10 @@ package plparser; +import java.io.PrintStream; + public class Property { String name; + public static int indent_step = 4; public Property() { @@ -15,4 +18,15 @@ return name; } + public void indent(PrintStream out, int indent,int flag) { + if (flag==0) return; + for(int i=0;i