c# - "Sprache" monadic parser `Or` and `Many` semantics -


i'm using sprache monadic parser parse dsl.

this snippet of grammar:

    public static readonly parser<iexpression> terminatedstatement =         exp in parse.ref(() => expression)         _ in parse.char(';').token()         select exp;      public static readonly parser<iexpression> statement =             parse.ref(() => terminatedstatement)             .or(parse.ref(() => invocationstatement));      public static readonly parser<statements> statements =         statements in statement.many()         select new statements(statements); 

if use statements.parse(" ") exception saying there unexpected end of input.

how can when statements use many operator, afaik yields 0-n results.

" " should return statements instance containing 0 statements.

so how can parser complain there unexpected end of input? shouldnt conclude there no statements there? (no matter funky stuff different expressions make statements do)


Comments