@@ -345,10 +345,12 @@ impl Parser {
345
345
/// - `bytes`: a slice to search a new XML event. Should contain text in
346
346
/// ASCII-compatible encoding
347
347
pub fn feed ( & mut self , bytes : & [ u8 ] ) -> Result < FeedResult , SyntaxError > {
348
+ dbg ! ( ( self . 0 , crate :: utils:: Bytes ( bytes) ) ) ;
348
349
for ( offset, & byte) in bytes. iter ( ) . enumerate ( ) {
349
350
let trail = & bytes[ offset..] ;
350
351
let start = offset + 1 ;
351
352
let rest = & bytes[ start..] ;
353
+ dbg ! ( ( self . 0 , offset, byte as char , crate :: utils:: Bytes ( trail) , crate :: utils:: Bytes ( rest) ) ) ;
352
354
self . 0 = match self . 0 {
353
355
State :: Start => match byte {
354
356
0x00 => State :: Bom ( BomParser :: X00 ) ,
@@ -549,6 +551,7 @@ impl Parser {
549
551
/// - `offset`: a position of `bytes` sub-slice in the one that was passed to `feed()`
550
552
#[ inline]
551
553
fn parse_text ( & mut self , bytes : & [ u8 ] , offset : usize ) -> FeedResult {
554
+ dbg ! ( ( self . 0 , offset, crate :: utils:: Bytes ( bytes) ) ) ;
552
555
self . 0 = State :: Text ;
553
556
match bytes. iter ( ) . position ( |& b| b == b'<' ) {
554
557
Some ( i) => FeedResult :: EmitText ( offset + i) ,
@@ -570,6 +573,7 @@ impl Parser {
570
573
offset : usize ,
571
574
mut parser : CommentParser ,
572
575
) -> FeedResult {
576
+ dbg ! ( ( self . 0 , offset, crate :: utils:: Bytes ( bytes) , parser) ) ;
573
577
match parser. feed ( bytes) {
574
578
Some ( i) => {
575
579
self . 0 = State :: Text ;
@@ -593,6 +597,7 @@ impl Parser {
593
597
/// - `offset`: a position of `bytes` sub-slice in the one that was passed to `feed()`
594
598
/// - `braces_left`: count of braces that wasn't seen yet in the end of previous data chunk
595
599
fn parse_cdata ( & mut self , bytes : & [ u8 ] , offset : usize , mut parser : CDataParser ) -> FeedResult {
600
+ dbg ! ( ( self . 0 , offset, crate :: utils:: Bytes ( bytes) , parser) ) ;
596
601
match parser. feed ( bytes) {
597
602
Some ( i) => {
598
603
self . 0 = State :: Text ;
@@ -611,8 +616,9 @@ impl Parser {
611
616
offset : usize ,
612
617
mut parser : QuotedParser ,
613
618
) -> Result < FeedResult , SyntaxError > {
619
+ dbg ! ( ( self . 0 , offset, crate :: utils:: Bytes ( bytes) , parser) ) ;
614
620
// Search `[` (start of DTD definitions) or `>` (end of <!DOCTYPE> tag)
615
- match parser. one_of ( bytes) {
621
+ match dbg ! ( parser. one_of( bytes) ) {
616
622
OneOf :: Open ( i) => self . parse_dtd ( & bytes[ i..] , offset + i, DtdParser :: default ( ) ) ,
617
623
OneOf :: Close ( i) => {
618
624
self . 0 = State :: Text ;
@@ -639,8 +645,9 @@ impl Parser {
639
645
mut offset : usize ,
640
646
mut parser : DtdParser ,
641
647
) -> Result < FeedResult , SyntaxError > {
648
+ dbg ! ( ( self . 0 , offset, crate :: utils:: Bytes ( bytes) , parser) ) ;
642
649
loop {
643
- let result = match parser. feed ( bytes) {
650
+ let result = match dbg ! ( parser. feed( bytes) ) {
644
651
// Skip recognized DTD structure
645
652
// TODO: Emit DTD events while parsing
646
653
quick_dtd:: FeedResult :: EmitPI ( off)
@@ -669,7 +676,8 @@ impl Parser {
669
676
}
670
677
671
678
fn parse_doctype_finish ( & mut self , bytes : & [ u8 ] , offset : usize ) -> FeedResult {
672
- match bytes. iter ( ) . position ( |& b| b == b'>' ) {
679
+ dbg ! ( ( self . 0 , offset, crate :: utils:: Bytes ( bytes) ) ) ;
680
+ match dbg ! ( bytes. iter( ) . position( |& b| b == b'>' ) ) {
673
681
Some ( i) => {
674
682
self . 0 = State :: Text ;
675
683
// +1 for `>` which should be included in event
@@ -692,7 +700,8 @@ impl Parser {
692
700
/// - `offset`: a position of `bytes` sub-slice in the one that was passed to `feed()`
693
701
/// - `has_mark`: a flag that indicates was the previous fed data ended with `?`
694
702
fn parse_pi ( & mut self , bytes : & [ u8 ] , offset : usize , mut parser : PiParser ) -> FeedResult {
695
- match parser. feed ( bytes) {
703
+ dbg ! ( ( self . 0 , offset, crate :: utils:: Bytes ( bytes) , parser) ) ;
704
+ match dbg ! ( parser. feed( bytes) ) {
696
705
Some ( i) => {
697
706
self . 0 = State :: Text ;
698
707
FeedResult :: EmitPI ( offset + i)
@@ -711,7 +720,8 @@ impl Parser {
711
720
/// That sub-slice begins on the byte that represents a tag name
712
721
/// - `offset`: a position of `bytes` sub-slice in the one that was passed to `feed()`
713
722
fn parse_end ( & mut self , bytes : & [ u8 ] , offset : usize ) -> FeedResult {
714
- match bytes. iter ( ) . position ( |& b| b == b'>' ) {
723
+ dbg ! ( ( self . 0 , offset, crate :: utils:: Bytes ( bytes) ) ) ;
724
+ match dbg ! ( bytes. iter( ) . position( |& b| b == b'>' ) ) {
715
725
Some ( i) => {
716
726
self . 0 = State :: Text ;
717
727
// +1 for `>` which should be included in event
@@ -740,7 +750,8 @@ impl Parser {
740
750
mut parser : QuotedParser ,
741
751
has_slash : bool ,
742
752
) -> FeedResult {
743
- match parser. feed ( bytes) {
753
+ dbg ! ( ( self . 0 , offset, crate :: utils:: Bytes ( bytes) , parser, has_slash) ) ;
754
+ match dbg ! ( parser. feed( bytes) ) {
744
755
Some ( 0 ) if has_slash => {
745
756
self . 0 = State :: Text ;
746
757
// +1 for `>` which should be included in event
0 commit comments