linguist icon indicating copy to clipboard operation
linguist copied to clipboard

Add language: ZScript

Open Witherbear opened this issue 3 years ago • 4 comments

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

Witherbear avatar Mar 01 '23 19:03 Witherbear

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

AeriaVelocity avatar Mar 02 '23 15:03 AeriaVelocity

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

johnmays avatar Nov 05 '23 02:11 johnmays

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:

  • Complete break if they require more than one word behind them or around them
  • Not handle more than one space

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

KaptainMicila avatar Nov 05 '23 09:11 KaptainMicila

@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

johnmays avatar Nov 05 '23 09:11 johnmays