1 18 19 package org.objectweb.jac.core.parsers.acc; 20 21 import java.io.FileReader ; 22 import java.io.InputStream ; 23 import java.io.InputStreamReader ; 24 import java.util.HashSet ; 25 import java.util.List ; 26 import java.util.Set ; 27 import java.util.Vector ; 28 import java_cup.runtime.Symbol; 29 import org.apache.log4j.Logger; 30 import org.objectweb.jac.core.InputStreamParser; 31 32 public class AccParserWrapper implements InputStreamParser 33 { 34 static Logger logger = Logger.getLogger("acc.parser"); 35 36 public AccParserWrapper() { 37 } 38 39 public List parse(InputStream inputStream, String streamName, 40 String targetClass, Set blockKeywords) 41 { 42 AccScanner lexer = new AccScanner(new InputStreamReader (inputStream), 43 streamName, blockKeywords); 44 AccParser parser = new AccParser(lexer); 45 logger.debug("Parsing "+streamName+" ..."); 47 Vector methods = null; 48 try { 49 methods = (Vector )parser.parse().value; 50 } catch (Exception e) { 52 lexer.printState(); 53 logger.error("Parser error in "+streamName,e); 54 } 55 logger.debug(streamName+" parsed"); 56 return methods; 57 } 58 64 68 public static void main(String [] args) 69 { 70 AccScanner scanner = null; 71 try { 72 scanner = new AccScanner(new FileReader (args[0]),args[0], 73 new HashSet ()); 74 AccParser myParser = new AccParser(scanner); 75 Vector methods = (Vector )myParser.parse().value; 76 System.out.println("Methods = "+methods); 77 } catch (Exception e) { 78 if (scanner!=null) 79 System.err.println(args[0]+":"+scanner.getLine()); 80 e.printStackTrace(); 81 } 82 } 83 } 84 | Popular Tags |