msv.tahiti.src.com.sun.tahiti.compiler.Driver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jaxb1-impl Show documentation
Show all versions of jaxb1-impl Show documentation
JAXB (JSR 222) Reference Implementation - JAXB1 build
/*
* @(#)$Id: Driver.java 1087 2001-08-18 01:37:50Z Bear $
*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the proprietary information of Sun Microsystems, Inc.
* Use is subject to license terms.
*
*/
package com.sun.tahiti.compiler;
import java.io.File;
import java.io.OutputStream;
import java.io.IOException;
import java.io.FileOutputStream;
import java.util.Map;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import com.sun.tahiti.compiler.Controller;
import com.sun.tahiti.compiler.ControllerImpl;
import com.sun.tahiti.compiler.generator.ModelGenerator;
import com.sun.tahiti.compiler.ll.Rules;
import com.sun.tahiti.compiler.ll.RuleSerializer;
import com.sun.tahiti.compiler.ll.RuleGenerator;
import com.sun.tahiti.compiler.sm.MarshallerSerializer;
import com.sun.tahiti.compiler.Symbolizer;
import com.sun.tahiti.grammar.TypeItem;
import com.sun.tahiti.grammar.AnnotatedGrammar;
import com.sun.tahiti.reader.GrammarLoader;
import com.sun.tahiti.util.xml.XSLTUtil;
import com.sun.msv.reader.GrammarReaderController;
import org.apache.xml.serialize.XMLSerializer;
import org.apache.xml.serialize.OutputFormat;
import org.xml.sax.XMLReader;
import org.xml.sax.DocumentHandler;
/**
* Command-line compiler.
*
* @author
* Kohsuke KAWAGUCHI
*/
public class Driver
{
private static class OutputMethod {}
private static final OutputMethod java = new OutputMethod();
private static final OutputMethod xml = new OutputMethod();
private static void usage() {
System.err.println(
"Usage: tahiti \n"+
"[OUTPUT OPTIONS]\n"+
" -out xml compiler will produce xml files.\n"+
" -out java compiler will produce java source files.\n"+
" -d specify output directory.\n"+
"[GENERIC OPTIONS]\n"+
" -package \n"+
" place java files into the specified package.\n"+
"" );
}
public static void main( String args[] ) throws Exception {
System.exit(run(args));
}
public static int run( String args[] ) throws Exception {
// TODO: where should we obtain the package name
// and the file name of the generated grammar?
OutputMethod out = java;
String grammarFileName=null;
File outDir = new File(".");
for( int i=0; i
* This method creates directories if necessary.
*
* @param javaPath
* it will be something like "abc.def.ghi"
*/
private static File getJavaFile( File parent, String javaPath ) {
File r = new File( parent, javaPath.replace('.','/')+".java" );
new File(r.getParent()).mkdirs();
return r;
}
}