diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-15 00:54:47 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-15 00:54:47 -0600 |
commit | 4907f4ed2f471f2ca23dd7ab30f602c1baed84c6 (patch) | |
tree | 850670fcb93cf9397285b632632da8662980bdfe /V2VM.java | |
parent | bd59acec960bf9e2ad93f0d1caa11a65613ee168 (diff) |
Add skeleton of CFG visitor
Diffstat (limited to 'V2VM.java')
-rw-r--r-- | V2VM.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/V2VM.java b/V2VM.java new file mode 100644 index 0000000..0f745f0 --- /dev/null +++ b/V2VM.java @@ -0,0 +1,51 @@ +import java.io.*; +import cs132.util.ProblemException; +import cs132.vapor.parser.VaporParser; +import cs132.vapor.ast.VaporProgram; +import cs132.vapor.ast.VBuiltIn.Op; + +import java.io.InputStreamReader; +import java.io.IOException; +import java.io.PrintStream; + +import st.*; +import misc.*; +import vaporize.library.*; + +public class V2VM { + + public static void main(String[] args) { + try { + VaporProgram pgrm = parseVapor(System.in, System.out); + System.out.println(pgrm); + + ControlFlowGraph vp = new ControlFlowGraph<Void, Void>(); + + } catch (IOException e) { + System.out.println(e.toString()); + System.exit(1); + } + } + + public static VaporProgram parseVapor(InputStream in, PrintStream err) throws IOException { + Op[] ops = { + Op.Add, Op.Sub, Op.MulS, Op.Eq, Op.Lt, Op.LtS, + Op.PrintIntS, Op.HeapAllocZ, Op.Error, + }; + boolean allowLocals = true; + String[] registers = null; + boolean allowStack = false; + + VaporProgram program; + try { + program = VaporParser.run(new InputStreamReader(in), 1, 1, + java.util.Arrays.asList(ops), + allowLocals, registers, allowStack); + } catch (ProblemException ex) { + err.println(ex.getMessage()); + return null; + } + + return program; + } +} |