Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PKAlternation + PKAny Repetition = Random Results #22

Open
agg23 opened this issue Aug 16, 2013 · 3 comments
Open

PKAlternation + PKAny Repetition = Random Results #22

agg23 opened this issue Aug 16, 2013 · 3 comments

Comments

@agg23
Copy link

agg23 commented Aug 16, 2013

Running the following parser results in some random results. The result occasionally contains "search" and/or "for", assumedly because of the PKAny Repetition immediately before and after the PKAlternation. Is there any way to resolve this or am I stuck with it?

    NSString *string = @"google search for ducky ducky super ducky duck";
    PKSequence *parser = [PKSequence sequence];

    PKRepetition *repetitionTest = [PKRepetition repetitionWithSubparser:[[PKAny any] discard]];

    [parser add:repetitionTest];

    PKAlternation *optionalSearch = [PKAlternation alternation];
    [optionalSearch add:[[PKEmpty empty] discard]];
    [optionalSearch add:[[PKLiteral literalWithString:@"search"] discard]];
    [parser add:optionalSearch];

    [parser add:[[PKLiteral literalWithString:@"google"] discard]];
    [parser add:optionalSearch];

    PKAlternation *optionalFor = [PKAlternation alternation];
    [optionalFor add:[[PKEmpty empty] discard]];
    [optionalFor add:[[PKLiteral literalWithString:@"for"] discard]];

    [parser add:optionalFor];

    PKRepetition *searchTerm = [PKRepetition repetitionWithSubparser:[PKAny any]];
    [parser add:searchTerm];
    PKAssembly *result = [parser bestMatchFor:[PKTokenAssembly assemblyWithString:string]]
@zakdances
Copy link

Are you still seeing incorrect output?

@agg23
Copy link
Author

agg23 commented Sep 19, 2013

Indeed. I have not discovered the issue.

@agg23
Copy link
Author

agg23 commented Sep 27, 2013

Would you happen to have any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants