01: package ro.infoiasi.donald.compiler.parser;
02:
03: import java.io.*;
04:
05: public class Main {
06:
07: public static void main(String args[]) throws Exception {
08: if (args.length == 3) {
09: String fileName = args[0];
10: String parserName = args[1];
11: String tokenName = args[2];
12:
13: ParserSpec spec = ParserSpec.load(fileName);
14: CodeWriter cw = new CodeWriter(spec,
15: CodeWriter.LALR1_PARSER, parserName, tokenName);
16:
17: PrintWriter out = new PrintWriter(new BufferedWriter(
18: new FileWriter(parserName + ".java")));
19: cw.generateParser(out);
20: out.flush();
21: out.close();
22:
23: out = new PrintWriter(new BufferedWriter(new FileWriter(
24: tokenName + ".java")));
25: cw.generateSymbolClass(out);
26: out.flush();
27: out.close();
28:
29: } else {
30: System.err
31: .println("java parser.Main <file> <parser_name> <token_name>");
32: }
33: }
34: }
|