|
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.
>
|