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

Improve documentation #185

Closed
4 tasks
dragostis opened this issue Jan 22, 2018 · 12 comments · Fixed by #730
Closed
4 tasks

Improve documentation #185

dragostis opened this issue Jan 22, 2018 · 12 comments · Fixed by #730

Comments

@dragostis
Copy link
Contributor

dragostis commented Jan 22, 2018

Four critical areas:

  • iterators example
  • prec_climber example
  • PrecClimber example (can be the same as above)
  • any undocumented stuff
@XAMPPRocky
Copy link

Hello, I'd also like to add that there is a lack of examples beyond what is in the README. The only example I can find is one in pest/examples and it seems to not use the same syntax as the README's examples. Something for feature complete like a ini parser that's small but shows best practices for parsing file formats would be great!

@dragostis
Copy link
Contributor Author

dragostis commented Feb 12, 2018

@Aaronepower Examples and reference are found in the pest_derive crate whose documentation is currently offline because of a bug in docs.rs.

@oleid
Copy link

oleid commented Jun 29, 2018

Yesterday, I discovered pest and defined a language to define a graph for some toy project of mine. Writing the grammar was really straight forward, although I never did anything like that before -- kudos!

I also found the test cases in the grammar sub-repo quite helpful to validate the language I defined. Yet, what I'm struggling with is using the parsed output to fill my types with information. While it's working now, it felt more complicated than needed and the code looks ugly (i.e. unwrap all over the place for things, I can safely unwrap, since it parsed correctly before), so I assume I misused the API. Hence, it would be wonderful to get a few "best practices". What I found strange, for example, was that I had to use i.e. a for loop to iterate over the output just to be able to use an into_inner() on the iteration variable for something like this:

[...]
whitelist = { "[" ~ port_or_type ~ ("," ~ port_or_type)* ~ "]" | "[" ~ "]" }
blacklist = { "!" ~ whitelist }

port_or_type = { identifier | int  }
[...]

I'd need iter over blacklist and use into_inner() to get the whitelist. So I end up matching the Rule in the loop and returning from the function in the match arm. Same goes for port_or_type. Or I manually called next() on the iterator. Iterating over the whitelist, however, is okay, since it's a list.

@benruijl
Copy link

benruijl commented Sep 1, 2018

I am trying to find out how to do custom error messages, but I can't seem to find anything about this in the documentation, nor in the examples.

@dragostis
Copy link
Contributor Author

@benruijl, what kind of custom errors? Error type has a custom error that you could use at semantic level. For parsing, you can have special rules, that, when they match, you know that an error was caused.

@benruijl
Copy link

benruijl commented Sep 1, 2018

I meant giving a more descriptive error than just the rule name at the semantic level. It is not clear to me how to add that (I do not see that in the documentation).

@dragostis
Copy link
Contributor Author

I'm not exactly sure what you're looking for. Feel free to drop a message on Gitter.

@Eh2406
Copy link

Eh2406 commented Oct 31, 2018

The Stan language was considering using Rust for there new compiler, in so doing they tried pest and describe it as "is not fully documented yet and I wasn’t able to parse something fairly simple with it". In a follow up conversation they elaborated with "I can’t find in my notes what I was specifically having trouble with with Pest. It wasn’t like there was one particular bug - pest in particular admits its documentation is half-finished. I think if you said to them “Someone tried to parse a C-like language” they would probably know what was missing."

@CAD97
Copy link
Contributor

CAD97 commented Oct 31, 2018

Really, what needs to be done is more example work in the book. If we flush out the planned example chapters there, I think we'll have a pretty stellar onboarding experience.

@dragostis
Copy link
Contributor Author

To me, the documentation right now is definitely good enough to do more than just a fairily simple example. Did the author give the book a fair chance? It might be the case that it's a bit slow for someone looking tl get right into action.

I'd very much like to offer help if the author would like to give pest another chance! :)

@Eh2406
Copy link

Eh2406 commented Oct 31, 2018

I don't know if they want to give Rust another chance, I think they have settled on OCaml. That is the problem with documentation issues, a lot of the people turned off by it never ask for help.

Ther rust code is at https://github.com/seantalts/stan3/tree/170e6afc5b0e00dc5f201a25a881b7aa11f679b2
I think it would be reasonable to fork the repo and rewrite the example to use pest. I don't know if they will accept a PR, but it would make a good example.

@Timmmm
Copy link

Timmmm commented Nov 8, 2019

I think the missing documentation is pretty clear to be honest:

  • How do you actually get the nice errors mentioned in the readme? For me it just prints a standard #[derive(debug)] output.
  • How do you handle keywords - it's easy for a generic identifier to match before keywords do. (See this section for tree sitter). I think the answer is that you put the identifier last in alternatives lists, but it would be nice if the documentation said.
  • How do I just dump the output of the parser? There doesn't seem to be an easy way.
  • The examples should include a dump of the parser output. Except for the readme, they all just jump straight into processing it before we get to see what the thing that we are processing looks like!
  • Why is all the reference documentation for the grammar syntax in pest-derive, seems like an odd place for it!

Great project, and the documentation isn't too bad to be honest but I feel like it could be great without too much work.

tomtau pushed a commit to tomtau/pest that referenced this issue Nov 4, 2022
added missing_docs warning etc. and documented the currently
undocumented public APIs. added additional explanations in README,
updated links, etc.

Closes pest-parser#335
Closes pest-parser#299
Closes pest-parser#298
Closes pest-parser#297
Closes pest-parser#185
tomtau pushed a commit to tomtau/pest that referenced this issue Nov 4, 2022
added missing_docs warning etc. and documented the currently
undocumented public APIs. added additional explanations in README,
updated links, etc.

Closes pest-parser#335
Closes pest-parser#299
Closes pest-parser#298
Closes pest-parser#297
Closes pest-parser#185
tomtau pushed a commit to tomtau/pest that referenced this issue Nov 4, 2022
added missing_docs warning etc. and documented the currently
undocumented public APIs. added additional explanations in README,
updated links, etc.

Closes pest-parser#335
Closes pest-parser#299
Closes pest-parser#298
Closes pest-parser#297
Closes pest-parser#185
tomtau pushed a commit to tomtau/pest that referenced this issue Nov 4, 2022
added missing_docs warning etc. and documented the currently
undocumented public APIs. added additional explanations in README,
updated links, etc.

Closes pest-parser#335
Closes pest-parser#299
Closes pest-parser#298
Closes pest-parser#297
Closes pest-parser#185
tomtau pushed a commit to tomtau/pest that referenced this issue Nov 4, 2022
added missing_docs warning etc. and documented the currently
undocumented public APIs. added additional explanations in README,
updated links, etc.

Closes pest-parser#335
Closes pest-parser#299
Closes pest-parser#298
Closes pest-parser#297
Closes pest-parser#185
@tomtau tomtau closed this as completed in bd3b18a Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants