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 ebnf representation #13

Merged

Conversation

alexpantyukhin
Copy link
Contributor

Related to issue: #1

@alecthomas
Copy link
Owner

This is awesome, thanks!

@alecthomas alecthomas merged commit a944549 into alecthomas:master Feb 20, 2018
@alecthomas
Copy link
Owner

Hmmm, actually this doesn't seem to be working correctly.

The following struct:

type grammar struct {
	ID   string   `@Ident { @"." @Ident }`
	Next *grammar `[ @@ ]`
}

Results in this EBNF:

ID := token("Ident") .
Next := Ident { "." Ident } [ participle.grammar ] .

I'm going to revert this. I'd be happy to take another look if you can fix the bugs and add some tests.

@alexpantyukhin
Copy link
Contributor Author

Yes, it seems problem there. I will fix it.
I guess that creating intermediate structure between node -> string in ebnf generation process would be useful for testing.

@alexpantyukhin
Copy link
Contributor Author

@alecthomas .
The problem is that ebnf is basing on the node structure. If run

    fmt.Print(parser.String())

for the grammar which you pasted we wil get the following result:

strct(type=main.grammar, expr=(@(field=ID, node=token("Ident")) { (@(field=ID, node=".") @(field=ID, node=token("Ident"))) } [@(field=Next, node=<>)]))
.

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.

None yet

2 participants