Mercurial > hg > Members > kono > PLparser
view src/plparser/TestScanner.java @ 7:619472ca4742
Refactoring for multiple implementation of scanner
author | one |
---|---|
date | Wed, 01 Sep 2010 15:23:37 +0900 |
parents | b149a5aa465a |
children | 8d0f9c1816f5 |
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); } 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(); } } }