Ok but how does the parser knows whether the input is multiexpression or an
error?
I mean it stops parsing in the middle of the string which seems really
weird to me.

Peter

On Sun, Jul 5, 2015 at 3:28 PM, Sven Van Caekenberghe <s...@stfx.eu> wrote:

> Hi Peter,
>
> > On 05 Jul 2015, at 14:36, Peter Uhnák <i.uh...@gmail.com> 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