Skip to content

Ref inside Or not working #166

@BorisTheBrave

Description

@BorisTheBrave
                var r = new Dictionary<int, Parser<bool>>();

                Parser<bool> R(int i) => Parse.Ref(() => r[i]);
                //Parser<bool> R(int i) => r[i];

                r[5] = Parse.Char('b').Return(true);
                r[4] = Parse.Char('a').Return(true);
                r[3] = R(4).Then(_ => R(5)).Or(R(5).Then(_ => R(4))); // ab or ba
                r[2] = R(4).Then(_ => R(4)).Or(R(5).Then(_ => R(5))); // aa or bb
                r[1] = R(2).Then(_ => R(3)).Or(R(3).Then(_ => R(2)));
                //r[1] = R(3).Then(_ => R(2));

                var top = R(1).End().Or(Parse.AnyChar.Return(false));

                Console.WriteLine(top.Parse("babb"));

Expected result: prints "true"
Actual result: Exception Parsing failure: unexpected 'b'; expected a (Line 1, Column 1); recently consumed:

This only occurs if Ref and Or are used - if you substitute either of the commented out lines for the ones above them, the error does not occur.

I presume #129 was not fixed properly.

I tested with Sprache 2.3.1 and 2.3.2-develop-00043

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions