Пример #1
0
        public virtual void Parse(LookaheadTextReader input, ParserVisitor visitor)
        {
            ParserResults results = ParseCore(new SeekableTextReader(input));

            // Replay the results on the visitor
            visitor.Visit(results);
        }
Пример #2
0
        public virtual void Parse(LookaheadTextReader input, ParserVisitor visitor)
        {
            ParserResults results = ParseCore(new SeekableTextReader(input));

            // Replay the results on the visitor
            visitor.Visit(results);
        }
Пример #3
0
 public virtual Task CreateParseTask(TextReader input,
                                     ParserVisitor consumer) {
     return new Task(() => {
         try {
             Parse(input, consumer);
         }
         catch (OperationCanceledException) {
             return; // Just return if we're cancelled.
         }
     });
 }
Пример #4
0
 public virtual Task CreateParseTask(TextReader input,
                                     ParserVisitor consumer)
 {
     return(new Task(() => {
         try {
             Parse(input, consumer);
         }
         catch (OperationCanceledException) {
             return; // Just return if we're cancelled.
         }
     }));
 }
Пример #5
0
        public virtual void Parse(LookaheadTextReader input, ParserVisitor visitor) {
            // Setup the parser context
            ParserContext context = new ParserContext(input, CodeParser, MarkupParser, MarkupParser, visitor) {
                DesignTimeMode = DesignTimeMode
            };

            MarkupParser.Context = context;
            CodeParser.Context = context;

            // Execute the context
            try {
                MarkupParser.ParseDocument();
            }
            finally {
                context.OnComplete();
            }
        }
Пример #6
0
        public static void Visit(this ParserVisitor self, ParserResults result)
        {
            if (self == null)
            {
                throw new ArgumentNullException("self");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            result.Document.Accept(self);
            foreach (RazorError error in result.ParserErrors)
            {
                self.VisitError(error);
            }
            self.OnComplete();
        }
Пример #7
0
        public virtual void Parse(LookaheadTextReader input, ParserVisitor visitor)
        {
            // Setup the parser context
            ParserContext context = new ParserContext(input, CodeParser, MarkupParser, MarkupParser, visitor)
            {
                DesignTimeMode = DesignTimeMode
            };

            MarkupParser.Context = context;
            CodeParser.Context   = context;

            // Execute the context
            try {
                MarkupParser.ParseDocument();
            }
            finally {
                context.OnComplete();
            }
        }
Пример #8
0
 public VisitorPair(ParserVisitor visitor1, ParserVisitor visitor2) {
     Visitor1 = visitor1;
     Visitor2 = visitor2;
 }
 private ParserContext SetupTestRun(string document, Action<TextReader> positioningAction, ParserBase codeParser, MarkupParser markupParser, ParserBase activeParser, ParserVisitor listener) {
     ParserContext context = new ParserContext(new BufferingTextReader(new StringReader(document)), codeParser, markupParser, activeParser, listener);
     positioningAction(context.Source);
     context.ResetBuffers();
     return context;
 }
Пример #10
0
 private ParserContext SetupTestRun(string document, ParserVisitor listener) {
     var codeParser = new CSharpCodeParser();
     var markupParser = new HtmlMarkupParser();
     return SetupTestRun(document, b => { }, codeParser, markupParser, codeParser, listener);
 }
Пример #11
0
 public virtual void Parse(TextReader input, ParserVisitor visitor) {
     Parse(new BufferingTextReader(input), visitor);
 }
Пример #12
0
        public ParserContext(LookaheadTextReader source, ParserBase codeParser, MarkupParser markupParser, ParserBase activeParser, ParserVisitor visitor) {
            if (source == null) { throw new ArgumentNullException("source"); }
            if (codeParser == null) { throw new ArgumentNullException("codeParser"); }
            if (markupParser == null) { throw new ArgumentNullException("markupParser"); }
            if (activeParser == null) { throw new ArgumentNullException("activeParser"); }
            if (visitor == null) { throw new ArgumentNullException("visitor"); }
            if (activeParser != codeParser && activeParser != markupParser) {
                throw new ArgumentException(RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, "activeParser");
            }

            CaptureOwnerTask();

            Source = source;
            CodeParser = codeParser;
            MarkupParser = markupParser;
            ActiveParser = activeParser;
            _visitorStack.Push(visitor);
            ResetBuffers();
        }
Пример #13
0
 public virtual void Parse(TextReader input, ParserVisitor visitor)
 {
     Parse(new BufferingTextReader(input), visitor);
 }
Пример #14
0
 public VisitorPair(ParserVisitor visitor1, ParserVisitor visitor2)
 {
     Visitor1 = visitor1;
     Visitor2 = visitor2;
 }
Пример #15
0
 /// <summary>
 /// Pushes a visitor onto the visitor stack
 /// </summary>
 /// <remarks>
 /// When StartBlock/EndBlock/EndSpan/OnError are called, the visitor on the top of the visitor stack
 /// will receive those calls.
 /// </remarks>
 public void PushVisitor(ParserVisitor visitor) {
     AssertOnOwnerTask();
     _visitorStack.Push(visitor);
 }
Пример #16
0
 public virtual void Parse(TextReader input, ParserVisitor visitor)
 {
     Parse(new SeekableTextReader(input), visitor);
 }
Пример #17
0
 /// <summary>
 /// Pushes a visitor onto the visitor stack
 /// </summary>
 /// <remarks>
 /// When StartBlock/EndBlock/EndSpan/OnError are called, the visitor on the top of the visitor stack
 /// will receive those calls.
 /// </remarks>
 public void PushVisitor(ParserVisitor visitor)
 {
     AssertOnOwnerTask();
     _visitorStack.Push(visitor);
 }
Пример #18
0
 /// <summary>
 /// Parses the specified template.
 /// </summary>
 /// <param name="template">The string template to parse.</param>
 /// <param name="parser">The parser.</param>
 /// <param name="visitor">The parser visitor.</param>
 private static void ParseTemplate(string template, RazorParser parser, ParserVisitor visitor)
 {
     using (var reader = new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(template))))
     {
         parser.Parse(reader, visitor);
     }
 }
Пример #19
0
 public virtual ParserContext CreateParserRun(LookaheadTextReader input, ParserBase codeParser, MarkupParser markupParser, ParserVisitor listener) {
     return new ParserContext(input, codeParser, markupParser, SelectActiveParser(codeParser, markupParser), listener);
 }
Пример #20
0
 public virtual void Parse(TextReader input, ParserVisitor visitor)
 {
     Parse(new SeekableTextReader(input), visitor);
 }
Пример #21
0
        public ParserContext(LookaheadTextReader source, ParserBase codeParser, MarkupParser markupParser, ParserBase activeParser, ParserVisitor visitor)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (codeParser == null)
            {
                throw new ArgumentNullException("codeParser");
            }
            if (markupParser == null)
            {
                throw new ArgumentNullException("markupParser");
            }
            if (activeParser == null)
            {
                throw new ArgumentNullException("activeParser");
            }
            if (visitor == null)
            {
                throw new ArgumentNullException("visitor");
            }
            if (activeParser != codeParser && activeParser != markupParser)
            {
                throw new ArgumentException(RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, "activeParser");
            }

            CaptureOwnerTask();

            Source       = source;
            CodeParser   = codeParser;
            MarkupParser = markupParser;
            ActiveParser = activeParser;
            _visitorStack.Push(visitor);
            ResetBuffers();
        }