Skip to content

x/exp/ebnf: wider support for EBNF grammars #17848

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

Closed
bamarni opened this issue Nov 8, 2016 · 3 comments
Closed

x/exp/ebnf: wider support for EBNF grammars #17848

bamarni opened this issue Nov 8, 2016 · 3 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@bamarni
Copy link

bamarni commented Nov 8, 2016

At the moment, the x/exp/ebnf package implements a subset of EBNF specification and also has some golang specific syntax.

For example, the following would be parsed as valid while it is not strict EBNF :

newline = /* the Unicode code point U+000A */ .

And this one is valid EBNF but would be parsed as invalid :

newline = ? the Unicode code point U+000A ? ;

Would you accept contributions to make it support more of the EBNF spec? Or does it only target the golang specification syntax?

Some ideas :

  • support comments (* ... *)
  • support special sequence symbol ? ... ?
  • support the other terminator symbol ;
  • would it make sense to have a strict mode verify function, which doesn't allow golang comments?
@griesemer
Copy link
Contributor

griesemer commented Nov 8, 2016

Do you have a strong reason for wanting to make these changes (besides being "standard compliant")? The package is tiny, you can always make a copy and adjust it for your purposes and post elsewhere. Once we try to follow the standard, there is going to be a maintenance burden, because there will be bugs.

I'd prefer this would be left alone; as I don't see any benefit here. Specifically:

  • The package already supports /* */ comments, I don't see much difference between (* *) and /* */, except that the former requires some work to get right because text/scanner doesn't support it.
  • Using ";" instead of "." also seems of marginal benefit, though easy to do. But why have two different ways to do the same thing? (N. Wirth proposed EBNF originally, and he uses "." : http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf, page 11.)
  • I'm not a fan of the "?" notation at all. It literally raises questions when you just see it (what does it mean?) - it's definitively not self-explanatory. Using a comment gets the same job done and the meaning is more obvious. The fact that the ? symbol means 0 or 1 times in other notations only adds to the confusion.

@griesemer griesemer added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 8, 2016
@bamarni
Copy link
Author

bamarni commented Nov 8, 2016

I was looking at how to define EBNF spec for a syntax I'm working on (https://github.com/bamarni/ticketfile), and maybe use x/exp/ebnf to validate the spec file during CI.

I reported this as it could have been an improvement and possibly a first contribution. But if you think that's not worth the effort I'll probably stick to the golang spec style.

@griesemer
Copy link
Contributor

It sounds like you are free to define the syntax however you like (i.e., the exact notation is not forced upon you through some external body). If that is indeed the case, I'd recommend that you just stick to the style used in the spec if you want to use this library.

The point of EBNF is to make syntax easy to read, and our choice may not be the standard, but it's not uncommon, simple, and it's faithful to the original intent by the inventor N. Wirth (standards have a tendency to add unnecessary complexity). Instead, focus your energy on the rest of your product (just my recommendation).

On the other hand, if you insist on following that particular standard for whatever reason, I suggest you just make a local copy. The library is really small, and then you have full control over it no matter what. In fact, this might be the best choice for you since x/exp is experimental and we're not giving any guarantees about its content or how long it might stay as is or even be around.

Finally, if you're looking for a way to contribute, there's plenty of stuff to do that's interesting, and that would have more impact (because it's more important). A starting point is to look at open issues https://github.com/golang/go/issues and see if you can find something that you'd feel comfortable to tackle (search for the "suggested" label). More urgent issues can be found by looking for the Go 1.8 and Go 1.8 Maybe labels.

@golang golang locked and limited conversation to collaborators Nov 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants