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

Add support for rust-peg output when working with slices #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

garretfick
Copy link

Motivation for change

rust-peg trace statements are in one of two forms.

When the input is a str, then the statements are line/column:

[PEG_TRACE] Attempting to match rule `nums` at 1:1
[PEG_TRACE] Matched rule `nums` at 1:1 to 1:5

When the input is a slice, then the statements are indices:

[PEG_TRACE] Attempting to match rule `list` at 0
[PEG_TRACE] Matched rule `list` at 0 to 5`

pegviz failed when parsing the index form because it expected only the line/column form.

What changed

This pull request adds support for the index form. There are two parts to the proposed change:

  • update the parser to support both forms
  • change the Location struct to an enum to support both forms
  • change the pos function to support either Location form

How do I know it works?

I wrote two integration tests that parse output that I generated from rust-peg. I also tested with output from ironplc (a project I'm building that uses rust-peg) using both the str and slice variations of the parser.

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

Successfully merging this pull request may close these issues.

1 participant