summaryrefslogtreecommitdiffstats
path: root/code/FORTRAN2C/fortran2c/Compiler.java
blob: 7b124fa5b4028db7bc3036893dd918e50eff9ea6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package fortran2c;
import fortran2c.parser.*;
import fortran2c.lexer.*;
import fortran2c.node.*;
import java.io.*;

public class Compiler
{
    public static void main(String[] args)
    {
        try
        {
            System.out.println("Using source file: " + args[0]);
            // Create a Parser instance.
            Parser p = new Parser(new Lexer(new PushbackReader(new InputStreamReader(new FileInputStream(args[0])), 1024)));
            // Parse the input.
            Start tree = p.parse();
            // Apply the translation.
            CWriter cWriter = new CWriter("build/out.c");

            tree.apply(new Translation(cWriter));
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}