public void TestSyntax() { var myParser = new TypeLuaParser(); myParser.Setup(); var filesDir = Path.Combine(Directory.GetCurrentDirectory(), "TestFiles"); var fields = Directory.GetFiles(filesDir); foreach (var field in fields) { var combine = Path.Combine(field); var readAllText = File.ReadAllText(combine); string state = ""; try { if (myParser.Parse(new StringReader(readAllText))) { state = "pass:"******"error:" + Path.GetFileNameWithoutExtension(field); } } catch (Exception e) { state = e.Message + ":" + Path.GetFileNameWithoutExtension(field); } Console.WriteLine(state); } }
public static Project Build(string projectRoot, params string[] classPaths) { var myParser = new TypeLuaParser(); myParser.Setup(); var project = new Project(projectRoot); projectRoot = projectRoot + "\\"; Types.Class tlClass = null; List <Types.Class> classes = new List <Types.Class>(); try { foreach (var classPath in classPaths) { var path = classPath.Replace(projectRoot, ""); path = path.Replace("\\", "/"); var extension = Path.GetExtension(path); if (extension == ".tl") { tlClass = new Types.Class(project, path.Substring(0, path.Length - 3)); var readAllText = File.ReadAllText(classPath); myParser.Parse(new StringReader(readAllText), project, tlClass); classes.Add(tlClass); } else if (extension == ".lua") { var luafile = new Luafile(project, path.Substring(0, path.Length - 4)); project.luafiles[luafile.FullName] = luafile; } } var classParser = new ClassParser(); for (int i = 0; i < classes.Count; i++) { tlClass = classes[i]; tlClass.Packages.PackageList.BuildPackageContext(tlClass.Packages); } for (int i = 0; i < classes.Count; i++) { tlClass = classes[i]; classParser.BuildGlobalContext(tlClass); } for (int i = 0; i < classes.Count; i++) { tlClass = classes[i]; classParser.ClarifyType(tlClass); } for (int i = 0; i < classes.Count; i++) { tlClass = classes[i]; classParser.TypeVerify(tlClass); } } catch (FileParseException e) { e.FileName = tlClass.ClassPath; Console.WriteLine(e.StackTrace); throw e; } return(project); }