Skip to content
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

Added updated GDScript lexer. #842

Merged
merged 6 commits into from
Sep 4, 2023
Merged

Conversation

admoore0
Copy link
Contributor

@admoore0 admoore0 commented Sep 3, 2023

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
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
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
2 checks passed
@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