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

Sequence not working as expected #104

Open
david-pfx opened this issue Jan 7, 2018 · 2 comments
Open

Sequence not working as expected #104

david-pfx opened this issue Jan 7, 2018 · 2 comments

Comments

@david-pfx
Copy link

I rather expected these two ways of defining an Ident to work the same, but they don't.

    Ident = Letter IdChar* WSC
    Ident = v:( Letter IdChar*) WSC { v }
    WSC = SP* { "" }

The first one includes trailing whitespace, which is unexpected given that WSC is supposed to translate into empty. The generated code goes to all the trouble of acquiring the correct values for each component and then just does a substring from first to last for the returned value.

Not really that useful as it stands. Not a biggie, but annoying.

@otac0n
Copy link
Owner

otac0n commented Jan 18, 2018

This is by design, but if you have a proposal for a different behavior, I'm open to taking a change. I agree that this is a bit of a rough edge.

@david-pfx
Copy link
Author

The existing generated code looks like this:
state.Subject.Substring(startCursor0.Location, len)

It's a simple solution, to treat a sequence as just a chunk of characters, but really a sequence is the concatenation of its components. The aim would be to generate code more like:
String.Concat(r0, r1, r2, ...)

But I agree, it would be a breaking change, so it would be best if it could be optional.

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

No branches or pull requests

2 participants