private void ProcedureDocumentation(string val) { if (_currentKeyWord != KeyWordType.PROCEDURE) { string[] headers = { "Тип", "Название", "Аргументы", "Возвращаемое значение", "Видимость", "Описание" }; ExcelExporter.AppendLine(Color.GreenYellow, headers); _currentKeyWord = KeyWordType.PROCEDURE; } val = val.Replace(";", string.Empty); var docParams = new List <string>(); var strings = val.Split('('); if (strings.Length > 1) { var typeAndName = strings[0].Split(' '); docParams.Add(typeAndName[0]); docParams.Add(typeAndName[1]); var args = strings[1].Split(')'); docParams.Add(args[0]); if (args.Length > 1) { var res = args[1].Split(':'); if (res.Length > 1) { docParams.Add(res[1]); } else { docParams.Add("-"); } } } else { var res = strings[0].Split(':'); var typeAndName = res[0].Split(' '); docParams.Add(typeAndName[0]); docParams.Add(typeAndName[1]); docParams.Add("-"); if (res.Length > 1) { docParams.Add(res[1]); } else { docParams.Add("-"); } } docParams.Add(_currentAccessType.ToString().ToLower()); ExcelExporter.AppendLine(Color.White, docParams.ToArray()); }
private void FieldDocumentation(string val) { if (_currentKeyWord != KeyWordType.FIELD) { string[] headers = { "Название", "Тип", "Видимость", "Описание" }; ExcelExporter.AppendLine(Color.GreenYellow, headers); _currentKeyWord = KeyWordType.FIELD; } val = val.Replace(";", string.Empty); var docParams = new List <string>(); var res = val.Split(':'); docParams.Add(res[0]); docParams.Add(res[1]); docParams.Add(_currentAccessType.ToString().ToLower()); ExcelExporter.AppendLine(Color.White, docParams.ToArray()); }
public void Parse() { try { using (var stream = new StreamReader(_filePath)) { string line = string.Empty; while (!(line = stream.ReadLine()).Contains("implementation")) { if (ParseCodeLine(KeyWordType.CLASS, line, ClassDocumentation)) { continue; } if (ParseCodeLine(KeyWordType.FIELD, line, FieldDocumentation)) { continue; } if (ParseCodeLine(KeyWordType.PROCEDURE, line, ProcedureDocumentation)) { continue; } if (ParseCodeLine(KeyWordType.FUNCTION, line, ProcedureDocumentation)) { continue; } if (ParseCodeLine(KeyWordType.PUBLIC, line, (x) => { _currentAccessType = KeyWordType.PUBLIC; })) { continue; } if (ParseCodeLine(KeyWordType.PRIVATE, line, (x) => { _currentAccessType = KeyWordType.PRIVATE; })) { continue; } if (ParseCodeLine(KeyWordType.PROTECTED, line, (x) => { _currentAccessType = KeyWordType.PROTECTED; })) { continue; } } } } catch (Exception e) { throw e; } }
public SaleViewModel(IModernNavigationService modernNavigationService) { _modernNavigationService = modernNavigationService; selectedItem = new KeyWordType { ID = 0, Name = "商品名" }; comboItemsSource = new ObservableCollection <KeyWordType>() { selectedItem, new KeyWordType { ID = 1, Name = "货号" }, new KeyWordType { ID = 2, Name = "条形码" }, }; GridVisible = false; }
private bool ParseCodeLine(KeyWordType wordType, string line, Action <string> documentationAction) { var checker = new TextChecker(); var matches = checker.CheckText(wordType, line); if (matches.Count > 0) { foreach (Match val in matches) { documentationAction(val.Value); } return(true); } else { return(false); } }
public MatchCollection CheckText(KeyWordType wordType, string text) { var reg = string.Empty; text = text.Trim(); _keyWords.TryGetValue(wordType, out reg); if (reg != null) { var regex = new Regex(reg, RegexOptions.IgnoreCase); var matches = regex.Matches(text); return(matches); } else { return(null); } }
public LogViewModel(IModernNavigationService modernNavigationService) { _modernNavigationService = modernNavigationService; selectedItem = new KeyWordType { ID = 0, Name = "用户名" }; comboItemsSource = new ObservableCollection <KeyWordType>() { selectedItem, new KeyWordType { ID = 1, Name = "命令" }, new KeyWordType { ID = 2, Name = "时间" }, }; GridVisible = false; date = DateTime.Now; EditVisible = false; EditEnable = false; }
private void ClassDocumentation(string val) { if (_currentKeyWord != KeyWordType.CLASS) { string[] headers = { "Название", "Тип", "Базовый класс и интерфейсы", "Описание" }; ExcelExporter.AppendLine(Color.GreenYellow, headers); _currentKeyWord = KeyWordType.CLASS; _currentAccessType = KeyWordType.PRIVATE; } val = val.Replace(";", string.Empty); var docParams = new List <string>(); var typeAndName = val.Split('='); docParams.Add(typeAndName[0]); var parent = typeAndName[1].Split('('); docParams.Add(parent[0]); if (parent.Length > 1) { docParams.Add(parent[1].Replace(")", string.Empty)); } ExcelExporter.AppendLine(Color.White, docParams.ToArray()); }
private TokenKeyWord(KeyWordType t) { Type = t; }
private Lexem ParseKeyWord(string line, ref int i, int lineIndex) { if (line is null) { throw new ArgumentNullException(nameof(line)); } var endPosition = i; var isCorrect = true; while (line[endPosition] != ' ' && line[endPosition] != '\t' && line[endPosition] != '\n') { if (!(line[endPosition] >= 'a' && line[endPosition] <= 'z' || line[endPosition] == '_' || line[endPosition] == '1' || line[endPosition] == '6')) { isCorrect = false; } endPosition++; } var keyWord = line.Substring(i, endPosition - i); i = endPosition; if (!isCorrect) { return new Lexem { LexemType = LexemType.Unrecognized, LineIndex = lineIndex, Description = "Нерозпізнана лексема", UnrecognizedText = keyWord } } ; var availableKeyWords = new List <string> { "program", "var", "start", "finish", "get", "put", "if", "then", "goto", "div", "mod", "eg", "ne", "not", "and", "or", "integer16_t" }; foreach (var kw in availableKeyWords) { if (kw == keyWord) { KeyWordType keyWordType = KeyWordType.Program; switch (kw) { case "program": keyWordType = KeyWordType.Program; break; case "var": keyWordType = KeyWordType.Var; break; case "start": keyWordType = KeyWordType.Start; break; case "finish": keyWordType = KeyWordType.Finish; break; case "get": keyWordType = KeyWordType.Get; break; case "put": keyWordType = KeyWordType.Put; break; case "if": keyWordType = KeyWordType.If; break; case "then": keyWordType = KeyWordType.Then; break; case "goto": keyWordType = KeyWordType.Goto; break; case "div": keyWordType = KeyWordType.Div; break; case "mod": keyWordType = KeyWordType.Mod; break; case "eg": keyWordType = KeyWordType.Eg; break; case "ne": keyWordType = KeyWordType.Ne; break; case "not": keyWordType = KeyWordType.Not; break; case "and": keyWordType = KeyWordType.And; break; case "or": keyWordType = KeyWordType.Or; break; case "integer16_t": keyWordType = KeyWordType.Integer; break; } return(new Lexem { LexemType = LexemType.KeyWord, LineIndex = lineIndex, Description = "Ключове слово", KeyWord = kw, KeyWordType = keyWordType }); } } return(new Lexem { LexemType = LexemType.Unrecognized, LineIndex = lineIndex, Description = "Нерозпізнана лексема", UnrecognizedText = keyWord }); }