-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
31 lines (28 loc) · 973 Bytes
/
Copy pathProgram.cs
File metadata and controls
31 lines (28 loc) · 973 Bytes
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
using System;
using System.IO;
namespace JackCompiling
{
internal static class Program
{
public static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("Usage:\n" +
" JackCompiler <file>.jack" +
" JackCompiler <directory>");
Console.WriteLine("Translates <file>.jack to <file>.vm");
Console.WriteLine(" or every *.jack file in <directory> to *.vm");
Environment.Exit(1);
return;
}
var directoryMode = Directory.Exists(args[0]);
var jackFiles = directoryMode ? Directory.GetFiles(args[0], "*.jack") : new[] { args[0] };
foreach (var jackFile in jackFiles)
{
var compiler = new JackCompiler();
compiler.Compile(jackFile);
}
}
}
}