Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Literal tokens beginning with @ fail? #411

Closed
nkcmr opened this issue Jul 20, 2024 · 2 comments
Closed

Literal tokens beginning with @ fail? #411

nkcmr opened this issue Jul 20, 2024 · 2 comments

Comments

@nkcmr
Copy link

nkcmr commented Jul 20, 2024

I am trying to use this library to try to create a Go parser of Turtle. One of the productions of Turtle is a line that literally begins with @prefix (here).

When I try to create a parser that specifies that the "@prefix" token starts the line, it just doesn't work in Participle. I've condensed this issue into a small, runnable snippet here: https://go.dev/play/p/kOQ2_bAA2Re

This snippet builds 2 parsers:

GRAMMAR (broken):
ProgramBroken = WordBroken* .
WordBroken = "@word" <string> ";" .

GRAMMAR (ok):
ProgramOK = WordOK* .
WordOK = "word" <string> ";" .

The one that makes use of the @ symbol does not seem to work, but when the grammar does not use the @ symbol, it works fine.

I apologize if I have missed something obvious in the documentation, but I did scan around for a few hours to try to get past this issue to no avail. Please let me know if any other info helps, and obviously: thank you so much for this library and your time.

@alecthomas
Copy link
Owner

@ and word are two separate tokens, so you'll need to match them separately like "@" "word"

@nkcmr
Copy link
Author

nkcmr commented Jul 20, 2024

That does seem to get some things to work. But then it allows for things like @ word "bar", or @\n\n word "foo"; which, applying back to my use-case of trying to implement a Turtle parser, is invalid.

Repository owner locked and limited conversation to collaborators Jul 21, 2024
@alecthomas alecthomas converted this issue into discussion #413 Jul 21, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants