@@ -84,7 +84,7 @@ public function parse() {
8484 private function parseRecursive () {
8585 $ sb = "" ;
8686 while (false !== ($ c = $ this ->in ->nextChar ())) {
87- if ($ c != self ::SPACE_CHAR && $ c != self ::TAB_CHAR ) {
87+ if ($ c != self ::SPACE_CHAR && $ c != self ::TAB_CHAR && $ c != "\r" && $ c != "\n" ) {
8888 $ p = $ this ->parseStructure ($ c );
8989 $ o = $ p ->getRight ();
9090 $ c = $ p ->getLeft ();
@@ -132,12 +132,15 @@ private function parseStructure($c) {
132132 if ($ c == self ::END_MAP ) {
133133 $ this ->queue ->dequeue ();
134134 $ cl = $ this ->conf ->getString (Configuration::CLASS_PROPERTY , Configuration::DEFAULT_CLASS_PROPERTY_VALUE );
135+ $ p = new Pair ($ c , $ m );
135136 if (isset ($ m [$ cl ])) {
136137 $ o = $ this ->createClass ($ m );
137- $ c = $ this ->in ->nextChar ();
138- return new Pair ($ c , $ o );
138+ $ p = new Pair ($ c , $ o );
139139 }
140- return new Pair ($ c , $ m );
140+ if (false !== ($ ch = $ this ->in ->nextChar ())) {
141+ $ p ->setLeft ($ ch );
142+ }
143+ return $ p ;
141144 }
142145 break ;
143146 case self ::START_ARRAY :
@@ -146,7 +149,9 @@ private function parseStructure($c) {
146149 $ c = $ this ->parseList ($ l );
147150 if ($ c == self ::END_ARRAY ) {
148151 $ this ->queue ->dequeue ();
149- $ c = $ this ->in ->nextChar ();
152+ if (false !== ($ ch = $ this ->in ->nextChar ())) {
153+ $ c = $ ch ;
154+ }
150155 return new Pair ($ c , $ l );
151156 }
152157 break ;
@@ -213,13 +218,13 @@ private function parseMap(&$m) {
213218 while (false !== ($ c = $ this ->in ->nextChar ())) {
214219 if ($ c == self ::END_MAP ) {
215220 return $ c ;
216- } else {
221+ } else if ( $ c != self :: SPACE_CHAR && $ c != self :: TAB_CHAR && $ c != "\r" && $ c != "\n" ) {
217222 $ sb = "" ;
218223 // searching key
219224 do {
220225 if ($ c === false )
221226 throw new \Exception ("Reached end of stream - un-parsed data " );
222- if ($ c != self ::ELEM_DELIM )
227+ if ($ c != self ::ELEM_DELIM && $ c != "\r" && $ c != "\n" )
223228 $ sb = $ sb . $ c ;
224229 } while (false !== ($ c = $ this ->in ->nextChar ()) && $ c != self ::VALUE_DELIM );
225230 $ key = trim ($ sb );
@@ -251,7 +256,7 @@ private function parseList(&$l) {
251256 while (false !== ($ c = $ this ->in ->nextChar ())) {
252257 if ($ c == self ::END_ARRAY ) {
253258 return $ c ;
254- } else if ($ c == self ::ELEM_DELIM || $ c == self ::VALUE_DELIM ) {
259+ } else if ($ c == self ::SPACE_CHAR || $ c == self :: TAB_CHAR || $ c == self :: ELEM_DELIM || $ c == self ::VALUE_DELIM || $ c == "\r" || $ c == "\n" ) {
255260 // do nothing
256261 } else {
257262 $ p = $ this ->parseListInnerElement ($ c );
0 commit comments