/**
 * 
 */
package blog.parse;

import java.io.InputStream;

import blog.absyn.Absyn;
import blog.absyn.Printer;
import blog.msg.ErrorMsg;

/**
 * @author leili
 * @since Apr 18, 2012
 * 
 */
public class Parse {

	protected ErrorMsg errorMsg;
	protected Absyn absyn;
	protected InputStream inp;

	public Parse(java.io.Reader inp, ErrorMsg errorMsg) {
		this.errorMsg = errorMsg;
		BLOGParser parser;
		try {
			parser = new BLOGParser(new BLOGLexer(inp, errorMsg), errorMsg);
			/* open input files, etc. here */

			parser. /* debug_ */parse();
			// modified by leili, only for debug purpose
			// parser.debug_parse();
			absyn = parser.parseResult;
		} catch (Throwable e) {
			e.printStackTrace();
			throw new Error(e.toString());
		} finally {
			try {
				inp.close();
			} catch (java.io.IOException e) {
			}
		}
	}

	public static Parse parseFile(String filename) {
		blog.msg.ErrorMsg errorMsg = new blog.msg.ErrorMsg(filename);
		java.io.Reader inp;
		try {
			inp = new java.io.FileReader(filename);
		} catch (java.io.FileNotFoundException e) {
			throw new Error("File not found: " + filename);
		}
		return new Parse(inp, errorMsg);
	}

	public static Parse parseString(String content) {
		blog.msg.ErrorMsg errorMsg = new blog.msg.ErrorMsg("STRING"
		    + content.hashCode());
		java.io.Reader inp;
		try {
			inp = new java.io.StringReader(content);
		} catch (Throwable e) {
			throw new Error("String is null!");
		}
		return new Parse(inp, errorMsg);
	}

	public ErrorMsg getErrorMsg() {
		return errorMsg;
	}

	public Absyn getParseResult() {
		return absyn;
	}

	public static void main(String[] args) {
		Parse parse = parseFile(args[0]);
		parse.getParseResult().printTree(new Printer(System.out), 0);
	}
}

@@ -80,16 +80,52 @@
 .Absyn;%0A
+import blog.absyn.IndentingPrinter;%0A
 import b
@@ -1295,13 +1295,15 @@
 g(%22S
-TRING
+tring: 
 %22%0A%09%09
@@ -1732,17 +1732,28 @@
 rint
-Tree(new 
+Syntax(new Indenting
 Prin
@@ -1771,11 +1771,8 @@
 out)
-, 0
 );%0A%09

Change main() to use printSyntax instead of printTree