github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.11k stars 4.19k forks source link

Add language: ZScript #6301

Open Witherbear opened 1 year ago

Witherbear commented 1 year ago

Language name

ZScript

URL of example repository

https://github.com/jekyllgrim/Painslayer

URL of syntax highlighting grammar

https://marketplace.visualstudio.com/items?itemName=kaptainmicila.gzdoom-zscript

Most popular extensions

.zs .zsc

Detected language

ZenScript

AeriaVelocity commented 1 year ago

ZScript also uses *.zsc (at least that's what I use, also considering *.zs is already used by ZenScript)

johnmays commented 10 months ago

Hi, @Witherbear, I was working on a PR to add ZScript, but I ran into an error that will prevent me from moving forward for now. The grammar you provided doesn't work (I followed the link on the extension page to the @KaptainMicila 's repo). In other words, when I submit that link to the add-grammar script, it finds a lot of errors (I believe every error is related to the inclusion of qualifiers like + and * in regex lookbehind assertions, which some regex engines don't allow, but I'm not an expert). Here are the errors it found in a terminal output log: output.txt.

Unless an improved grammar exists somewhere else, or someone fixes the one in the VSCode Extension's repo, ZScript can't be added to linguist. But, if you fix it or find a working grammar, I can add it!

Best, John

KaptainMicila commented 10 months ago

Hello, @johnmays. The grammar files were made to work perfectly around visual studio code's regex engine, which supports dynamic lookbehind assertions. Sadly, ruby's engine does not support this "advanced" feature (the output.txt files says so). This would require someone to make a grammar that doesn't use dynamic "lookbehind"s or somehow not use ruby's regex engine.

Be aware that making lookbehinds "static" may cause some rules to:

Just to let you know: I'm sure that entire grammar needs profiling and so it does have a lot of opportunities for optimization.

johnmays commented 10 months ago

@KaptainMicila Okay that is great info. (BTW, thanks for making the extension in the first place). I may take a look at changing it for this regex if I have some spare time. I am wondering if all of the highlighting can still take be achieved without the use of dynamic lookbehinds. Maybe not, because I do see how it can break. Maybe we will see.

Best, John