• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use reader::events::XmlEvent;
2 use reader::lexer::Token;
3 
4 use super::{Result, PullParser, State};
5 
6 impl PullParser {
inside_comment(&mut self, t: Token) -> Option<Result>7     pub fn inside_comment(&mut self, t: Token) -> Option<Result> {
8         match t {
9             // Double dash is illegal inside a comment
10             Token::Chunk(ref s) if &s[..] == "--" => Some(self_error!(self; "Unexpected token inside a comment: --")),
11 
12             Token::CommentEnd if self.config.ignore_comments => {
13                 self.lexer.outside_comment();
14                 self.into_state_continue(State::OutsideTag)
15             }
16 
17             Token::CommentEnd => {
18                 self.lexer.outside_comment();
19                 let data = self.take_buf();
20                 self.into_state_emit(State::OutsideTag, Ok(XmlEvent::Comment(data)))
21             }
22 
23             _ if self.config.ignore_comments => None,  // Do not modify buffer if ignoring the comment
24 
25             _ => {
26                 t.push_to_string(&mut self.buf);
27                 None
28             }
29         }
30     }
31 
32 }
33