Help Needed for GDScript Syntax Highilighter

tajmonetajmone Posts: 4Member

Hi everybody. This is my first post here, so forgive me if I'm posting in a wrong category.

I'm writing a GDScript language definition for André Simon's Highlight tool. I'm almost done with the task, but I have some questions about GDScript syntax.

String Escape Sequences

In Godot's docs it's mentioned that:

Strings can contain the standard C escape sequences.

I've looked at the source of gd_tokenizer.cp(line: 594) and needed some clarifications.

"\/" Escape Char

In the escapable chars list I've encountered \/:

case '/': res='/'; break; //wtf

I'm not sure wether I should include this in the highlighter escape sequences. Should I?

NOTE: Even though Godot's editor highlights all string types with the same color, the Highlight tool distinguishes between different string types, and has a special category for escape strings; so I have to decide if "\/" should be included in the list or not.

Octal, Hex and Unicode code points Escapes

Looking at gd_tokenizer.cp, I've also found:

case 'u': {
    //hexnumbarh - oct is deprecated

If I've understood correctly, Universal character names are implemented with the escape sequence \uxxxx (ie: \u followed by 4 hex digits). Correct? Also, is the number of digits fixed or it's a range from 1 to 4?

The "//hexnumbarh - oct is deprecated" comment in the source got me confused about Octal and Hexadecimal escape sequences:

As for the Octal escape sequence \nnn (ie: \ followed by either 1, 2 or 3 octal numbers), I don't understand if it's implemented or not in GDScript. Is it? If yes, how many octal digits does it take?

Regarding the Hexadecimal sequence \xhh… (ie: \x followed by 1 or more hex numbers), I couldn't work out from the source if it's implemented or not. Is it?

If anyone can help me with these I'll be thankful — and should complete the language definition quite soon, since most of the work is done, and I'm just stuck on some details and busy testing edge cases.

If I come across further questions I shall post them as additional comments on this thread; and I'll also post a link to the finished syntax file once ready (until it gets bundled with the next release of Highlight package).




  • tajmonetajmone Posts: 4Member

    I've published my first release of the syntax file:

    After further inspection of Godot source codes, I've decided to implement the above mentioned points as follows:

    • "\/" implemented
    • Universal character names implmented as \u followed by 4 hex digits.
    • Removed Octal and Hex escape sequences.

    So far it seems to work good, I've compared a good number of gdscript source files how they look in Godot's Editor and Highlight preview, and seems to be doing a good job.

    Still, if anyone has some comments on the above questions, I'll be grateful for any explanations.

Sign In or Register to comment.