-
Notifications
You must be signed in to change notification settings - Fork 65
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
Detect *.peggy
files as PEG
in GitHub
#544
Conversation
This is great, and thank you for offering to file a bug over there to get the ball rolling. Can you please add something to docs/documentation.html about this, and ensure you are in the AUTHORS file? |
Sure! I wasn't sure where to mention this in the docs. I just kind of skimmed, but I didn't see anything like a "recommended project structure" section where I could recommend a I'll get a PR out to Linguist soon. If it gets approve and isn't marked |
Yes, those examples are fine. The most interesting one is probably fizzbuzz.peggy which tries to have one of every syntax construct, including ones that have been added since the fork from PEG.js. I've got several other projects to point to if you need them. Please link to the linguist bug here for tracking. If you add a section almost at the end, before "Compatibility", I can also say something about the new TypeScript support (which hasn't shipped yet) in that section; it would say "put your .peggy file in src/, generate parser.js and parser.d.ts into lib/, and reference the .js file in your .ts file with '../lib/parser.js'". I think this would be a good place to suggest using a .peggy.confg.js file as well. I'll add all of that if you stub it out. |
Looks like we commented at the same time 😆 I opted for the semver example because it's a bit more "real world" in terms of its usage. Linguist doesn't like "Hello world" style examples, and I think a fizzbuzz example could fall under that category. |
Note the new grammar syntax constructs since the fork are:
|
🤔 That syntax is supported by the VS Code extension, right? Is that backwards-compatible with "old" PEG.js? If so, it might be worth updating Linguist to also use the new syntax grammar. The current grammar comes from here, I think. Or it may be worth making a PR into https://github.com/Alhadis/language-grammars to update the grammar there. |
Yes, because I maintain that now, too, and IIRC someone sent me a patch. Current code is here: https://github.com/peggyjs/code-peggy-language
Yes, it's worth doing that at the same time. The new syntax is a proper superset of the PEG.js syntax; backward-compatibility has been a high priority for Peggy. |
If you want a lower-latency way to talk this all through, we've got a Discord you can get to from https://peggyjs.org/ |
Another good example that is real-world here: https://github.com/hildjj/node-abnf/blob/main/lib/abnfp.peggy |
The Linguist PR was approved, so this PR probably isn't needed after all. |
OK, I'm going to close this as overcome by events, but feel free to either re-open or add more comments here as needed. I've subscribed to the linguist bug to watch for other updates. Let us know if we can help with updating the syntax. Thanks for the work! |
Superseded by github-linguist/linguist#7017 |
Thank goodness I stumbled on this! I was about to give up on using the (unmaintained) PEG.js.
Linguist is the tool that GitHub uses to detect languages. This adds an override to
.gitattributes
to make Linguist detect files with the.peggy
extension as PEG.js. This adds syntax highlighting to those files, and makes sure that they're included in the language stats.Unfortunately,
.peggy
doesn't seem to be popular enough yet to "officially" be made a PEG.js extension. I'll make a PR there just in case. So for now, using the language override seems to be the best way to get.peggy
files detected as code. Vim or Emacs modelines can also be used.