protected IEnumerable <IConceptInfo> ExtractConcepts(MultiDictionary <string, IConceptParser> conceptParsers) { var stopwatch = Stopwatch.StartNew(); TokenReader tokenReader = new TokenReader(_tokenizer.GetTokens(), 0); List <IConceptInfo> newConcepts = new List <IConceptInfo>(); Stack <IConceptInfo> context = new Stack <IConceptInfo>(); tokenReader.SkipEndOfFile(); while (!tokenReader.EndOfInput) { IConceptInfo conceptInfo = ParseNextConcept(tokenReader, context, conceptParsers); newConcepts.Add(conceptInfo); UpdateContextForNextConcept(tokenReader, context, conceptInfo); if (context.Count == 0) { tokenReader.SkipEndOfFile(); } } _performanceLogger.Write(stopwatch, "DslParser.ExtractConcepts (" + newConcepts.Count + " concepts)."); if (context.Count > 0) { throw new DslSyntaxException(string.Format( ReportErrorContext(context.Peek(), tokenReader) + "Expected \"}\" at the end of the script to close concept \"{0}\".", context.Peek())); } return(newConcepts); }
private IEnumerable <IConceptInfo> ExtractConcepts(MultiDictionary <string, IConceptParser> conceptParsers) { var stopwatch = Stopwatch.StartNew(); TokenReader tokenReader = new TokenReader(_tokenizer.GetTokens(), 0); var newConcepts = new List <IConceptInfo>(); var context = new Stack <IConceptInfo>(); var warnings = new List <string>(); tokenReader.SkipEndOfFile(); while (!tokenReader.EndOfInput) { var parsed = ParseNextConcept(tokenReader, context, conceptParsers); newConcepts.Add(parsed.ConceptInfo); if (parsed.Warnings != null) { warnings.AddRange(parsed.Warnings); } UpdateContextForNextConcept(tokenReader, context, parsed.ConceptInfo); _onKeyword?.Invoke(tokenReader, null); if (context.Count == 0) { tokenReader.SkipEndOfFile(); } } _performanceLogger.Write(stopwatch, "ExtractConcepts (" + newConcepts.Count + " concepts)."); if (context.Count > 0) { var(dslScript, position) = tokenReader.GetPositionInScript(); throw new DslSyntaxException($"Expected \"}}\" to close concept \"{context.Peek()}\".", "RH0002", dslScript, position, 0, ReportPreviousConcept(context.Peek())); } foreach (string warning in warnings) { if (_legacySyntax == ExcessDotInKey.Ignore) { _logger.Trace(warning); } else { _logger.Warning(warning); } } if (_legacySyntax == ExcessDotInKey.Error && warnings.Any()) { throw new DslSyntaxException(warnings.First()); } return(newConcepts); }
private IEnumerable <IConceptInfo> ExtractConcepts(MultiDictionary <string, IConceptParser> conceptParsers) { var stopwatch = Stopwatch.StartNew(); TokenReader tokenReader = new TokenReader(_tokenizer.GetTokens(), 0); var newConcepts = new List <IConceptInfo>(); var context = new Stack <IConceptInfo>(); var warnings = new List <string>(); tokenReader.SkipEndOfFile(); while (!tokenReader.EndOfInput) { var parsed = ParseNextConcept(tokenReader, context, conceptParsers); newConcepts.Add(parsed.ConceptInfo); if (parsed.Warnings != null) { warnings.AddRange(parsed.Warnings); } UpdateContextForNextConcept(tokenReader, context, parsed.ConceptInfo); if (context.Count == 0) { tokenReader.SkipEndOfFile(); } } _performanceLogger.Write(stopwatch, "DslParser.ExtractConcepts (" + newConcepts.Count + " concepts)."); if (context.Count > 0) { throw new DslSyntaxException(string.Format( ReportErrorContext(context.Peek(), tokenReader) + "Expected \"}\" at the end of the script to close concept \"{0}\".", context.Peek())); } foreach (string warning in warnings) { if (_legacySyntax.Value == LegacySyntax.Ignore) { _logger.Trace(warning); } else { _logger.Info(warning); } } if (_legacySyntax.Value == LegacySyntax.Error && warnings.Any()) { throw new DslSyntaxException(warnings.First()); } return(newConcepts); }
protected IEnumerable<IConceptInfo> ExtractConcepts(IEnumerable<IConceptParser> conceptParsers) { var stopwatch = Stopwatch.StartNew(); TokenReader tokenReader = new TokenReader(_tokenizer.GetTokens(), 0); List<IConceptInfo> newConcepts = new List<IConceptInfo>(); Stack<IConceptInfo> context = new Stack<IConceptInfo>(); tokenReader.SkipEndOfFile(); while (!tokenReader.EndOfInput) { IConceptInfo conceptInfo = ParseNextConcept(tokenReader, context, conceptParsers); newConcepts.Add(conceptInfo); UpdateContextForNextConcept(tokenReader, context, conceptInfo); if (context.Count == 0) tokenReader.SkipEndOfFile(); } _performanceLogger.Write(stopwatch, "DslParser.ExtractConcepts (" + newConcepts.Count + " concepts)."); if (context.Count > 0) throw new DslSyntaxException(string.Format( ReportErrorContext(context.Peek(), tokenReader) + "Expected \"}\" at the end of the script to close concept \"{0}\".", context.Peek())); return newConcepts; }