Skip to content

Added updated GDScript lexer. - #842

Merged
alecthomas merged 6 commits into
alecthomas:masterfrom
admoore0:gdscript4
Sep 4, 2023
Merged

alecthomas merged 6 commits into
alecthomas:masterfrom
admoore0:gdscript4

Conversation

@admoore0

@admoore0 admoore0 commented Sep 3, 2023 •

Copy link
Copy Markdown
Contributor

Godot 4 was released a while ago, and the release changed a lot of things in GDScript. This new lexer is currently capable of processing GDScript files written in 4.0 or later. I renamed the existing GDScript lexer to GDScript3, and gave the new one (now named GDScript) a priority of 0.1. I also added some simple analyzers to differentiate if only a file extension is given.

@alecthomas

Copy link
Copy Markdown
Owner

Thanks!

Would you mind converting this to an XML lexer please? Chroma has deprecated use of Go lexers. You can do this with mkdir out && chroma --xml=out then copying out/gdscript.xml to lexers/embedded/gdscript4.xml.

Also rename this to GDScript4 (or rename the original to GDScript3).

As for the conflict, that's fairly straightforward to resolve. If GDScript4 is the most common, give it a higher <priority>0.1</priority>. I also might suggest adding some analyse patterns, see the c.xml lexer for an example:

    <analyse single="true" >
      <regex pattern="(?m)^\s*#include &lt;" score="0.1" />
      <regex pattern="(?m)^\s*#ifn?def " score="0.1" />
    </analyse>

@alecthomas

Copy link
Copy Markdown
Owner

You'll probably need to rename the existing tests to gdscript3.

@admoore0 admoore0 changed the title Draft: Added updated GDScript lexer. Added updated GDScript lexer. Sep 4, 2023
@alecthomas
alecthomas merged commit 6428fb4 into alecthomas:master Sep 4, 2023
@admoore0
admoore0 deleted the gdscript4 branch September 4, 2023 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址