private void TstParser2() { _logger.Info("Begin"); var text = @"app Enemy { on Init => { 'Hello world!' >> @>log; } }"; var parserContext = new TstMainStorageContext(); var codeFile = new CodeFile(); var internalParserContext = new InternalParserContext(text, codeFile, parserContext); var parser = new SourceCodeParser(internalParserContext); parser.Run(); var result = parser.Result; _logger.Info($"parsedFileInfoList = {result.WriteListToString()}"); //Token token = null; //while ((token = internalParserContext.GetToken()) != null) //{ // _logger.Info($"token = {token}"); //} _logger.Info("End"); }
/// <inheritdoc/> public CodeFile Parse(ParsedFileInfo parsedFileInfo, DefaultSettingsOfCodeEntity defaultSettings) { #if DEBUG //Log($"parsedFileInfo = {parsedFileInfo}"); #endif var text = File.ReadAllText(parsedFileInfo.FileName); #if DEBUG //Log($"text = {text}"); #endif var result = new CodeFile(); result.IsLocator = parsedFileInfo.IsLocator; result.FileName = parsedFileInfo.FileName; var internalParserContext = new InternalParserContext(text, result, _context); internalParserContext.SetCurrentDefaultSetings(defaultSettings); var parser = new SourceCodeParser(internalParserContext); parser.Run(); var codeEntitiesList = parser.Result; #if DEBUG //Log($"codeEntitiesList = {codeEntitiesList.WriteListToString()}"); #endif result.CodeEntities = codeEntitiesList; return(result); }
/// <inheritdoc/> public List <CodeEntity> Parse(string text) { #if DEBUG //Log($"text = {text}"); #endif var codeFile = new CodeFile(); var internalParserContext = new InternalParserContext(text, codeFile, _context); var parser = new SourceCodeParser(internalParserContext); parser.Run(); return(parser.Result); }
private static void TstLinguisticVariable_Tests() { _logger.Log("Begin"); var text = @"linvar logic for range [0, 1] { constraints: for inheritance; terms: minimal = L(0, 0.1); low = Trapezoid(0, 0.05, 0.3, 0.45); middle = Trapezoid(0.3, 0.4, 0.6, 0.7); high = Trapezoid(0.55, 0.7, 0.95, 1); maximal = S(0.9, 1); }"; var mainStorageContext = new UnityTestMainStorageContext(); var codeFile = new CodeFile(); var internalParserContext = new InternalParserContext(text, codeFile, mainStorageContext); var parser = new SourceCodeParser(internalParserContext); parser.Run(); var result = parser.Result; var firstItem = result.SingleOrDefault(); firstItem.LinguisticVariable.CheckDirty(); _logger.Log($"firstItem = {firstItem}"); var term = firstItem.LinguisticVariable.Values[4]; _logger.Log($"term = {term}"); var handler = term.Handler; _logger.Log($"handler = {handler}"); _logger.Log("End"); }
private CodeEntity Parse(string text) { var codeFile = new CodeFile(); var internalParserContext = new InternalParserContext(text, codeFile, _mainStorageContext); var parser = new SourceCodeParser(internalParserContext); parser.Run(); var result = parser.Result; Assert.AreEqual(result.Count, 1); var firstItem = result.Single(); return(firstItem); }