-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCompiler.cs
34 lines (28 loc) · 831 Bytes
/
Compiler.cs
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
29
30
31
32
33
34
using System;
namespace StructuralPatterns.Facade;
// Facade
public class Compiler
{
public void Compile(string sourceCodePath, string targetPath)
{
Console.WriteLine($"Compiler: Starting to compile source code from {sourceCodePath}");
// Subsystem 1
var lexer = new Lexer(sourceCodePath);
// Subsystem 2
var parser = new Parser(lexer);
var program = parser.Parse();
// Subsystem 3
var checker = new Checker(program);
var isSemanticallyCorrect = checker.Check();
// Subsystem 4
if (isSemanticallyCorrect)
{
var generator = new Generator(program);
generator.Generate(targetPath);
}
else
{
Console.WriteLine("Source code has errors");
}
}
}