From: Frédéric S. <fre...@ar...> - 2009-11-18 14:43:39
Attachments:
frederic_surleau.vcf
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body bgcolor="#ffffff" text="#000000"> Hi,<br> <br> Example :<br> <br> {<br> "test":<br> [<br> { "a" : "aaa" }, // Comment for a<br> { "b" : "bbb" }, // Comment for b<br> { "c" : "ccc" } // Comment for c<br> ]<br> }<br> <br> With this example you get an error : "Missing ',' or ']' in array declaration" for "// Comment for c"<br> <br> I fixed the problem by reading tokens in the same way readObject() does.<br> <br> Fixed version of readArray() :<br> <br> <tt>bool<br> Reader::readArray( Token &tokenStart )<br> {<br> currentValue() = Value( arrayValue );<br> skipSpaces();<br> if ( *current_ == ']' ) // empty array<br> {<br> Token endArray;<br> readToken( endArray );<br> return true;<br> }<br> int index = 0;<br> while ( true )<br> {<br> Value &value = currentValue()[ index++ ];<br> nodes_.push( &value );<br> bool ok = readValue();<br> nodes_.pop();<br> if ( !ok ) // error already set<br> return recoverFromError( tokenArrayEnd );<br> <br> Token token;<br> <font color="#3333ff"><b> // Accept Comment after last item in the array.<br> ok = readToken( token );<br> while ( token.type_ == tokenComment && ok )<br> ok = readToken( token );<br> if( ! ok<br> </b></font> || ( token.type_ != tokenArraySeparator &&<br> token.type_ != tokenArrayEnd ) )<br> {<br> return addErrorAndRecover( "Missing ',' or ']' in array declaration",<br> token,<br> tokenArrayEnd );<br> }<br> if ( token.type_ == tokenArrayEnd )<br> break;<br> }<br> return true;<br> }<br> </tt><br> <br> Regards,<br> Frédéric SURLEAU.<br> <br> </body> </html> |
From: Baptiste L. <bap...@gm...> - 2009-11-18 22:26:30
|
Test added and code fixed. Thanks for signaling this, Baptiste. Le 18 novembre 2009 15:27, Frédéric SURLEAU <fre...@ar...> a écrit : > Hi, > > Example : > > { > "test": > [ > { "a" : "aaa" }, // Comment for a > { "b" : "bbb" }, // Comment for b > { "c" : "ccc" } // Comment for c > ] > } > > With this example you get an error : "Missing ',' or ']' in array > declaration" for "// Comment for c" > > I fixed the problem by reading tokens in the same way readObject() does. > > Fixed version of readArray() : > > bool > Reader::readArray( Token &tokenStart ) > { > currentValue() = Value( arrayValue ); > skipSpaces(); > if ( *current_ == ']' ) // empty array > { > Token endArray; > readToken( endArray ); > return true; > } > int index = 0; > while ( true ) > { > Value &value = currentValue()[ index++ ]; > nodes_.push( &value ); > bool ok = readValue(); > nodes_.pop(); > if ( !ok ) // error already set > return recoverFromError( tokenArrayEnd ); > > Token token; > * // Accept Comment after last item in the array. > ok = readToken( token ); > while ( token.type_ == tokenComment && ok ) > ok = readToken( token ); > if( ! ok > * || ( token.type_ != tokenArraySeparator && > token.type_ != tokenArrayEnd ) ) > { > return addErrorAndRecover( "Missing ',' or ']' in array > declaration", > > token, > > tokenArrayEnd ); > } > if ( token.type_ == tokenArrayEnd ) > break; > } > return true; > } > > > Regards, > Frédéric SURLEAU. > |