using System;


namespace Liss {

class Liss {
	public static void Main (string[] arg) 
	{
		string[] dir;
		string dirPath = "", filePath = "";
		bool caduceus = false;
		
		if (arg.Length > 0) {
			dir = arg[0].Split('/');
			filePath = dir[dir.Length - 1];
			if (arg.Length > 1)
			{
				if (arg[1] == "-caduceus")
					caduceus = true;
				else
				{
					if (arg.Length == 3 && arg[2] == "-caduceus")
						caduceus = true;
					dirPath = arg[1];
					if (!dirPath.EndsWith("/"))
						dirPath += "/";
				}
			}
			else 
				for(int i=0; i<dir.Length - 1; i++)
					dirPath += dir[i] + "/";
			
			Scanner scanner = new Scanner(arg[0]);
			Parser parser = new Parser(scanner);
			parser.SymTab = new SymbolTable(parser, caduceus);
			parser.Resolver = new Resolver(scanner);
			parser.genCode = new VM_Code();
			parser.Parse();

			if (parser.errors.count == 0) 
			{
				Console.WriteLine(parser.output);
				parser.SymTab.Interpret(parser.output, dirPath + filePath.Replace(".liss", ".c"));
			}
		} else
			Console.WriteLine("-- No source file specified");
	}


}

} // end namespace
