示例#1
0
        public ResultParsing ParseString(StringBuilder source, string sourceFile)
        {
            ResultParsing resultParsing = null;

            using (var l = Lock(sourceFile))
            {
                var a = this.Errors.Where(c => c.Filename == sourceFile).ToList();
                foreach (var item in a)
                {
                    this.Errors.Remove(item);
                }

                var result  = WorkflowConfigParser.ParseString(source, sourceFile, this._output, this._outputError);
                var visitor = (WorkflowConfigVisitor) new WorkflowConfigVisitor()
                {
                    Filename = sourceFile,
                }.Visit(result.Tree)
                ;

                this.Errors.AddRange(visitor.Errors);

                resultParsing = new ResultParsing()
                {
                    Keywords   = visitor.Keywords,
                    Texts      = visitor.Texts,
                    References = visitor.References,
                };
            }

            return(resultParsing);
        }
示例#2
0
        public static WorkflowConfigParser ParseString(StringBuilder source, string sourceFile = "", TextWriter output = null, TextWriter outputError = null)
        {
            ICharStream stream = CharStreams.fromstring(source.ToString());

            var parser = new WorkflowConfigParser(output, outputError)
            {
                File    = sourceFile ?? string.Empty,
                Content = source,
                Crc     = source.ToString().GetHashCode(),
            };

            parser.ParseCharStream(stream);
            return(parser);
        }