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

Support :rept expressions in PEG #9

Merged
merged 1 commit into from
Oct 24, 2020

Conversation

stouset
Copy link
Contributor

@stouset stouset commented Oct 23, 2020

:rept wasn't supported in the PEG, even though it exists for ABNF.

When implementing a PEG parser based on ABNF with an a*b-style rule, you currently get

RuntimeError: attempt to parse unknown rule type: rept

@gkellogg
Copy link
Collaborator

You may need to parse the ABNF, and then run the to_peg method to generate a grammar that can be parsed.

You can see how it's done in the ABNF example.

If it's still not working for you, please give me the example you're using and I'll work it up. If the README needs updates to clarify this, please consider a PR.

@gkellogg
Copy link
Collaborator

(Sorry, thinking this was an issue, not a PR). I'll look at this more closely and consider. There are working examples that use rept, so the to_peg process may handle this, but direct support would be better.

@stouset
Copy link
Contributor Author

stouset commented Oct 23, 2020

PEG didn't have the support to handle rept(input, m, prod) in the AST, from what I could tell. A simple ABNF parsed by

EBNF.parse(File.read(abnf_path), format: :abnf).make_peg.ast

has rept rules in it, but actually trying to run a parser with them fails.

@gkellogg
Copy link
Collaborator

As you know, things get very meta quickly when you're working on this stuff :) This can make it challenging to keep things straight. I believe the Rule#parse method did have direct support for this, but it must have been dropped accidentally along the way.

Ideally, one of the examples in the ABNF example directory would also exercise this functionality (I'm surprised it doesn't).

Also, as this is a substantive change, if you haven't already done so, and as called for in the README, please consider making a public domain dedication, as part of this PR. This will cover any future contributions, as well.

@stouset
Copy link
Contributor Author

stouset commented Oct 24, 2020

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>

@gkellogg
Copy link
Collaborator

Thanks, but that was the body of the unlicensed the dedication is the following

I dedicate any and all copyright interest in this software to the
public domain. I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors. I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.

@stouset
Copy link
Contributor Author

stouset commented Oct 24, 2020

Whoops, I should have scrolled down farther.

I dedicate any and all copyright interest in this software to the
public domain. I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors. I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.

@gkellogg gkellogg merged commit d82029c into dryruby:develop Oct 24, 2020
@stouset stouset deleted the support-rept-in-peg branch October 24, 2020 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants