forked from efrederickson/SharpLua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
48 lines (47 loc) · 1.45 KB
/
Copy pathProgram.cs
File metadata and controls
48 lines (47 loc) · 1.45 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Created by SharpDevelop.
* User: elijah
* Date: 12/26/2011
* Time: 12:25 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.IO;
using SharpLua.AST;
namespace SharpLua.Luac
{
class Program
{
public static int Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("Usage: luac <file> [outfile]");
Console.WriteLine(" <file> is the input file name");
Console.WriteLine(" [outfile] is an optional output file name");
return 1;
}
Parser.Parser p = new SharpLua.Parser.Parser();
bool success;
Chunk c = p.ParseChunk(new Parser.TextInput(File.ReadAllText(args[0])), out success);
if (success)
{
string _out = "";
if (args.Length > 1)
_out = args[1];
else
_out = Path.GetDirectoryName(args[0]) + "\\" + Path.GetFileNameWithoutExtension(args[0]) + ".sluac";
SharpLua.Serializer.Serialize(c, _out);
return 0;
}
else
{
Console.WriteLine("Parsing error(s)!");
foreach (Tuple<int, string> t in p.Errors)
Console.WriteLine("Line " + t.Item1 + ": " + t.Item2);
}
return 1;
}
}
}