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

more doc? #100

Open
kpixley opened this issue Jun 30, 2020 · 3 comments
Open

more doc? #100

kpixley opened this issue Jun 30, 2020 · 3 comments

Comments

@kpixley
Copy link

kpixley commented Jun 30, 2020

Doc appears to be out of date. Notably, buffer[begin:end] doesn't work. Not very useful without it.

I'm also having trouble understanding how to build parse trees with peg. leg apparently has/had $$ = but when I try that, peg dumps core.

Also having trouble figuring out error handling. Like, how do I report an error up from embedded fragments?

Is the parser guaranteed to be "p"? It is used in examples, but not mentioned in doc.

Is there an equivalent to yyaccept or yyreject?

Is there a - operator as with leg?

@theclapp
Copy link

I am not the author, but I can help with a few of these.

Notably, buffer[begin:end] doesn't work

Use text in your Go code to refer to the text captured between < and >. See peg.peg for examples.

Is the parser guaranteed to be "p"?

Yes. In the template in tree/peg.go, p is hardcoded as the method receiver in all functions.

I don't know about the rest, sorry.

@theclapp
Copy link

Is there a - operator as with leg?

Not sure exactly what this means. Checking the manual for peg/leg, I see - used in two contexts: one is as the dash in a range

range =         char '-' char | char

which this package supports (see here), and one is as a regular part of the grammar

- =             ( space | comment )*

which just defines - as zero-or-more spaces-or-comments.

So I think the answer is: yes, Peg supports the - operator as with leg. Except of course that if you want - to mean (space / comment)* (using Peg syntax), you'll have to define it that way.

@pointlander
Copy link
Owner

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

3 participants