private void TokenProcess() { TokenAnalyzer tA = new TokenAnalyzer(); tA.ProcessSourceFile(); this.dataTable = tA.GetDataTable(); this.docCounts = tA.GetDocCounts(); }
public static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Must have at least two parameters: SteamKit root path and output path!"); return; } string steamKitPath = Path.GetFullPath(args[0]); string languagePath = Path.Combine(steamKitPath, "Resources", "SteamLanguage"); string outputPath = Path.GetFullPath(args[1]); Environment.CurrentDirectory = languagePath; var codeGen = new GoGen(); Queue <Token> tokenList = LanguageParser.TokenizeString(File.ReadAllText("steammsg.steamd")); Node root = TokenAnalyzer.Analyze(tokenList); Node rootEnumNode = new Node(); Node rootMessageNode = new Node(); rootEnumNode.childNodes.AddRange(root.childNodes.Where(n => n is EnumNode)); rootMessageNode.childNodes.AddRange(root.childNodes.Where(n => n is ClassNode)); StringBuilder enumBuilder = new StringBuilder(); StringBuilder messageBuilder = new StringBuilder(); codeGen.EmitEnums(rootEnumNode, enumBuilder); codeGen.EmitClasses(rootMessageNode, messageBuilder); string outputEnumFile = Path.Combine(outputPath, "enums.go"); string outputMessageFile = Path.Combine(outputPath, "messages.go"); Directory.CreateDirectory(Path.GetDirectoryName(outputEnumFile)); File.WriteAllText(Path.Combine(steamKitPath, outputEnumFile), enumBuilder.ToString()); File.WriteAllText(Path.Combine(steamKitPath, outputMessageFile), messageBuilder.ToString()); }
/// <summary> /// Creates the list of all elements. /// </summary> /// <param name="projectPath">The project path.</param> /// <param name="externalLinksFileInfo">The external links file info.</param> /// <returns></returns> public static SortedDictionary <string, HelpEntity> CreateListOfAllElements(string projectPath, FileInfo externalLinksFileInfo) { SortedDictionary <string, HelpEntity> allElements = new SortedDictionary <string, HelpEntity>(); SortedDictionary <Guid, string> topicsNames = new SortedDictionary <Guid, string>(); ExternalLinkAnalyzer.GetAllExternalLinks(allElements, externalLinksFileInfo); ProjectAnalyzer pa = new ProjectAnalyzer(projectPath); if (pa.M_Project == null) { MessageBox.Show("Deserialization of the project failed !", "Deserialization failed!", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } try { topicsNames = ProjectContentAnalyzer.GetTopicsNames(pa.ProjectContentFile); } catch (Exception contentException) { MessageBox.Show("Exception appears in content analyzer: " + contentException + " Check if: \n - all topics are correctly added to the project \n - GUIDS are unique \n - check if the content file has correct structure", "Analyze failed!", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } try { ImageAnalyzer.GetAllImages(allElements, pa.AllImages); } catch (Exception imageException) { MessageBox.Show("Exception appears in Image analyzer: " + imageException + " Check if: \n - all images are correctly added to the project \n - the build action is set to Image \n - GUIDS are unique", "Analyze failed!", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } try { TokenAnalyzer.GetAllTokens(allElements, pa.TokensFile); } catch (Exception tokenException) { MessageBox.Show("Exception appears in Token analyzer: " + tokenException + " Check if: \n - all tokens are correctly added to the project \n - tokens names are unique \n - token is added \"as token\"", "Analyze failed!", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } try { LibraryAnalyzer.GetAllLibraryLinks(allElements, pa.AllLibraryFiles); } catch (Exception libraryException) { MessageBox.Show("Exception appears in Library analyzer: " + libraryException + " Check if: \n - all libraries are correctly added to the project \n - library is added \"as library\"", "Analyze failed!", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } try { TopicsAnalyzer.GetAllTopics(allElements, pa.AllMamlFiles, topicsNames); } catch (Exception topicsException) { MessageBox.Show("Exception appears in Topics analyzer: " + topicsException + " Check if: \n - all topics are correctly added to the project \n - topic is added \"as topic\"", "Analyze failed!", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } return(allElements); }
private void GetFileContent() { string filePath = "./sourcefile/" + fileIndex.ToString() + ".txt"; fileContent = TokenAnalyzer.ReadTextFromFile(filePath); }