Hi Peter,

> On 05 Jul 2015, at 14:36, Peter Uhnák <[email protected]> wrote:
> 
> How come this passes?
> 
> STON fromString: '{
>       "a": "b"
> }wtf",
>       "x": "y"
> '.
> 
> The result is dictionary "a" -> "b".
> 
> I would expect for it to die on parse error.
> 
> Peter

The reason this does not fail is because (1) STON is a stream parser that 
accepts possibly multiple top-level expression from one stream (2) your input 
is basically valid and complete until the closing curly brace.

You could enforce the fact that the whole input should be consumed yourself.

| input reader result |
input := '{
        "a": "b"
}wtf",
        "x": "y"
' readStream.
reader := STON reader on: input.
result := reader next.
reader consumeWhitespace.
self assert: reader atEnd.
result

Sven


Reply via email to