@@ -84,7 +84,7 @@ public function parse() {
84
84
private function parseRecursive () {
85
85
$ sb = "" ;
86
86
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" ) {
88
88
$ p = $ this ->parseStructure ($ c );
89
89
$ o = $ p ->getRight ();
90
90
$ c = $ p ->getLeft ();
@@ -132,12 +132,15 @@ private function parseStructure($c) {
132
132
if ($ c == self ::END_MAP ) {
133
133
$ this ->queue ->dequeue ();
134
134
$ cl = $ this ->conf ->getString (Configuration::CLASS_PROPERTY , Configuration::DEFAULT_CLASS_PROPERTY_VALUE );
135
+ $ p = new Pair ($ c , $ m );
135
136
if (isset ($ m [$ cl ])) {
136
137
$ o = $ this ->createClass ($ m );
137
- $ c = $ this ->in ->nextChar ();
138
- return new Pair ($ c , $ o );
138
+ $ p = new Pair ($ c , $ o );
139
139
}
140
- return new Pair ($ c , $ m );
140
+ if (false !== ($ ch = $ this ->in ->nextChar ())) {
141
+ $ p ->setLeft ($ ch );
142
+ }
143
+ return $ p ;
141
144
}
142
145
break ;
143
146
case self ::START_ARRAY :
@@ -146,7 +149,9 @@ private function parseStructure($c) {
146
149
$ c = $ this ->parseList ($ l );
147
150
if ($ c == self ::END_ARRAY ) {
148
151
$ this ->queue ->dequeue ();
149
- $ c = $ this ->in ->nextChar ();
152
+ if (false !== ($ ch = $ this ->in ->nextChar ())) {
153
+ $ c = $ ch ;
154
+ }
150
155
return new Pair ($ c , $ l );
151
156
}
152
157
break ;
@@ -213,13 +218,13 @@ private function parseMap(&$m) {
213
218
while (false !== ($ c = $ this ->in ->nextChar ())) {
214
219
if ($ c == self ::END_MAP ) {
215
220
return $ c ;
216
- } else {
221
+ } else if ( $ c != self :: SPACE_CHAR && $ c != self :: TAB_CHAR && $ c != "\r" && $ c != "\n" ) {
217
222
$ sb = "" ;
218
223
// searching key
219
224
do {
220
225
if ($ c === false )
221
226
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" )
223
228
$ sb = $ sb . $ c ;
224
229
} while (false !== ($ c = $ this ->in ->nextChar ()) && $ c != self ::VALUE_DELIM );
225
230
$ key = trim ($ sb );
@@ -251,7 +256,7 @@ private function parseList(&$l) {
251
256
while (false !== ($ c = $ this ->in ->nextChar ())) {
252
257
if ($ c == self ::END_ARRAY ) {
253
258
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" ) {
255
260
// do nothing
256
261
} else {
257
262
$ p = $ this ->parseListInnerElement ($ c );
0 commit comments