Compiler.cs 1.1 KB

123456789101112131415161718192021222324252627282930
  1. using System;
  2. namespace csharp_sccd_compiler
  3. {
  4. public class Compiler
  5. {
  6. public static void generate(string input_file, string output_file, CodeGenerator.Platform platform)
  7. {
  8. ClassDiagram class_diagram = createAST(input_file);
  9. generateFromAST(class_diagram, output_file, platform);
  10. }
  11. public static ClassDiagram createAST(string input_file)
  12. {
  13. ClassDiagram cd = new ClassDiagram(input_file); //create AST
  14. (new StateLinker()).visit(cd); //visitor fixing state references
  15. (new PathCalculator()).visit(cd); //visitor calculating paths
  16. return cd;
  17. }
  18. public static void generateFromAST(ClassDiagram class_diagram, string output_file, CodeGenerator.Platform platform)
  19. {
  20. if ((new CSharpGenerator()).generate(class_diagram, output_file, platform))
  21. Logger.displayInfo("The following classes <" + string.Join(", ", class_diagram.class_names) + "> have been exported to the following file: " + output_file);
  22. }
  23. }
  24. }