1 20 package org.objectweb.modfact.qvt.syntaxe; 21 22 26 27 import java.io.*; 28 import java.util.logging.ConsoleHandler ; 29 import java.util.logging.Level ; 30 import java.util.logging.Logger ; 31 32 import javax.jmi.reflect.RefObject; 33 import javax.jmi.xmi.XmiWriter; 34 35 import org.objectweb.modfact.jmi.repository.simpletrl.SimpleTRLPackageImpl; 36 import org.objectweb.modfact.jmi.xmi.XmiWriterImpl; 37 import org.objectweb.modfact.qvt.util.RulePrinter; 38 39 import simpletrl.SimpleTRLPackage; 40 41 class TranslationService { 42 public static void main(String [] args) { 43 44 FileInputStream fileInput = null; 45 46 try { 47 fileInput = new FileInputStream(args[0]); 48 DataInputStream input = new DataInputStream(fileInput); 49 STRLLexer lexer = new STRLLexer(input); 50 STRLParser parser = new STRLParser(lexer); 51 52 SimpleTRLPackage p = 53 SimpleTRLPackageImpl.create( 54 ClassLoader 55 .getSystemResource("simpletrl/metamodel_SimpleTRL.xml") 56 .toString()); 57 58 59 Logger log = Logger.getLogger("org.objectweb.modfact.qvt.syntaxe.TranslationService"); 61 parser.setLogger(log); 62 63 ConsoleHandler chJmi = new ConsoleHandler (); 64 chJmi.setLevel(Level.INFO); 65 log.addHandler(chJmi); 66 67 parser.setRuleModel(p); 68 parser.file(); 69 70 74 75 XmiWriter w = new XmiWriterImpl(); 76 FileOutputStream out = new FileOutputStream(args[1]); 77 w.write(out, p, "1.2"); 78 out.close(); 79 80 out = new FileOutputStream(args[2]); 81 RulePrinter.printer.printRules( 82 (RefObject) p.getRulesUnit().refAllOfClass().toArray()[0], 83 new PrintWriter(out)); 84 out.close(); 85 86 } catch (Exception e) { 87 System.err.println("exception REDA: " + e); 88 e.printStackTrace(); 89 } 90 } 91 } 92 | Popular Tags |