Skip to content
Snippets Groups Projects
Commit 54ff7e2b authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Cleaned up main program and made it possible to control naming an d placement...

Cleaned up main program and made it possible to control naming an d placement of generated code. Created a README
parent 2f3a8898
No related branches found
No related tags found
No related merge requests found
......@@ -12,37 +12,56 @@ import java.io.PrintStream;
public class GenCompiler extends Parser {
public static void main(String args[]) {
Start ast = parse(args);
File siarasDir = new File("x3d");
String dir = "x3d";
String outName = "x3d";
String[] schema = new String[1];
boolean first = true;
for (int i=0; i<args.length; i++) {
if (args[i].equals("-d")) {
dir = args[++i];
} else if (args[i].equals("-o")) {
outName = args[++i];
} else {
// OK, we suppose the remaing arg to be parsed.
schema[0] = args[i++];
}
}
Start ast = parse(schema);
File siarasDir = new File(dir);
if (!siarasDir.isDirectory()) {
siarasDir.mkdir();
}
String fileName = null;
String common = dir+File.separator+outName;
try {
// Generate JastAdd abstract grammar
fileName = "x3d/x3d.ast";
fileName = common+".ast";
PrintStream pStream = new PrintStream(new File(fileName));
ast.genAbsGrammar(pStream);
// Generate JavaCC input
fileName = "x3d/x3d.jjt";
fileName = common+".jjt";
pStream = new PrintStream(new File(fileName));
ast.genJavaCC(pStream);
// Generate Parser.java
fileName = "x3d/Parser.java";
fileName = dir+"/Parser.java";
pStream = new PrintStream(new File(fileName));
ast.genParser(pStream);
// Generate PrettyPrint.java
fileName = "x3d/PrettyPrint.java";
fileName = dir+"/PrettyPrint.java";
pStream = new PrintStream(new File(fileName));
ast.genPrettyPrint(pStream);
// Generate aspects
fileName = "x3d/GeneratedAspects.jrag";
fileName = dir+"/GeneratedAspects.jrag";
pStream = new PrintStream(new File(fileName));
ast.genAspects(pStream);
......
README 0 → 100644
ABOUT
The main purpose of the Schemacompiler is to automatically generate
compiler front-ends for different XML dialects. Given an XML schema,
the schemacompiler will generate an abstract grammar and some aspect
code for JastAdd, as well as a JavaCC parser description. The
generated compiler may then be extended with more aspects, and
possibly new abstract grammar rules, to form a complete compiler.
USAGE
$ java GenCompiler [-d dir] [-o outfile] schema
options:
-d dir directory where generated files are put.
Will be created if not already exists.
Default is 'x3d'.
-o outfile Name for generated grammar files.
Default is 'x3d'.
'$ java GenCompiler examples/x3d-3.0.xsd' will generate a compiler for
x3d in the x3d subdirectory. x3d/build.xml should be studied as an
example on how to use the generated code.
AUTHOR
Anders Nilsson <anders.nilsson@cs.lth.se>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment