view src/plparser/TestScanner.java @ 8:8d0f9c1816f5

StreamTokenizer and Scanner version
author one
date Wed, 01 Sep 2010 18:43:06 +0900
parents 619472ca4742
children 29e309b2f624
line wrap: on
line source

package plparser;


import java.io.FileNotFoundException;
import java.io.FileReader;

public class TestScanner {
	
	public static PLScanner<Property> scan;

	public static void main(String arg[]) {
		initScanner();
		if (arg.length==0) {
			arg = new String[1];
			arg[0] = "data/alias_article.plist";
		}
		for(String file: arg) {
			try {
				scan(new FileReader(file));
			} catch (FileNotFoundException e) {
				scan(file);
			}
		}
	}
	
	public static void initScanner() {
		Dictionary<Property> dict = new Dictionary<Property>();
		 // scan = new PropertyListScanner<Property>(dict);
		// scan = new PropertyListStreamTokenizer<Property>(dict);
		scan = new PropertyListStreamScanner<Property>(dict);
	}


	public static void scan(String exp) {
		for(Token<Property> t : scan.scanToken(exp)) {
			System.out.print(t+" ");
		}
		System.out.println();
	}
	
	public static void scan(FileReader file) {
		for(Token<Property> t : scan.scanToken(file)) {
			System.out.print(t+" ");
			System.out.println();
		}
	}
	

}