diff src/plparser/PropertyListParser.java @ 4:29c0866e3a84

text
author one
date Sun, 29 Aug 2010 18:28:38 +0900
parents 1f46c9d09c1e
children 29b5497fc942
line wrap: on
line diff
--- a/src/plparser/PropertyListParser.java	Sun Aug 29 12:47:11 2010 +0900
+++ b/src/plparser/PropertyListParser.java	Sun Aug 29 18:28:38 2010 +0900
@@ -10,8 +10,9 @@
 	Token<Node> nextToken;
 	public PropertyListScanner<Node> scanner;
 	private Dictionary<Node> dict;
+	// scope is necessary if you have to parse nested name scope
 //	private PropertyListScope<Node> scope;
-	
+
 	public PropertyListParser(String string,
 			PropertyListNodeFactory<Node> lf) {
 		this.lf = lf;
@@ -19,6 +20,11 @@
 		scanner.set(string);
 	}
 	
+	public PropertyListParser(PropertyListNodeFactory<Node> lf) {
+		this.lf = lf;
+		initialize();
+	}
+	
 
 	public void initReservedWord() {
 		dict.reserve("=",TokenID.Assign);
@@ -40,7 +46,8 @@
 	}
 
 	public Node parse() {
-		if (scanner==null) return null;
+		if (scanner==null) return null; // internal error
+		if (scanner.cb==null) return null; // nothing to do
 		nextToken();
 		return term();
 	}
@@ -55,24 +62,24 @@
 		
 	}
 
-	public void parseFile(String file) {
+	public Node parseFile(String file) {
 		try {
 			scanner = scanner.pushScannerFile(file);
 		} catch (FileNotFoundException e) {
 			error("Can't open "+file);
-			return;
+			return null;
 		}
-		doParse();
+		return doParse();
 	}
 	
-	public void parse(InputStream file) {
+	public Node parse(InputStream file) {
 		scanner = scanner.pushScannerFile(file,null);
-		doParse();
+		return doParse();
 	}
 
-	public void parse(InputStream in, String prompt) {
+	public Node parse(InputStream in, String prompt) {
 		scanner = scanner.pushScannerFile(in,prompt);
-		doParse();
+		return doParse();
 	}
 	
 	public Node doParse() {